From 41ce6b67c02ff4ec5f33da8b70b4076d09d95ea2 Mon Sep 17 00:00:00 2001 From: nathaniel smith Date: Sat, 1 Aug 2015 17:16:36 -0700 Subject: [PATCH] splash of color / sorting --- tildetown-py/cgi.py | 6 ++++-- tildetown-py/templates/guestbook.html | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tildetown-py/cgi.py b/tildetown-py/cgi.py index 797dbb6..d8b7e27 100644 --- a/tildetown-py/cgi.py +++ b/tildetown-py/cgi.py @@ -53,10 +53,12 @@ def get_random(): def get_guestbook(): data_dir = app.config['DATA_DIR'] # TODO sort by timestamp - posts = map(lambda p: json.loads(slurp(os.path.join(data_dir, p))), os.listdir(data_dir)) + filename_to_json = lambda p: json.loads(slurp(os.path.join(data_dir, p))) + posts = map(filename_to_json, os.listdir(data_dir)) + sorted_posts = sorted(posts, key=lambda p: p['timestamp']) context = { - "posts": posts, + "posts": sorted_posts, } context.update(site_context()) return render_template('guestbook.html', **context) diff --git a/tildetown-py/templates/guestbook.html b/tildetown-py/templates/guestbook.html index d8d531b..890b002 100644 --- a/tildetown-py/templates/guestbook.html +++ b/tildetown-py/templates/guestbook.html @@ -2,6 +2,7 @@ {{site_name}} guestbook +

{{site_name}} guestbook