|
|
@ -19,6 +19,22 @@
|
|
|
|
(res/status 500)
|
|
|
|
(res/status 500)
|
|
|
|
(res/send (ex-message err))))))))
|
|
|
|
(res/send (ex-message err))))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn admin-panel-handler-factory
|
|
|
|
|
|
|
|
[client]
|
|
|
|
|
|
|
|
(fn [req res]
|
|
|
|
|
|
|
|
(let [channel (chan)
|
|
|
|
|
|
|
|
id (.-id (.-params req))]
|
|
|
|
|
|
|
|
(go
|
|
|
|
|
|
|
|
(try
|
|
|
|
|
|
|
|
(let [articles (<! (db/get-articles client channel))]
|
|
|
|
|
|
|
|
(res/status 200)
|
|
|
|
|
|
|
|
(.render res "admin_panel"
|
|
|
|
|
|
|
|
(-> {:articles articles}
|
|
|
|
|
|
|
|
(cljs.core/clj->js))))
|
|
|
|
|
|
|
|
(catch js/Error err
|
|
|
|
|
|
|
|
(res/status 500)
|
|
|
|
|
|
|
|
(res/send (ex-message err))))))))
|
|
|
|
|
|
|
|
|
|
|
|
(defn htmx-get-article-handler-factory
|
|
|
|
(defn htmx-get-article-handler-factory
|
|
|
|
[client]
|
|
|
|
[client]
|
|
|
|
(fn [req res]
|
|
|
|
(fn [req res]
|
|
|
@ -40,3 +56,45 @@
|
|
|
|
(res/status 500)
|
|
|
|
(res/status 500)
|
|
|
|
(res/send (ex-message err))))))))
|
|
|
|
(res/send (ex-message err))))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn htmx-get-article-row-handler-factory
|
|
|
|
|
|
|
|
[client]
|
|
|
|
|
|
|
|
(fn [req res]
|
|
|
|
|
|
|
|
(let [channel (chan)
|
|
|
|
|
|
|
|
id (.-id (.-params req))]
|
|
|
|
|
|
|
|
(go
|
|
|
|
|
|
|
|
(try
|
|
|
|
|
|
|
|
(let [article (<! (db/get-article client id channel))]
|
|
|
|
|
|
|
|
(if (empty? article)
|
|
|
|
|
|
|
|
(do
|
|
|
|
|
|
|
|
(res/status 404)
|
|
|
|
|
|
|
|
(res/send (ex-message "404")))
|
|
|
|
|
|
|
|
(do
|
|
|
|
|
|
|
|
(res/status 200)
|
|
|
|
|
|
|
|
(.render res "article_row"
|
|
|
|
|
|
|
|
(-> {:article article :layout false}
|
|
|
|
|
|
|
|
(cljs.core/clj->js))))))
|
|
|
|
|
|
|
|
(catch js/Error err
|
|
|
|
|
|
|
|
(res/status 500)
|
|
|
|
|
|
|
|
(res/send (ex-message err))))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn htmx-get-article-row-handler-factory
|
|
|
|
|
|
|
|
[client]
|
|
|
|
|
|
|
|
(fn [req res]
|
|
|
|
|
|
|
|
(let [channel (chan)
|
|
|
|
|
|
|
|
id (.-id (.-params req))]
|
|
|
|
|
|
|
|
(go
|
|
|
|
|
|
|
|
(try
|
|
|
|
|
|
|
|
(let [article (<! (db/get-article client id channel))]
|
|
|
|
|
|
|
|
(if (empty? article)
|
|
|
|
|
|
|
|
(do
|
|
|
|
|
|
|
|
(res/status 404)
|
|
|
|
|
|
|
|
(res/send (ex-message "404")))
|
|
|
|
|
|
|
|
(do
|
|
|
|
|
|
|
|
(res/status 200)
|
|
|
|
|
|
|
|
(.render res "article_row"
|
|
|
|
|
|
|
|
(-> {:article article :layout false}
|
|
|
|
|
|
|
|
(cljs.core/clj->js))))))
|
|
|
|
|
|
|
|
(catch js/Error err
|
|
|
|
|
|
|
|
(res/status 500)
|
|
|
|
|
|
|
|
(res/send (ex-message err))))))))
|
|
|
|
|
|
|
|
|
|
|
|