summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/serve.fnl34
1 files changed, 22 insertions, 12 deletions
diff --git a/bin/serve.fnl b/bin/serve.fnl
index c8fc6f2..7a24799 100644
--- a/bin/serve.fnl
+++ b/bin/serve.fnl
@@ -361,7 +361,7 @@
[:button {:type :submit} "Искать"]]
paginator]])
-(fn base-template [form path page total items]
+(fn base-template [form path page total items text]
(local paginator (paginator-template form page 48 total))
(local menu-path
(if (and form.tags (< 0 (# form.tags)))
@@ -401,15 +401,18 @@
[:div {:class "description-text text"}
[:NO-ESCAPE (. texts (.. menu-path "-description"))]]
"")]
- (if (< 0 (# items))
- [:div {:class "list"}
- (table.unpack (map #(item-template $2) items))]
- (if spellfix-suggestion
- [:NO-ESCAPE
- (string.format texts.no-results-with-suggestion
- spellfix-suggestion
- spellfix-suggestion)]
- [:NO-ESCAPE texts.no-results]))
+ (if text
+ [:p {:class "text"} text]
+ (< 0 (# items))
+ [:div {:class "list"}
+ (table.unpack (map #(item-template $2) items))]
+ [:p {:class "text"}
+ (if spellfix-suggestion
+ [:NO-ESCAPE
+ (string.format texts.no-results-with-suggestion
+ spellfix-suggestion
+ spellfix-suggestion)]
+ [:NO-ESCAPE texts.no-results])])
[:div {} paginator]
[:footer {}
[:p {:class "text"} [:NO-ESCAPE texts.footer-text]]]]]]]])
@@ -445,8 +448,15 @@
["white-tea"] (respond query "Белый чай")
["yellow-tea"] (respond query "Желтый чай")
["teaware"] (respond query "Посуда")
- [] (respond query)
- _ (values 404 {} "not found")))))
+ (where t (= 0 (# t))) (respond query)
+ _ (values
+ 404 {:content-type "text/html"}
+ (.. "<!DOCTYPE html>\n"
+ (html.render
+ (base-template
+ (collect-form query nil)
+ "" 1 0 [] "Страница не найдена!")
+ true)))))))
(fn robots-handler []
(values 200 {:content-type "text/plain"} "User-agent: *\nAllow: /"))