summaryrefslogtreecommitdiff
path: root/src/chef/frontend/visitor/home.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/chef/frontend/visitor/home.clj')
-rw-r--r--src/chef/frontend/visitor/home.clj41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/chef/frontend/visitor/home.clj b/src/chef/frontend/visitor/home.clj
new file mode 100644
index 0000000..6503983
--- /dev/null
+++ b/src/chef/frontend/visitor/home.clj
@@ -0,0 +1,41 @@
+(ns chef.frontend.visitor.home
+ (:require [hiccup2.core :as html]
+ [ring.util.response :as ruresp]
+ [chef.utils :as cutils]
+
+ [chef.frontend.visitor.search :as cfvsearch]
+
+ [chef.logic.categories :as clcategories]))
+
+(defn- render [req]
+ (cutils/gen-page "chef"
+ (let [category (clcategories/get-category (or (get-in req [:params "category"]) -1))]
+ [:div {:style {:text-align :center}}
+ [:h1 "chef"]
+ [:h2 "Finde das perfekte Gericht für dich!"]
+ [:b (:categories/question category)]
+ [:div
+ (for [child-category (clcategories/find-categories-with-parent (:categories/id category))]
+ [: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 (clcategories/generate-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"}
+ (cfvsearch/render "" (:categories/id category))]])))
+
+(defn handler [req]
+ (-> req
+ render
+ html/html
+ str
+ ruresp/response))