(import-macros {:compile-html HTML} :macros)
(local lib (require :lib))
(fn read-file [file]
(with-open [f (io.open file "r")]
(f:read :*all)))
(fn base [content]
(HTML
[: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 "/static/favicon.svg"
:type "image/svg+xml"}]]
[:body {}
[:main {:class "container"} (table.concat content)]]]))
(fn header [current-path authenticated?]
(local logo
(HTML
[:img {:class "logo-img" :src "/static/logo.svg"
:alt "Белая жаба в мультяшном стиле с чайником на голове"}]))
(HTML
[:article {:class "article"}
[:div {:class "logo"}
(HTML [:img {:class "logo-bg" :src "/static/logo-bg.png"
:alt "Солнце за логотипом, фон"}])
(if authenticated?
(HTML [:img {:class "logo-glasses" :src "/static/glasses.png"
:alt "Солнцезащитные очки"}])
"")
(if (~= current-path "")
(HTML [:a {:href "/" :class "d-inline-block"} logo])
logo)
[:h1 {} [:NO-ESCAPE "Чайная
«Белая жаба»"]]]
[: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]
(HTML
[: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 : header : basket-item}