summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/auth.fnl6
-rw-r--r--pages/shop/_product/edit.fnl10
-rw-r--r--pages/shop/_product/index.fnl22
-rw-r--r--pages/shop/add.fnl14
-rw-r--r--pages/shop/index.fnl22
5 files changed, 42 insertions, 32 deletions
diff --git a/pages/auth.fnl b/pages/auth.fnl
index 9cb7a66..c6c1832 100644
--- a/pages/auth.fnl
+++ b/pages/auth.fnl
@@ -1,4 +1,4 @@
-(import-macros {:compile-html <>} :macros)
+(import-macros {:compile-html HTML} :macros)
(local forms (require :forms))
(local lib (require :lib))
(local templates (require :templates))
@@ -11,10 +11,10 @@
(fn content [data errors]
(set data.password nil)
- [(<>
+ [(HTML
[:div {:class "side"}
(templates.header "/auth")])
- (<>
+ (HTML
[:section {:class "content"}
[:div {:class "mb-1"} [:a {:href "/"} "⟵ Обратно на главную"]]
[:h2 {} "Войти"]
diff --git a/pages/shop/_product/edit.fnl b/pages/shop/_product/edit.fnl
index 9465d94..7e7548d 100644
--- a/pages/shop/_product/edit.fnl
+++ b/pages/shop/_product/edit.fnl
@@ -1,4 +1,4 @@
-(import-macros {:compile-html <>} :macros)
+(import-macros {:compile-html HTML} :macros)
(local templates (require :templates))
(local {: product-form} (require :pages.shop.add))
(local forms (require :forms))
@@ -14,6 +14,10 @@
products.title,
products.position,
products.short_description,
+ products.recommendations,
+ products.year,
+ products.season,
+ products.region,
products.stock,
products.type,
products.packaging,
@@ -42,10 +46,10 @@
(error "empty data for insert SQL-statement"))))
(fn content [form data errors authenticated?]
- [(<>
+ [(HTML
[:div {:class "side"}
(templates.header "/shop" authenticated?)])
- (<>
+ (HTML
[:div {:class "content"}
[:div {:class "mb-1"}
[:a {:href (.. "/shop/" data.name)} "⟵ Обратно к товару"]]
diff --git a/pages/shop/_product/index.fnl b/pages/shop/_product/index.fnl
index 722c952..2904b61 100644
--- a/pages/shop/_product/index.fnl
+++ b/pages/shop/_product/index.fnl
@@ -1,4 +1,4 @@
-(import-macros {:compile-html <>} :macros)
+(import-macros {:compile-html HTML} :macros)
(local templates (require :templates))
(local dicts (require :dicts))
(local lib (require :lib))
@@ -41,25 +41,25 @@
(for [i 1 5]
(table.insert images (. product (.. "image" i))))
- [(<>
+ [(HTML
[:div {:class "side"}
(templates.header "/shop" authenticated?)])
- (<>
+ (HTML
[:div {:class "content"}
[:div {:class "mb-1"} [:a {:href "/shop"} "⟵ Обратно к списку"]]
(let [link (.. "/static/files/" product.image1)]
- (<> [:a {:href link :target "_blank"}
- [:img {:class "product-page-img-mobile mb-1-5"
- :src (.. link "-thumbnail.jpg")}]]))
+ (HTML [:a {:href link :target "_blank"}
+ [:img {:class "product-page-img-mobile mb-1-5"
+ :src (.. link "-thumbnail.jpg")}]]))
[:div {:class "product-page-layout"}
[:div {}
[:h2 {:class "product-page-title mb-1"} product.title]
[:section {:class "mb-2"}
(if authenticated?
- (<> [:div {:class "mb-0-5"}
- [:a {:href (.. "/shop/" product.name "/edit")}
- "✎ Редактировать"]])
+ (HTML [:div {:class "mb-0-5"}
+ [:a {:href (.. "/shop/" product.name "/edit")}
+ "✎ Редактировать"]])
"")
[:div {:class "mb-0-5" :style "font-style: italic;"}
(or (dicts.label dicts.tea-type product.type) product.type) ", "
@@ -71,8 +71,8 @@
(table.concat
(icollect [idx image (ipairs images)]
(let [link (.. "/static/files/" image)]
- (<> [:a {:href link :target "_blank"}
- [:img {:class "product-page-img" :src (.. link "-thumbnail.jpg")}]]))))]]])])
+ (HTML [:a {:href link :target "_blank"}
+ [:img {:class "product-page-img" :src (.. link "-thumbnail.jpg")}]]))))]]])])
(fn render [request db authenticated?]
(let [product (find-product db request.params._product)]
diff --git a/pages/shop/add.fnl b/pages/shop/add.fnl
index 8fcfdf1..5b5bfc5 100644
--- a/pages/shop/add.fnl
+++ b/pages/shop/add.fnl
@@ -1,4 +1,4 @@
-(import-macros {:compile-html <>} :macros)
+(import-macros {:compile-html HTML} :macros)
(local templates (require :templates))
(local dicts (require :dicts))
(local forms (require :forms))
@@ -17,8 +17,14 @@
(forms.text-input "title" "Полное название" true 0 200)
(forms.select-input "type" "Вид чая" true dicts.tea-type)
(forms.select-input "packaging" "Упаковка" true dicts.tea-packaging)
+ (forms.number-input "year" "Год изготовления" false 1950
+ (tonumber (os.date "%Y")))
+ (forms.select-input "season" "Сезон изготовления" false dicts.tea-season)
+ (forms.text-input "region" "Место изготовления" false 0 500)
(forms.textarea-input "short_description" "Короткое описание" true 0 1000)
- (forms.textarea-input "description" "Полное описание" true 0 20000)
+ (forms.textarea-input "description" "Полное описание" false 0 20000)
+ (forms.textarea-input "recommendations" "Рекомендации по завариванию"
+ false 0 20000)
(forms.number-input "price_per" "Цена" true 0 100000
"За штуку или грамм.")
(forms.number-input "stock" "Сколько в наличии" true 0 100000
@@ -53,10 +59,10 @@
(error "empty data for insert SQL-statement"))))
(fn content [form data errors authenticated?]
- [(<>
+ [(HTML
[:div {:class "side"}
(templates.header "/shop" authenticated?)])
- (<>
+ (HTML
[:div {:class "content"}
[:div {:class "mb-1"}
[:a {:href "/shop"} "⟵ Обратно к списку"]]
diff --git a/pages/shop/index.fnl b/pages/shop/index.fnl
index 5a96ab2..bbe08fa 100644
--- a/pages/shop/index.fnl
+++ b/pages/shop/index.fnl
@@ -1,4 +1,4 @@
-(import-macros {:compile-html <>} :macros)
+(import-macros {:compile-html HTML} :macros)
(local lib (require :lib))
(local dicts (require :dicts))
(local templates (require :templates))
@@ -42,16 +42,16 @@
;; (if (< 0 product.stock)
;; (each [_ q (ipairs (quantity-steps product.stock 50))]
;; (table.insert quantity-options
- ;; (<>
+ ;; (HTML
;; [:option {:value (tostring q)}
;; (.. q " грамм за " (* product.price-per q) "₽")])))
- ;; (table.insert quantity-options (<> [:option {:value "0"} "Товар закончился"])))
+ ;; (table.insert quantity-options (HTML [:option {:value "0"} "Товар закончился"])))
(local images [])
(for [i 2 5]
(table.insert images (. product (.. "image" i))))
- (<>
+ (HTML
[:section {:class (.. "shop-item"
(if (not product.published)
" shop-item-not-published" ""))}
@@ -61,7 +61,7 @@
:src (.. "/static/files/" (. product.image1) "-thumbnail.jpg")}]
(table.concat
(icollect [idx image (ipairs images)]
- (<>
+ (HTML
[:img {:class "shop-item-img" :src (.. "/static/files/" image "-thumbnail.jpg")
:loading "lazy"
:style (.. "z-index: " (+ idx 2) ";"
@@ -79,11 +79,11 @@
[:div {} product.short-description]]))
(fn content [db basket basket-total authenticated?]
- [(<>
+ [(HTML
[:div {:class "side"}
(templates.header "/shop" authenticated?)
(if (< 0 (# basket))
- (<>
+ (HTML
[:article {:class "article"}
[:h2 {} "Корзина"]
[:div {}
@@ -94,14 +94,14 @@
[:div {:class "basket-total"} (.. "Итого: " basket-total "₽")]
[:a {:href "/shop/order"} "Оформить заказ"]])
"")])
- (<>
+ (HTML
[:div {:class "content"}
[:div {:class "mb-1"} [:a {:href "/"} "⟵ Обратно на главную"]]
[:h2 {:class "mb-1 product-page-title"}
"Магазин"
(if authenticated?
- (<> [:a {:style "font-size: 1rem; margin-left: 0.75rem;"
- :href (.. "/shop/add")} "+ Добавить"])
+ (HTML [:a {:style "font-size: 1rem; margin-left: 0.75rem;"
+ :href (.. "/shop/add")} "+ Добавить"])
"")]
[:div {:class "shop-items"}
(let [products (all-products db authenticated?)]
@@ -109,7 +109,7 @@
(table.concat
(icollect [_ v (ipairs products)]
(item-template v)))
- (<> [:em {} "Пока что здесь ничего нет!"])))]])])
+ (HTML [:em {} "Пока что здесь ничего нет!"])))]])])
(fn create-order [db]
(let [id (_G.must (luna.crypto.random-string 64))]