From 257436a8843e9cbdcad3cd054d61276bc83c85bc Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Mon, 20 Mar 2017 23:16:58 +0100 Subject: [PATCH] Add forward and back buttons and detail view --- resources/sql/queries.sql | 12 ++++++++++++ resources/templates/detail.html | 20 ++++++++++++++++++++ resources/templates/index.html | 16 ++++++++-------- src/clj/yenu/routes/core.clj | 11 +++++++++++ 4 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 resources/templates/detail.html diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql index 64ba0d8..ab090ed 100644 --- a/resources/sql/queries.sql +++ b/resources/sql/queries.sql @@ -22,6 +22,18 @@ LIMIT :count OFFSET :offset -- :name get-image-count :? :1 SELECT COUNT(id) as count FROM images +-- :name get-next-image :? :1 +SELECT * FROM images +WHERE created_at > :image-date +ORDER BY created_at ASC +LIMIT 1 + +-- :name get-prev-image :? :1 +SELECT * FROM images +WHERE created_at < :image-date +ORDER BY created_at DESC +LIMIT 1 + -- :name create-tag! :i! INSERT OR IGNORE INTO tags (tagname) diff --git a/resources/templates/detail.html b/resources/templates/detail.html new file mode 100644 index 0000000..44776dc --- /dev/null +++ b/resources/templates/detail.html @@ -0,0 +1,20 @@ +{% extends "layout.html" %} + +{% block content %} + +{% if next-image %} +Weiter +{% endif %} + +{% if prev-image %} +Zurück +{% endif %} + +

{{ image.title }}

+{{ image.title }} + +{% if image.description|length > 0 %} +

{{ image.description }}

+{% endif %} + +{% endblock %} diff --git a/resources/templates/index.html b/resources/templates/index.html index e280528..57649d6 100644 --- a/resources/templates/index.html +++ b/resources/templates/index.html @@ -1,6 +1,14 @@ {% extends "layout.html" %} {% block content %} +
+ {% for image in images %} + + {{ image.title }} + + {% endfor %} +
+
{% if pages|count > 1 %}