yenu/src/clj/yenu/routes/core.clj

28 lines
837 B
Clojure
Raw Normal View History

2017-03-15 00:28:27 +01:00
(ns yenu.routes.core
(:require [yenu.layout :as layout]
[compojure.core :refer [defroutes GET POST]]
[ring.util.http-response :as response]
[ring.util.response :refer [redirect file-response]]
[yenu.helpers.images :as images]
[yenu.db.core :as db]))
(defn index-page []
(layout/render "index.html"
{:images (db/get-all-images {:offset 0 :count 10})}))
(defn image-file [type hash ext]
(let [filename (str hash "." ext)]
(file-response (images/data-path "gallery" type filename))))
(defroutes core-routes
(GET "/" []
(index-page))
(GET ["/images/:type/:hash.:ext"
;;:type #"(normal|raw|thumbnails)"
;;:hash #"[0-9]+-[^.]+"
;;:ext #"(png|jpg)"
]
[type hash ext]
(image-file type hash ext)))