diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql
index 9f69fd3..2a382e4 100644
--- a/resources/sql/queries.sql
+++ b/resources/sql/queries.sql
@@ -84,6 +84,15 @@ SELECT * FROM comments
WHERE image_id = :image_id
ORDER BY created_at ASC
+-- :name get-comment :? :1
+SELECT * FROM comments
+WHERE id = :id
+LIMIT 1
+
+-- :name delete-comment! :! :1
+DELETE FROM comments
+WHERE id = :id
+
-- :name get-recent-comments :? :*
SELECT comments.*, images.title FROM comments
LEFT JOIN images ON images.id = comments.image_id
diff --git a/resources/templates/detail.html b/resources/templates/detail.html
index 2c28867..07d4fbe 100644
--- a/resources/templates/detail.html
+++ b/resources/templates/detail.html
@@ -72,6 +72,9 @@
{{ comment.author }}
+ {% ifequal identity ":creator" %}
+
Löschen
+ {% endifequal %}
{{ comment.comment|markdown-to-html|safe }}
diff --git a/src/clj/yenu/routes/admin.clj b/src/clj/yenu/routes/admin.clj
index 5584f9e..427dbb9 100644
--- a/src/clj/yenu/routes/admin.clj
+++ b/src/clj/yenu/routes/admin.clj
@@ -58,6 +58,9 @@
(db/delete-image-tags! {:id id})
(add-tags-for-image id tags))
+(defn image-id-from-comment [id]
+ (:image_id (db/get-comment {:id id})))
+
(defroutes admin-routes
(GET "/upload" [:as request]
(-> (layout/render
@@ -75,6 +78,12 @@
(-> (redirect "/page/1")
(assoc :flash {:message "Bild wurde gelöscht" :type "danger"})))
+ (GET "/delete-comment/:id" [id]
+ (let [image-id (image-id-from-comment id)]
+ (db/delete-comment! {:id id})
+ (-> (redirect (str "/show/" image-id))
+ (assoc :flash {:message "Kommentar wurde gelöscht" :type "danger"}))))
+
(GET "/edit/:id" [id :as request]
(edit-image-form id request))
diff --git a/src/clj/yenu/routes/core.clj b/src/clj/yenu/routes/core.clj
index 2eef273..b41dcbd 100644
--- a/src/clj/yenu/routes/core.clj
+++ b/src/clj/yenu/routes/core.clj
@@ -35,16 +35,15 @@
(page (inc current) (= current num) "disabled" (h/html "Weiter " [:span.fa.fa-arrow-right]))]]
[:div.clearfix]))
-(defn index-page [current-page request]
+(defn index-page [current request]
(let [image-count 25
- offset (* (dec current-page) image-count)
+ offset (* (dec current) image-count)
pages (number-of-pages image-count)
images (db/get-all-images {:offset offset :count image-count})]
(layout/render "index.html"
{:images images
:flash (:flash request)
- :current-page current-page
- :pagination (pagination pages current-page)})))
+ :pagination (pagination pages current)})))
(defn detail-page [image-id request]
(let [image (db/get-image {:id image-id})