|
|
@ -1,6 +1,7 @@
|
|
|
|
(ns wanijo.view
|
|
|
|
(ns wanijo.view
|
|
|
|
(:require [hiccup.page :refer [html5
|
|
|
|
(:require [hiccup.page :refer [html5
|
|
|
|
include-css]]))
|
|
|
|
include-css]]
|
|
|
|
|
|
|
|
[clojure.spec.alpha :as spec]))
|
|
|
|
|
|
|
|
|
|
|
|
(defn btnlink
|
|
|
|
(defn btnlink
|
|
|
|
([target caption]
|
|
|
|
([target caption]
|
|
|
@ -34,10 +35,28 @@
|
|
|
|
(str "O, " ident)])]
|
|
|
|
(str "O, " ident)])]
|
|
|
|
(when authed?
|
|
|
|
(when authed?
|
|
|
|
[:section.header-content
|
|
|
|
[:section.header-content
|
|
|
|
(btnlink "/schema" "Jaki Ijo" "header-content__link")
|
|
|
|
(btnlink "/schema" "Jaki ijo" "header-content__link")
|
|
|
|
(btnlink "/logout" "Lape" "header-content__link")])]
|
|
|
|
(btnlink "/logout" "Lape" "header-content__link")])]
|
|
|
|
[:nav (when authed? "nav")]
|
|
|
|
[:nav (when authed? "nav")]
|
|
|
|
(vec (concat [:main] content))
|
|
|
|
(vec (concat [:main] content))
|
|
|
|
[:aside (when authed? "aside")]
|
|
|
|
[:aside (when authed? "aside")]
|
|
|
|
[:footer
|
|
|
|
[:footer
|
|
|
|
[:small "Ilo pali e ijo"]]]])))
|
|
|
|
[:small "Ilo pali e ijo"]]]])))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn flash-error [content]
|
|
|
|
|
|
|
|
[:section.flash--error
|
|
|
|
|
|
|
|
[:h2.flash__heading--error "Pakala"]
|
|
|
|
|
|
|
|
content])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn spec-to-errmsg [spec-key req]
|
|
|
|
|
|
|
|
(when-let [spec-data (and (not-empty (:params req))
|
|
|
|
|
|
|
|
(spec/explain-data spec-key (:params req)))]
|
|
|
|
|
|
|
|
(flash-error
|
|
|
|
|
|
|
|
(->> (:clojure.spec.alpha/problems spec-data)
|
|
|
|
|
|
|
|
(map
|
|
|
|
|
|
|
|
(fn [prob]
|
|
|
|
|
|
|
|
[:p
|
|
|
|
|
|
|
|
"Field \""
|
|
|
|
|
|
|
|
[:span.flash__field (first (:path prob))]
|
|
|
|
|
|
|
|
"\" must comply to "
|
|
|
|
|
|
|
|
[:span.flash__pred (:pred prob)]]))))))
|
|
|
|