diff --git a/src/main/blog/handlers.cljs b/src/main/blog/handlers.cljs index 6a0a00c..7eef0c1 100644 --- a/src/main/blog/handlers.cljs +++ b/src/main/blog/handlers.cljs @@ -19,6 +19,22 @@ (res/status 500) (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 ( {:articles articles} + (cljs.core/clj->js)))) + (catch js/Error err + (res/status 500) + (res/send (ex-message err)))))))) + (defn htmx-get-article-handler-factory [client] (fn [req res] @@ -40,3 +56,45 @@ (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 ( {: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 ( {:article article :layout false} + (cljs.core/clj->js)))))) + (catch js/Error err + (res/status 500) + (res/send (ex-message err)))))))) + diff --git a/src/main/blog/server.cljs b/src/main/blog/server.cljs index 01c04bf..5cc0143 100644 --- a/src/main/blog/server.cljs +++ b/src/main/blog/server.cljs @@ -32,8 +32,14 @@ (handlers/index-page-handler-factory client)) (fn [req res] + (. app get "/admin" + (handlers/admin-panel-handler-factory client)) + (. app get "/htmx/articles/:id" (handlers/htmx-get-article-handler-factory client)) + + (. app get "/htmx/admin/rows/article/:id/" + (handlers/htmx-get-article-row-handler-factory client)) ) (defn start