diff options
Diffstat (limited to 'src/chef/pages/home.clj')
-rw-r--r-- | src/chef/pages/home.clj | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/chef/pages/home.clj b/src/chef/pages/home.clj deleted file mode 100644 index 9bc82fb..0000000 --- a/src/chef/pages/home.clj +++ /dev/null @@ -1,51 +0,0 @@ -(ns chef.pages.home - (:require [chef.database :as cdb] - [hiccup2.core :as html] - [honey.sql :as sql] - [next.jdbc :as jdbc] - [ring.util.response :as ruresp] - [chef.utils :as cutils] - - [chef.components.search :as ccsearch])) - -(defn- render [req] - (cutils/gen-page "chef" - (let [category (->> {:select [:*] - :from [:categories] - :where [:= :id (or (get-in req [:params "category"]) -1)]} - sql/format - (jdbc/execute! @cdb/db) - first)] - [:div {:style {:text-align :center}} - [:h1 "chef"] - [:h2 "Finde das perfekte Gericht für dich!"] - [:b (:categories/question category)] - [:div - (for [child-category (->> {:select [:*] - :from [:categories] - :where [:= :parent (:categories/id category)]} - sql/format - (jdbc/execute! @cdb/db))] - [:div - [:button {:style {:margin-bottom "1em"} - :onclick (str "window.location = \"/?category=" (:categories/id child-category) "\"")} - (:categories/name child-category)] - [:br]])] - (when (pos? (:categories/id category)) - [:h3 (cutils/category-path category)]) - [:input {:type :text - :style {:width "90%" :margin :auto} - :placeholder "Suche" - :hx-get (str "/components/search?category=" (:categories/id category)) - :name "query" - :hx-swap "innerHTML" - :hx-target "#search-results"}] - [:div {:id "search-results"} - (ccsearch/render "" (:categories/id category))]]))) - -(defn handler [req] - (-> req - render - html/html - str - ruresp/response)) |