diff --git a/src/main/blog/handlers.cljs b/src/main/blog/handlers.cljs index 91ff33e..8559c6a 100644 --- a/src/main/blog/handlers.cljs +++ b/src/main/blog/handlers.cljs @@ -26,10 +26,12 @@ [client] (fn [req res] (let [channel (chan) - id (.-id (.-params req))] + search (.-search (.-query req))] (go (try - (let [articles ( {:articles articles @@ -133,6 +135,23 @@ (res/status 500) (res/send (ex-message err)))))))) +(defn htmx-admin-search-articles-handler-factory + [client] + (fn [req res] + (let [channel (chan) + search (.-search (.-body req))] + (go + (try + (let [articles ( {:articles articles + :layout false} + (cljs.core/clj->js)))) + (catch js/Error err + (res/status 500) + (res/send (ex-message err)))))))) + (defn htmx-create-article-handler-factory [client] (fn [req res] diff --git a/src/main/blog/server.cljs b/src/main/blog/server.cljs index 37db67f..0c8592d 100644 --- a/src/main/blog/server.cljs +++ b/src/main/blog/server.cljs @@ -79,6 +79,9 @@ (. app get "/htmx/articles/:id" (handlers/htmx-get-article-handler-factory client)) + (. app post "/htmx/admin/search/articles/" + (handlers/htmx-admin-search-articles-handler-factory client)) + (. app get "/htmx/admin/rows/article/:id/" (handlers/htmx-get-article-row-handler-factory client)) diff --git a/views/admin_panel.hbs b/views/admin_panel.hbs index 70467c5..78bdf52 100644 --- a/views/admin_panel.hbs +++ b/views/admin_panel.hbs @@ -1,4 +1,4 @@ -
+
@@ -17,17 +17,24 @@
-
- +
- +
- +
+ +{{> search_articles_update_param_script }} + diff --git a/views/partials/article_rows.hbs b/views/partials/article_rows.hbs new file mode 100644 index 0000000..4348691 --- /dev/null +++ b/views/partials/article_rows.hbs @@ -0,0 +1,5 @@ + + {{#each articles as |article| }} + {{> article_row article=article }} + {{/each}} +