# HG changeset patch # User Matt Johnston # Date 1432741503 -28800 # Node ID 141948a400a6e116c964f9bb3b0d9377bd55ad17 # Parent c490de0cf17e166caeae4cf3e9ff5079922b908a working zoom diff -r c490de0cf17e -r 141948a400a6 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 c490de0cf17e -r 141948a400a6 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 c490de0cf17e -r 141948a400a6 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.