--- a/templates/results.html Wed May 27 18:57:30 2015 +0800
+++ b/templates/results.html Thu May 28 15:11:01 2015 +0800
<a href="/results.html">back to tip</a>
{% set prevrev = changesets[0]['rev'] + 120 if changesets else None %}
- {% if prevrev %}<a href="?rev=rev({{ prevrev }})">prev page</a>{% end %}
+ {% if prevrev %}<a href="{{ setrev(prevrev) }}">prev page</a>{% end %}
{% set nextrev = changesets[-1]['rev'] - 1 if changesets else None %}
- {% if nextrev > -1 %}<a href="?rev=rev({{ nextrev }})">next page</a>{% end %}
+ {% if nextrev > -1 %}<a href="{{ setrev(nextrev) }}">next page</a>{% end %}
<span style="color: #777;">
- hover things for a tooltip; red means slowest ever, green means fastest
- ever; first color and time means without .hg/cache, second means with
+ hover things for a tooltip; red means slow, green means fast; first
+ color and time means without .hg/cache, second means with .hg/cache.
+ local colors (<a href="{{ setlocal(None) }}">switch to global colors</a>)
+ global colors (<a href="{{ setlocal(1) }}">switch to local colors</a>)
<a href="/results.html">back to tip</a>
- {% if prevrev %}<a href="?rev=rev({{ prevrev }})">prev page</a>{% end %}
- {% if nextrev > -1 %}<a href="?rev=rev({{ nextrev }})">next page</a>{% end %}
+ {% if prevrev %}<a href="{{ setrev(prevrev) }}">prev page</a>{% end %}
+ {% if nextrev > -1 %}<a href="{{ setrev(nextrev) }}">next page</a>{% end %}
--- a/viewer.py Wed May 27 18:57:30 2015 +0800
+++ b/viewer.py Thu May 28 15:11:01 2015 +0800
+from urllib import quote_plus
from tornado.ioloop import IOLoop
from tornado.options import define, options
+ def urlencode(self, **kwargs):
+ def joinparams(params):
+ return ','.join(quote_plus(i, '()') for i in params)
+ return '&'.join(quote_plus(k) + '=' + joinparams(v) for k, v in kwargs.items())
+ def setlocal(self, value=None):
+ kwargs = self.request.arguments.copy()
+ kwargs['local'] = [str(value)]
+ return '?' + self.urlencode(**kwargs)
+ def setrev(self, value):
+ kwargs = self.request.arguments.copy()
+ kwargs['rev'] = ['rev({})'.format(value)]
+ return '?' + self.urlencode(**kwargs)
changesets = self.getchangesets()
- results = self.getresults(changesets, self.get_argument('local', False))
- self.render('results.html', changesets=changesets, marks=MARKS, results=results)
+ local = self.get_argument('local', False)
+ results = self.getresults(changesets, local)
+ 'changesets': changesets,
+ 'setlocal': self.setlocal,
+ self.render('results.html', **context)
def green_to_red((low, high), value):