# HG changeset patch # User Steve Losh # Date 1276454272 14400 # Node ID bcdc35f68d5d021b0f4d4ee52bafadd21c4b0e96 # Parent 80d65cd81298caef9ffd15e306ca9df6777e1939 web: add pagination diff -r 80d65cd81298 -r bcdc35f68d5d review/static/style.css --- a/review/static/style.css Sun Jun 13 13:39:58 2010 -0400 +++ b/review/static/style.css Sun Jun 13 14:37:52 2010 -0400 @@ -203,6 +203,7 @@ } #index .content table tr td.node { padding-left: 0px; + width: 110px; } #index .content table tr td.node .rev { font-weight: bold; @@ -247,6 +248,9 @@ #index .content table tr td.stats .badge:hover { text-decoration: none; } +#index .content .pagination a.older { + float: right; +} #changeset .content .fulldesc { font-size: 18px; line-height: 1.25; diff -r 80d65cd81298 -r bcdc35f68d5d review/static/style.less --- a/review/static/style.less Sun Jun 13 13:39:58 2010 -0400 +++ b/review/static/style.less Sun Jun 13 14:37:52 2010 -0400 @@ -240,6 +240,7 @@ } &.node { padding-left: 0px; + width: 110px; .rev { font-weight: bold; @@ -289,6 +290,11 @@ } } } + .pagination { + a.older { + float: right; + } + } } #changeset .content { .fulldesc { diff -r 80d65cd81298 -r bcdc35f68d5d review/templates/index.html --- a/review/templates/index.html Sun Jun 13 13:39:58 2010 -0400 +++ b/review/templates/index.html Sun Jun 13 14:37:52 2010 -0400 @@ -39,4 +39,13 @@ {% endfor %} + + {% endblock %} diff -r 80d65cd81298 -r bcdc35f68d5d review/web_ui.py --- a/review/web_ui.py Sun Jun 13 13:39:58 2010 -0400 +++ b/review/web_ui.py Sun Jun 13 14:37:52 2010 -0400 @@ -33,7 +33,7 @@ from flask import abort, redirect, render_template, request app = Flask(__name__) -LOG_PAGE_LEN = 1000000 +LOG_PAGE_LEN = 15 def _item_gravatar(item): return 'http://www.gravatar.com/avatar/%s?s=30' % md5(email(item.author)).hexdigest() @@ -66,11 +66,27 @@ @app.route('/') -def index(): - rev_max = app.datastore.target['tip'].rev() +def index_newest(): + return index(-1) + +@app.route('//') +def index(rev_max): + tip = app.datastore.target['tip'].rev() + + if rev_max > tip or rev_max < 0: + rev_max = tip + rev_min = rev_max - LOG_PAGE_LEN if rev_max >= LOG_PAGE_LEN else 0 - rcsets = [app.datastore[r] for r in xrange(rev_max, rev_min, -1)] - return _render('index.html', rcsets=rcsets) + if rev_min < 0: + rev_min = 0 + + older = rev_min - 1 if rev_min > 0 else -1 + newer = rev_max + LOG_PAGE_LEN + 1 if rev_max < tip else -1 + if newer > tip: + newer = tip + + rcsets = [app.datastore[r] for r in xrange(rev_max, rev_min - 1, -1)] + return _render('index.html', rcsets=rcsets, newer=newer, older=older) def _handle_signoff(revhash):