# HG changeset patch # User Matt Johnston # Date 1432741503 -28800 # Node ID 0baa57b6d9ca105e9cec4e2fd374e9c4ed8cc64d # Parent b3dc81bee5b3f8aea2d5f7657eaed29598491f63 working zoom diff -r b3dc81bee5b3 -r 0baa57b6d9ca web/templog.py --- a/web/templog.py Wed May 27 22:37:43 2015 +0800 +++ b/web/templog.py Wed May 27 23:45:03 2015 +0800 @@ -66,7 +66,8 @@ @route('/graph.png') def graph(): response.set_header('Content-Type', 'image/png') - return make_graph(request.query.length, request.query.end) + minutes, endstr = get_request_zoom() + return make_graph(minutes, endstr) @route('/set/update', method='post') def set_update(): @@ -94,9 +95,9 @@ csrf_blob = secure.get_csrf_blob(), allowed = allowed) -@route('/') -def top(): - +def get_request_zoom(): + """ returns (length, end) tuple. + length is in minutes, end is a DATE_FORMAT string """ minutes = int(request.query.get('length', 26*60)) if 'end' in request.query: @@ -124,14 +125,21 @@ if end > datetime.now(): end = datetime.now() - + + endstr = end.strftime(DATE_FORMAT) + return (minutes, endstr) + +@route('/') +def top(): + minutes, endstr = get_request_zoom() + request.query.replace('length', minutes) - request.query.replace('end', end.strftime(DATE_FORMAT)) + request.query.replace('end', endstr) urlparams = urllib.urlencode(request.query) - graphdata = encode_data(make_graph(request.query.length, request.query.end), 'image/png') + graphdata = encode_data(make_graph(minutes, endstr), 'image/png') return bottle.template('top', urlparams=urlparams, - end = end.strftime(DATE_FORMAT), + end = endstr, length = minutes, graphwidth = config.GRAPH_WIDTH, graphdata = graphdata) diff -r b3dc81bee5b3 -r 0baa57b6d9ca web/templog.wsgi --- a/web/templog.wsgi Wed May 27 22:37:43 2015 +0800 +++ b/web/templog.wsgi Wed May 27 23:45:03 2015 +0800 @@ -1,6 +1,5 @@ #from gevent import monkey; monkey.patch_all() - import os import sys # Change working directory so relative paths (and template lookup) work again diff -r b3dc81bee5b3 -r 0baa57b6d9ca web/views/top.tpl --- a/web/views/top.tpl Wed May 27 22:37:43 2015 +0800 +++ b/web/views/top.tpl Wed May 27 23:45:03 2015 +0800 @@ -26,17 +26,19 @@ -
- + + - +
Click to zoom in, click the left axis to zoom out. Source code for the Raspberry Pi controller and this web interface. Adjustments by phone.