(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))