From b3fd9c6aad5828fae482794f3719c40a3dceb72e Mon Sep 17 00:00:00 2001 From: unwox Date: Tue, 16 Sep 2025 17:21:51 +0600 Subject: small improvements --- dicts.fnl | 8 ++++---- pages/auth.fnl | 40 ++++++++++++++++++++-------------------- static/style.css | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/dicts.fnl b/dicts.fnl index b884b45..d0465b0 100644 --- a/dicts.fnl +++ b/dicts.fnl @@ -1,12 +1,12 @@ (local product-type - [{:value "white" :label "Белый"} + [{:value "white" :label "Белый чай"} {:value "dark-oolong" :label "Темный улун"} {:value "light-oolong" :label "Светлый улун"} - {:value "red" :label "Красный"} - {:value "green" :label "Зеленый"} + {:value "red" :label "Красный чай"} + {:value "green" :label "Зеленый чай"} {:value "shu-puerh" :label "Шу пуэр"} {:value "sheng-puerh" :label "Шэн пуэр"} - {:value "yellow" :label "Желтый"} + {:value "yellow" :label "Желтый чай"} {:value "liu-bao" :label "Лю бао"} {:value "teapot" :label "Чайник"}]) diff --git a/pages/auth.fnl b/pages/auth.fnl index c6c1832..3afb517 100644 --- a/pages/auth.fnl +++ b/pages/auth.fnl @@ -3,22 +3,23 @@ (local lib (require :lib)) (local templates (require :templates)) -(local auth-form [ - {:title "" - :fields [ - (forms.text-input "name" "Пользователь" true) - (forms.password-input "password" "Пароль" true)]}]) +(local auth-form + [{:title "" + :fields [ + (forms.text-input "name" "Пользователь" true) + (forms.password-input "password" "Пароль" true)]}]) (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 {} "Войти"] - (forms.render-form auth-form data errors)])]) + (set data.password nil) + + [(HTML + [:div {:class "side"} + (templates.header "/auth")]) + (HTML + [:section {:class "content"} + [:div {:class "mb-1"} [:a {:href "/"} "⟵ Обратно на главную"]] + [:h2 {} "Войти"] + (forms.render-form auth-form data errors)])]) (fn create-session [db user expires-at] (local id (_G.must (luna.crypto.random-string 64))) @@ -27,7 +28,6 @@ db "INSERT INTO auth_sessions (id, user, creation_time, expires_at) VALUES (?, ?, ?, ?)" [id user (lib.now) expires-at])) - id) (fn check-user [db name entered-pass] @@ -50,10 +50,7 @@ (if request.form (let [name request.form.name entered-password request.form.password - correct-creds? (check-user db name entered-password) - errors (if (not correct-creds?) - {:password "Пользователя с таким именем и паролем не существует."} - nil)] + correct-creds? (check-user db name entered-password)] (if correct-creds? (let [next-week (+ (os.time) (* 60 60 24 7)) session-id (create-session @@ -63,7 +60,10 @@ :Set-Cookie (.. "auth= " session-id "; HttpOnly; SameSite=strict;" "Expires=" cookie-expires (if luna.debug? "" "; Secure"))} "")) - (values 200 {} (templates.base (content request.form errors))))) + (values 400 {} + (templates.base + (content request.form + {:password "Пользователя с таким именем и паролем не существует."}))))) (values 200 {} (templates.base (content {} {})))))) {: render} diff --git a/static/style.css b/static/style.css index ccdd08d..a152c1b 100644 --- a/static/style.css +++ b/static/style.css @@ -171,7 +171,7 @@ nav a.active { } .logo::before { - animation: infinite logo-rotation 120s; + animation: infinite linear logo-rotation 120s; background-image: url("/static/logo-bg.png"); background-repeat: no-repeat; background-size: cover; -- cgit v1.2.3