Mercurial > hg-stable
changeset 10247:e8c7410371e0
hgweb: add less/more links for search logs (issue1972)
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Thu, 14 Jan 2010 16:42:10 +0100 |
parents | b9d02695bde4 |
children | 4441e8d7f04f |
files | mercurial/hgweb/webcommands.py mercurial/templates/paper/search.tmpl |
diffstat | 2 files changed, 31 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py Thu Jan 14 16:28:21 2010 +0100 +++ b/mercurial/hgweb/webcommands.py Thu Jan 14 16:42:10 2010 +0100 @@ -98,7 +98,20 @@ except ErrorResponse: raise inst -def _search(web, tmpl, query): +def _search(web, req, tmpl): + + query = req.form['rev'][0] + revcount = web.maxchanges + if 'revcount' in req.form: + revcount = int(req.form.get('revcount', [revcount])[0]) + tmpl.defaults['sessionvars']['revcount'] = revcount + + lessvars = copy.copy(tmpl.defaults['sessionvars']) + lessvars['revcount'] = revcount / 2 + lessvars['rev'] = query + morevars = copy.copy(tmpl.defaults['sessionvars']) + morevars['revcount'] = revcount * 2 + morevars['rev'] = query def changelist(**map): cl = web.repo.changelog @@ -146,19 +159,18 @@ inbranch=webutil.nodeinbranch(web.repo, ctx), branches=webutil.nodebranchdict(web.repo, ctx)) - if count >= web.maxchanges: + if count >= revcount: break cl = web.repo.changelog parity = paritygen(web.stripecount) - return tmpl('search', - query=query, - node=hex(cl.tip()), - entries=changelist, - archives=web.archivelist("tip")) + return tmpl('search', query=query, node=hex(cl.tip()), + entries=changelist, archives=web.archivelist("tip"), + morevars=morevars, lessvars=lessvars) -def changelog(web, req, tmpl, shortlog = False): +def changelog(web, req, tmpl, shortlog=False): + if 'node' in req.form: ctx = webutil.changectx(web.repo, req) else: @@ -169,7 +181,7 @@ try: ctx = web.repo[hi] except error.RepoError: - return _search(web, tmpl, hi) # XXX redirect to 404 page? + return _search(web, req, tmpl) # XXX redirect to 404 page? def changelist(limit=0, **map): l = [] # build a list in forward order for efficiency
--- a/mercurial/templates/paper/search.tmpl Thu Jan 14 16:28:21 2010 +0100 +++ b/mercurial/templates/paper/search.tmpl Thu Jan 14 16:42:10 2010 +0100 @@ -28,6 +28,11 @@ files, or words in the commit message</div> </form> +<div class="navigate"> +<a href="{url}search/{lessvars%urlparameter}">less</a> +<a href="{url}search/{morevars%urlparameter}">more</a> +</div> + <table class="bigtable"> <tr> <th class="age">age</th> @@ -37,6 +42,11 @@ {entries} </table> +<div class="navigate"> +<a href="{url}search/{lessvars%urlparameter}">less</a> +<a href="{url}search/{morevars%urlparameter}">more</a> +</div> + </div> </div>