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