Download:
child 31:edd83c4dc2f0
parent 29:58bcac03bba9
30:ac681cc74573
Anton Shestakov <engored@ya.ru>, Thu, 28 May 2015 20:26:57 +0800
viewer: use setrev() for the back to tip link

2 файлов изменено, 18 вставок(+), 6 удалений(-) [+]
templates/results.html file | annotate | diff | comparison | revisions
viewer.py file | annotate | diff | comparison | revisions
--- a/templates/results.html Thu May 28 15:36:56 2015 +0800
+++ b/templates/results.html Thu May 28 20:26:57 2015 +0800
@@ -32,7 +32,7 @@
</head>
<body>
<header>
- <a href="/results.html">back to tip</a>
+ <a href="{{ setrev() }}">back to tip</a>
{% set prevrev = changesets[0]['rev'] + 120 if changesets else None %}
{% if prevrev %}<a href="{{ setrev(prevrev) }}">prev page</a>{% end %}
{% set nextrev = changesets[-1]['rev'] - 1 if changesets else None %}
@@ -88,7 +88,7 @@
</tbody>
</table>
<footer>
- <a href="/results.html">back to tip</a>
+ <a href="{{ setrev() }}">back to tip</a>
{% if prevrev %}<a href="{{ setrev(prevrev) }}">prev page</a>{% end %}
{% if nextrev > -1 %}<a href="{{ setrev(nextrev) }}">next page</a>{% end %}
</footer>
--- a/viewer.py Thu May 28 15:36:56 2015 +0800
+++ b/viewer.py Thu May 28 20:26:57 2015 +0800
@@ -148,12 +148,24 @@
pass
else:
kwargs['local'] = [str(value)]
- return '?' + self.urlencode(**kwargs)
+ if kwargs:
+ return '?' + self.urlencode(**kwargs)
+ else:
+ return self.request.path
- def setrev(self, value):
+ def setrev(self, value=None):
kwargs = self.request.arguments.copy()
- kwargs['rev'] = ['rev({})'.format(value)]
- return '?' + self.urlencode(**kwargs)
+ if value is None:
+ try:
+ kwargs.pop('rev')
+ except KeyError:
+ pass
+ else:
+ kwargs['rev'] = ['rev({})'.format(value)]
+ if kwargs:
+ return '?' + self.urlencode(**kwargs)
+ else:
+ return self.request.path
def results_html(self):
changesets = self.getchangesets()