summaryrefslogtreecommitdiff
path: root/templates.fnl
diff options
context:
space:
mode:
Diffstat (limited to 'templates.fnl')
-rw-r--r--templates.fnl83
1 files changed, 64 insertions, 19 deletions
diff --git a/templates.fnl b/templates.fnl
index f19c2b0..f4ff5cc 100644
--- a/templates.fnl
+++ b/templates.fnl
@@ -1,24 +1,69 @@
+(import-macros {:compile-html <>} :macros)
+(local lib (require :lib))
+
(fn read-file [file]
(with-open [f (io.open file "r")]
(f:read :*all)))
-(fn base-template [content]
- [:html {:lang "ru-RU"}
- [:head {}
- [:title {} "Чайная «Белая жаба» — маленькая уютная чайная в Омске"]
- [:meta {:charset "utf-8"}]
- [:meta {:name "viewport"
- :content (.. "width=device-width,initial-scale=1,"
- "minimum-scale=1.0,maximum-scale=5.0")}]
- [:meta {:name "description"
- :content (.. "Маленькая уютная чайная для своих: "
- "Омск, ул. Пушкина, д. 133/9, этаж 2. "
- "Посещение по предварительной договоренности, "
- "стоимость 500 рублей с человека.")}]
- [:style {} [:NO-ESCAPE (read-file "static/style.css")]]
- [:link {:rel "icon" :href "https://whitetoad.ru/static/favicon.svg"
- :type "image/svg+xml"}]]
- [:body {}
- [:main {:class "container"} (table.unpack content)]]])
+(fn base [content]
+ (<>
+ [:html {:lang "ru-RU"}
+ [:head {}
+ [:title {} "«Белая жаба» — маленькая уютная чайная в Омске"]
+ [:meta {:charset "utf-8"}]
+ [:meta {:name "viewport"
+ :content (.. "width=device-width,initial-scale=1,"
+ "minimum-scale=1.0,maximum-scale=5.0")}]
+ [:meta {:name "description"
+ :content (.. "Маленькая уютная чайная: "
+ "Омск, ул. Пушкина, д. 133/9, этаж 2. "
+ "Посещение по предварительной договоренности, "
+ "стоимость 500 рублей с человека.")}]
+ [:style {} [:NO-ESCAPE (read-file "static/style.css")]]
+ [:link {:rel "icon" :href "https://whitetoad.ru/static/favicon.svg"
+ :type "image/svg+xml"}]]
+ [:body {}
+ [:main {:class "container"} (table.concat content)]]]))
+
+(fn header [current-path authenticated?]
+ (local logo
+ (<>
+ [:img {:src "/static/logo.svg"
+ :alt "Белая жаба в мультяшном стиле с чайником на голове"}]))
+
+ (<>
+ [:article {:class "article"}
+ [:div {:class "logo"}
+ (if authenticated?
+ (<> [:img {:class "logo-glasses" :src "/static/glasses.png"
+ :alt "Солнцезащитные очки"}])
+ "")
+ (if (~= current-path "")
+ (<> [:a {:href "/" :class "d-inline-block"} logo])
+ logo)
+ [:h1 {} [:NO-ESCAPE "Чайная<br>«Белая&nbsp;жаба»"]]]
+ [:nav {}
+ [:a {:href "/shop" :class (if (lib.starts-with? current-path "/shop") "active" "")}
+ "магазин"]
+ [:span {} "~"]
+ [:a {:href "https://t.me/whitetoadtea"} "телеграм"]
+ [:span {} "~"]
+ [:a {:href "https://vk.com/whitetoadtea"} "вконтакте"]]]))
+
+(fn basket-item [item redirect-url]
+ (<>
+ [:div {:class "basket-item"}
+ [:div {:class "basket-item-image"}
+ [:img {:src (.. "/static/files/" (. item :images 1)) :alt item.title}]]
+ [:div {}
+ [:strong {:class "basket-item-title"} item.title]
+ [:div {:class "basket-item-price"}
+ (.. item.quantity " грамм за "
+ (* item.price-per item.quantity) "₽")
+ [:form {:class "basket-item-remove" :method "POST"
+ :action "/shop/cart/remove"}
+ [:input {:type "hidden" :name "redirect-url" :value redirect-url}]
+ [:input {:type "hidden" :name "id" :value (tostring item.id)}]
+ [:button {:type "submit"} "⨯ убрать из корзины"]]]]]))
-{: base-template}
+{: base : header : basket-item}