From 46bad35efce8817fd9fae0450e416f820ff742ce Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Tue, 15 Nov 2016 13:50:20 +0100 Subject: Simplify older/newer logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Löthberg --- scripts/build.py | 9 ++------- templates/entry.html | 6 +++--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/scripts/build.py b/scripts/build.py index 03b83b3..2b6055d 100755 --- a/scripts/build.py +++ b/scripts/build.py @@ -81,13 +81,8 @@ if __name__ == '__main__': build_entry(jenv, entry) for index, entry in enumerate(published): - older = None - newer = None - if index > 0: - older = published[index-1] - if index < len(published) - 1: - newer = published[index+1] - + older = published[index:index-1] + newer = published[index:index+1] build_entry(jenv, entry, older, newer) if len(published) > 1: diff --git a/templates/entry.html b/templates/entry.html index f5f11c7..730e48d 100644 --- a/templates/entry.html +++ b/templates/entry.html @@ -12,11 +12,11 @@
{% if older and newer%} - Older ({{ older['title'] }})Newer ({{ newer['title'] }}) + Older ({{ older[0]['title'] }})Newer ({{ newer[0]['title'] }}) {% elif older %} - Older ({{ older['title'] }}) + Older ({{ older[0]['title'] }}) {% elif newer %} - Newer ({{ newer['title'] }}) + Newer ({{ newer[0]['title'] }}) {% endif %}
{% endblock %} -- cgit v1.2.3-70-g09d2