diff options
author | Tim <contact@bytim.eu> | 2025-05-11 12:12:50 +0200 |
---|---|---|
committer | Tim <contact@bytim.eu> | 2025-05-11 12:12:50 +0200 |
commit | 06ecbc8c6d52f3e832683e68a52461c5f7c6cb84 (patch) | |
tree | 25f4a4f6881549ca1d6fdd1da0a4b8ff2965e9e0 /src/chef | |
parent | 77594fd2b62e4ea3e6a55fed2dabcce50e618bd3 (diff) | |
download | chef-06ecbc8c6d52f3e832683e68a52461c5f7c6cb84.tar.xz chef-06ecbc8c6d52f3e832683e68a52461c5f7c6cb84.zip |
Add basic home page; TODO: use real data for home page
Diffstat (limited to 'src/chef')
-rw-r--r-- | src/chef/components/search.clj | 14 | ||||
-rw-r--r-- | src/chef/pages/home.clj | 28 | ||||
-rw-r--r-- | src/chef/routes.clj | 9 | ||||
-rw-r--r-- | src/chef/utils.clj | 4 |
4 files changed, 49 insertions, 6 deletions
diff --git a/src/chef/components/search.clj b/src/chef/components/search.clj new file mode 100644 index 0000000..843f907 --- /dev/null +++ b/src/chef/components/search.clj @@ -0,0 +1,14 @@ +(ns chef.components.search + (:require [hiccup2.core :as html] + [ring.util.response :as ruresp])) + +(defn render [query] + [:p "Results; Query: " query]) + +(defn handler [req] + (if-let [query (get-in req [:params "query"])] + (-> (render query) + html/html + str + ruresp/response) + (ruresp/bad-request "No search query provide."))) diff --git a/src/chef/pages/home.clj b/src/chef/pages/home.clj index 84f643f..210fbed 100644 --- a/src/chef/pages/home.clj +++ b/src/chef/pages/home.clj @@ -1,12 +1,34 @@ (ns chef.pages.home (:require [hiccup2.core :as html] [ring.util.response :as ruresp] - [chef.utils :as cutils] - [ring.middleware.session :as rmsession])) + [chef.utils :as cutils])) + +(defn render [] + (cutils/gen-page "chef" + [:div {:style {:text-align :center}} + [:h1 "chef"] + [:h2 "Finde das perfekte Gericht für dich!"] + [:b "Welchen Gang suchst du?"] + ;; TODO: Dummy data; replace with data from db + [:div + [:button {:style {:margin-bottom "1em"}} "Vorspeise"] + [:br] + [:button {:style {:margin-bottom "1em"}} "Hauptgang"] + [:br] + [:button {:style {:margin-bottom "1em"}} "Nachtisch"] + [:br]] + [:input {:type :text + :style {:width "90%" :margin :auto} + :placeholder "Suche" + :hx-get "/components/search" + :name "query" + :hx-swap "innerHTML" + :hx-target "#search-results"}] + [:div {:id "search-results"}]])) (defn handler [req] (let [access-token (get-in req [:oauth2/access-tokens :auth]) - resp (-> (cutils/gen-page "chef" [:i "Coming soon..."]) + resp (-> (render) html/html str ruresp/response)] diff --git a/src/chef/routes.clj b/src/chef/routes.clj index c2fd6c7..27d6dfd 100644 --- a/src/chef/routes.clj +++ b/src/chef/routes.clj @@ -7,11 +7,16 @@ [clojure.string :as cstr] [chef.pages.home :as cphome] - [chef.pages.admin :as cpadmin])) + [chef.pages.admin :as cpadmin] + + [chef.components.search :as ccsearch])) (def router [["/" {:get {:handler cphome/handler}}] ["/admin/" {:get {:handler cpadmin/handler}}] - ["/static/*" (rring/create-resource-handler)]]) + ["/static/*" (rring/create-resource-handler)] + + ["/components" + ["/search" {:get {:handler ccsearch/handler}}]]]) (def ring-handler (delay (-> router rring/router diff --git a/src/chef/utils.clj b/src/chef/utils.clj index a721617..3170be9 100644 --- a/src/chef/utils.clj +++ b/src/chef/utils.clj @@ -5,7 +5,9 @@ [:html [:head [:meta {:name "viewport" :content "width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"}] - [:title title]] + [:title title] + [:link {:rel :stylesheet :href "/static/style.css"}] + [:meta {:http-equiv "content-type" :content "text/html; charset=utf-8"}]] (apply conj [:body] content [[:script {:src "/static/htmx.js"}]])]) (defmacro auth-only [request & body] |