summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--forms.fnl8
-rw-r--r--pages/shop/_product/index.fnl18
-rw-r--r--pages/shop/add.fnl10
-rw-r--r--pages/shop/index.fnl19
-rw-r--r--static/style.css1
5 files changed, 36 insertions, 20 deletions
diff --git a/forms.fnl b/forms.fnl
index b4c0795..4e57125 100644
--- a/forms.fnl
+++ b/forms.fnl
@@ -159,7 +159,13 @@
:value-from-html
(fn [value {: data : db}]
(if (= (type value) "table")
- (lib.handle-upload db value nil thumbnail-width)
+ (let [lower-name (_G.must (luna.utf8.lower value.name))
+ thumbnail
+ (if (or (lib.ends-with? lower-name ".jpg")
+ (lib.ends-with? lower-name ".png"))
+ thumbnail-width
+ nil)]
+ (lib.handle-upload db value nil thumbnail))
(not (lib.empty? value))
value
(let [previous-value (. data (.. name "_previous"))]
diff --git a/pages/shop/_product/index.fnl b/pages/shop/_product/index.fnl
index 91ec765..4bcf579 100644
--- a/pages/shop/_product/index.fnl
+++ b/pages/shop/_product/index.fnl
@@ -68,7 +68,7 @@
"")
(if (not (lib.empty? product.region)) (.. product.region ", ") "")
(if (= product.packaging "piece")
- (HTML [:strong {} product.price-per "₽ за 1 шт. "])
+ (HTML [:strong {} product.price-per "₽"])
(HTML [:span {}
[:strong {} [:NO-ESCAPE
(* 50 product.price-per)
@@ -88,11 +88,17 @@
(HTML [:div {} [:NO-ESCAPE (text->html product.description)]])
"")]
[:div {:class "product-page-imgs"}
- (table.concat
- (icollect [idx image (ipairs images)]
- (let [link (.. "/static/files/" image)]
- (HTML [:a {:href link :target "_blank"}
- [:img {:class "product-page-img" :src (.. link "-thumbnail.jpg")}]]))))]]])])
+ (table.concat
+ (icollect [idx image (ipairs images)]
+ (let [link (.. "/static/files/" image)
+ video? (lib.ends-with? (_G.must (luna.utf8.lower image)) ".webm")]
+ (HTML
+ [:a {:href link :target "_blank"}
+ (if video?
+ (HTML [:video {:class "product-page-img" :autoplay true :loop true
+ :muted true}
+ [:source {:src (.. "/static/files/" image) :type "video/webm"}]])
+ (HTML [: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 99cfee3..e95ad38 100644
--- a/pages/shop/add.fnl
+++ b/pages/shop/add.fnl
@@ -15,7 +15,7 @@
(.. "Уникальное название чая на латинице, без пробелов, "
"в нижнем регистре."))
(forms.text-input "title" "Полное название" true 0 200)
- (forms.select-input "type" "Вид чая" true dicts.product-type)
+ (forms.select-input "type" "Вид продукта" true dicts.product-type)
(forms.select-input "packaging" "Упаковка" true dicts.tea-packaging)
(forms.number-input "year" "Год изготовления" false 1950
(tonumber (os.date "%Y")))
@@ -33,10 +33,10 @@
{:title "Фото"
:fields [
(forms.file-input "image1" "Первое" true ".jpg" 512)
- (forms.file-input "image2" "Второе" false ".jpg" 512)
- (forms.file-input "image3" "Третье" false ".jpg" 512)
- (forms.file-input "image4" "Четвертое" false ".jpg" 512)
- (forms.file-input "image5" "Пятое" false ".jpg" 512)]}
+ (forms.file-input "image2" "Второе" false ".jpg,.webm" 512)
+ (forms.file-input "image3" "Третье" false ".jpg,.webm" 512)
+ (forms.file-input "image4" "Четвертое" false ".jpg,.webm" 512)
+ (forms.file-input "image5" "Пятое" false ".jpg,.webm" 512)]}
{:title "Данные о поставщике"
:fields [
diff --git a/pages/shop/index.fnl b/pages/shop/index.fnl
index 0b9336e..06642a5 100644
--- a/pages/shop/index.fnl
+++ b/pages/shop/index.fnl
@@ -61,13 +61,18 @@
[:img {:class "shop-item-img"
: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) ";"
- "width: calc(100% / " (# images) ");"
- "left: calc(100% / " (# images) " * " (- idx 1) ")")}])))]]
+ (let [without-videos
+ (icollect [_ v (ipairs images)]
+ (if (lib.ends-with? (_G.must (luna.utf8.lower v)) ".webm")
+ nil
+ v))]
+ (icollect [idx image (ipairs without-videos)]
+ (HTML
+ [:img {:class "shop-item-img" :src (.. "/static/files/" image "-thumbnail.jpg")
+ :loading "lazy"
+ :style (.. "z-index: " (+ idx 2) ";"
+ "width: calc(100% / " (# without-videos) ");"
+ "left: calc(100% / " (# without-videos) " * " (- idx 1) ")")}]))))]]
[:a {:href item-url} [:h3 {:class "shop-item-title"} product.title]]
[:div {:style "font-style: italic; margin-bottom: 0.25rem;"}
(or (dicts.label dicts.product-type product.type) product.type) ", "
diff --git a/static/style.css b/static/style.css
index 0494d87..959f0cd 100644
--- a/static/style.css
+++ b/static/style.css
@@ -570,7 +570,6 @@ p {
.product-page-img-mobile {
display: block;
- margin-top: -1rem;
}
.product-page-imgs > *:first-child {