splash of color / sorting

master
nathaniel smith 2015-08-01 17:16:36 -07:00
parent a1ceb740dd
commit 41ce6b67c0
2 changed files with 5 additions and 2 deletions

View File

@ -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)

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>{{site_name}} guestbook</title>
<link rel="stylesheet" type="text/css" href="http://tilde.town/style.css">
</head>
<body>
<h1>{{site_name}} guestbook</h1>