summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chef/pages/recipe.clj29
-rw-r--r--src/chef/routes.clj1
-rw-r--r--src/chef/utils.clj3
3 files changed, 21 insertions, 12 deletions
diff --git a/src/chef/pages/recipe.clj b/src/chef/pages/recipe.clj
index 84f999c..be88b2d 100644
--- a/src/chef/pages/recipe.clj
+++ b/src/chef/pages/recipe.clj
@@ -8,7 +8,7 @@
[ring.util.response :as ruresp])
(:import java.io.File))
-(defn- render [recipe]
+(defn- render [portions recipe]
(cutils/gen-page (str "chef - " (:recipes/title recipe))
[:div {:style {:margin-left "1em"}}
[:div
@@ -22,20 +22,27 @@
(jdbc/execute! @cdb/db)
first)) ")")]]
(when (some? (cutils/get-thumbnail-file recipe))
- [:img {:src (str "/recipes/" (:recipes/id recipe) "/thumbnail")
+ [:img {:src (str "/recipes/" (:recipes/id recipe) "/thumbnail")
:width "50%"}])
- [:h2 (str "Zutaten"
- (condp = (:recipes/unit recipe)
- 0 " pro Portion"
- 1 " pro Person"
- "")
- ":")]
+ [:h2
+ "Zutaten pro "
+ [:input {:type :number
+ :value portions
+ :style {:width "3em"
+ :display :inline-block}
+ "_" "on change go to url `?portions=${value of me}`"}]
+ (condp = (:recipes/unit recipe)
+ 0 " Portion(en)"
+ 1 " Person(en)"
+ "")
+ ":"]
[:ul (for [ingredient (-> recipe
:recipes/ingredients
cutils/parse-ingredients)]
[:li
[:b (:description ingredient)] ": "
- (:amount ingredient) (:unit ingredient)])]
+ (* (:amount ingredient) portions)
+ (:unit ingredient)])]
[:h2 "Zubereitung"]
(->> (:recipes/preparation recipe)
cstr/split-lines
@@ -50,7 +57,9 @@
sql/format
(jdbc/execute! @cdb/db)
first
- render
+ (render (or (try (Integer/parseInt (get-in req [:params "portions"]))
+ (catch Exception _ nil))
+ 1))
html/html
str
ruresp/response))
diff --git a/src/chef/routes.clj b/src/chef/routes.clj
index d21cb0d..084c7d7 100644
--- a/src/chef/routes.clj
+++ b/src/chef/routes.clj
@@ -4,7 +4,6 @@
[ring.middleware.params :as rmparams]
[ring.middleware.multipart-params :as rmmultiparams]
[ring.middleware.session :as rmsession]
- [ring.middleware.reload :as rmreload]
[dotenv :as env]
[clojure.string :as cstr]
diff --git a/src/chef/utils.clj b/src/chef/utils.clj
index e2725ce..22797cb 100644
--- a/src/chef/utils.clj
+++ b/src/chef/utils.clj
@@ -14,7 +14,8 @@
[:link {:rel :stylesheet :href "/static/style.css"}]
[:meta {:http-equiv "content-type" :content "text/html; charset=utf-8"}]
[:meta {:name "robots" :content "noindex,nofollow"}]]
- (apply conj [:body] content [[:script {:src "/static/htmx.js"}]])])
+ (apply conj [:body] content [[:script {:src "/static/htmx.js"}]
+ [:script {:src "/static/hyperscript.js"}]])])
(defmacro auth-only [request & body]
`(if (some? (get-in ~request [:session :oauth-token]))