By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

Pagination for commit lists

roundabout,
created on Wednesday, 24 April 2024, 16:18:25 (1713975505), received on Wednesday, 31 July 2024, 06:54:46 (1722408886)
Author identity: vlad <vlad.muntoiu@gmail.com>

ab830271b4880553ef4471a91f9b0005f3403889

app.py

@@ -1196,7 +1196,20 @@ def repository_log(username, repository, branch):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                               git_command(server_repo_location, None, "log",
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                           "--format='%H'").decode().split("\n")]
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            commits = Commit.query.filter(Commit.identifier.in_(commit_list))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            commits = Commit.query.filter(Commit.identifier.in_(commit_list)).order_by(Commit.author_date.desc())
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            page_number = flask.request.args.get("page", 1, type=int)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            page_length = flask.request.args.get("per_page", 2, type=int)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            page_listing = db.paginate(commits, page=page_number, per_page=page_length)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            if page_listing.has_next:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                next_page = page_listing.next_num
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            else:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                next_page = None
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            if page_listing.has_prev:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                prev_page = page_listing.prev_num
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            else:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                prev_page = None
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                return flask.render_template(
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        "repo-log.html",
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -1206,9 +1219,13 @@ def repository_log(username, repository, branch):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        current=branch,
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        repo_data=repo_data,
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        repo=repo,
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    commits=commits,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    commits=page_listing,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    is_favourite=get_favourite(flask.session.get("username"), username, repository)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    is_favourite=get_favourite(flask.session.get("username"), username, repository),
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    page_number=page_number,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    page_length=page_length,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    next_page=next_page,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    prev_page=prev_page
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                )
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

default_avatars/penguin.svg

@@ -8,7 +8,7 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                               version="1.1"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                               id="svg1"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                               xml:space="preserve"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                           inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                           inkscape:version="1.3.2 (091e20ef0f, 2023-11-25)"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                               sodipodi:docname="penguin.svg"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                               xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                               xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -23,11 +23,18 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                 inkscape:pagecheckerboard="0"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                 inkscape:deskcolor="#d1d1d1"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                 inkscape:document-units="px"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                             inkscape:zoom="3.2971429"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                             inkscape:cx="46.403812"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                             inkscape:cy="132.2357"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                             inkscape:zoom="0.75893496"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                             inkscape:cx="-333.3619"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                             inkscape:cy="-183.1514"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                 inkscape:current-layer="layer1" /><defs
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                             id="defs1" /><g
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                             id="defs1"><clipPath
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                               clipPathUnits="userSpaceOnUse"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                               id="clipPath11"><circle
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                 style="fill:#00bcd4;stroke-width:3.175;stroke-miterlimit:8"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                 id="circle12"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                 cx="25.4"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                 cy="25.4"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                 r="25.4" /></clipPath></defs><g
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                 inkscape:label="Strat 1"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                 inkscape:groupmode="layer"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                 id="layer1"><circle
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -36,6 +43,7 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                   cx="25.4"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                   cy="25.4"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                   r="25.4" /><path
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                               d="m 30.941406,21.901154 c -0.889006,0.592644 -3.70419,2.201349 -4.127529,2.518847 -0.825501,0.656164 -1.587505,0.613844 -2.413014,-0.0208 -0.423362,-0.338642 -3.238515,-1.947339 -4.12752,-2.518847 -1.016006,-0.656164 -0.95251,-1.481672 0.169361,-1.947339 3.471356,-1.460513 6.942713,-1.35468 10.392893,0.0632 1.037174,0.444483 1.07951,1.270008 0.105841,1.905011 M 46.223864,37.310654 C 44.255356,32.886795 41.567172,28.8651 38.095816,25.330247 36.973977,24.166072 36.275477,22.853736 35.852139,21.350887 35.640457,20.652403 35.492297,19.932719 35.344136,19.213043 34.920773,17.350368 34.730292,15.445356 33.862463,13.688514 32.317286,10.344158 29.629102,8.6084839 25.734415,8.4603149 c -3.831191,0.105841 -6.688712,1.7145061 -8.36089,5.0800301 -0.444482,0.910173 -0.762004,1.862675 -0.973669,2.836345 -0.359842,1.608681 -0.677364,3.280859 -1.058343,4.910701 -0.317521,1.37584 -0.952501,2.561183 -2.032012,3.619517 -3.407852,3.323188 -6.138367,7.13321 -8.212712,11.324235 -0.296338,0.613844 -0.5926676,1.227679 -0.7831728,1.862683 -0.4021703,1.397008 0.6138358,2.370678 2.0955128,2.032012 0.931336,-0.190481 1.862677,-0.381042 2.751682,-0.656164 0.867837,-0.317522 1.206503,-0.10584 1.418177,0.740805 1.37584,4.550859 4.381522,7.747046 8.974717,9.525056 8.720723,3.30202 18.901944,-1.397008 21.103293,-9.694393 0.14816,-0.571524 0.359842,-0.783205 0.994837,-0.571524 0.973678,0.296322 1.968516,0.508003 2.963354,0.740805 1.037174,0.190481 1.799179,-0.338642 1.947347,-1.354672 0.0632,-0.550324 -0.12704,-1.037174 -0.338642,-1.545177"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                               id="path1-6"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                               style="fill:#e0f7fa;stroke-width:2.11668" /></g></svg>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                               id="path2"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                               style="fill:#e0f7fa;stroke-width:1.52208"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                               d="M 25.400004,-9.7682436e-8 A 8.4666672,8.4666672 0 0 0 16.933332,8.4666662 v 6.7344728 c -0.44872,0.204936 -0.869872,0.489536 -1.240232,0.859896 L 3.7207081,28.033431 c -1.6583599,1.658353 -1.6583599,4.327846 0,5.986198 1.658352,1.658352 4.3278401,1.658352 5.9861921,0 l 1.2319688,-1.231966 a 14.816666,14.816666 0 0 0 4.105175,7.441406 14.816666,14.816666 0 0 0 20.881414,-0.169499 14.816666,14.816666 0 0 0 3.948079,-7.259505 l 1.219564,1.219564 c 1.658352,1.658352 4.327845,1.658352 5.986197,0 1.658353,-1.658352 1.658353,-4.327845 0,-5.986198 L 35.106902,16.061035 c -0.37036,-0.37036 -0.791496,-0.65496 -1.240234,-0.859896 V 8.4666662 A 8.4666672,8.4666672 0 0 0 25.400004,-9.7682436e-8 Z M 21.166668,6.9205078 a 2.1166668,2.1166668 0 0 1 2.116664,2.1166664 2.1166668,2.1166668 0 0 1 -2.116664,2.1166668 2.1166668,2.1166668 0 0 1 -2.116664,-2.1166668 2.1166668,2.1166668 0 0 1 2.116664,-2.1166664 z m 8.466664,0 a 2.1166668,2.1166668 0 0 1 2.11667,2.1166664 2.1166668,2.1166668 0 0 1 -2.11667,2.1166668 2.1166668,2.1166668 0 0 1 -2.116664,-2.1166668 2.1166668,2.1166668 0 0 1 2.116664,-2.1166664 z m -8.466664,6.3500002 h 8.466664 l -4.233328,4.233333 z m -6.35,33.296159 V 50.8 h 8.466664 v -4.233333 z m 12.7,0 V 50.8 h 8.466667 v -4.233333 z"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                               clip-path="url(#clipPath11)" /></g></svg>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

static/style.css

@@ -555,3 +555,17 @@ strong, em {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                align-items: center;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                justify-content: center;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        #pagination {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            display: flex;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            gap: 1em;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            justify-content: center;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            align-items: center;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            font-size: 1.5em;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            font-weight: 600;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        #pagination > a {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            text-decoration: none;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            color: var(--color-accent-1);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

templates/repository/repo-log.html

@@ -70,6 +70,25 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                    </section>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                </article>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            {% endfor %}
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        <x-hbox id="pagination">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            {% if prev_page %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                <a href="?page=1">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    «
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                </a>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                <a href="?page={{ prev_page }}">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                </a>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            {% endif %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            <span>{{ page_number }}</span>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            {% if next_page %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                <a href="?page={{ next_page }}">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                </a>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                <a href="?page={{ last_page }}">
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                    »
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                </a>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            {% endif %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        </x-hbox>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        </x-vbox>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    </x-frame>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                </x-vbox>