summaryrefslogtreecommitdiff
path: root/templates.fnl
blob: 07680f8966802dec9631c448580c923ac4a6bcbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(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 "https://whitetoad.ru/static/favicon.svg"
             :type "image/svg+xml"}]]
    [:body {}
     [:main {:class "container"} (table.concat content)]]]))

(fn header [current-path authenticated?]
  (local logo
    (HTML
     [:img {:src "/static/logo.svg"
            :alt "Белая жаба в мультяшном стиле с чайником на голове"}]))

  (HTML
   [:article {:class "article"}
    [:div {:class "logo"}
      (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 "Чайная<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]
  (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}