some easing on parameters, rendering of markdown

integration-tests
Josha von Gizycki 6 years ago
parent 705b13803b
commit ac448b8e2f

@ -16,7 +16,9 @@
com.github.ben-manes.caffeine/caffeine]] com.github.ben-manes.caffeine/caffeine]]
[buddy/buddy-hashers "1.3.0" [buddy/buddy-hashers "1.3.0"
:exclusions [commons-codec]] :exclusions [commons-codec]]
[clj-time "0.15.1"]]
[clj-time "0.15.1"]
[markdown-clj "1.0.5"]]
:profiles {:dev {:dependencies [[javax.servlet/servlet-api "2.5"] :profiles {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring/ring-mock "0.3.2"]] [ring/ring-mock "0.3.2"]]

@ -23,18 +23,18 @@
(defn login! [req] (defn login! [req]
(view/layout! (view/layout!
:content :content
[[:h1 "Kama ken"] [[:h1 "Login"]
(hform/form-to (hform/form-to
[:post (path :auth-login-check)] [:post (path :auth-login-check)]
(when (:flash req) [:section.flash (:flash req)]) (when (:flash req) [:section.flash (:flash req)])
;; ;;
(hform/label "uname" "Nimi") (hform/label "uname" "Name")
(hform/text-field {:required "required"} "uname") (hform/text-field {:required "required"} "uname")
;; ;;
(hform/label "pw" "Toki Pimeja") (hform/label "pw" "Password")
(hform/password-field {:required "required"} "pw") (hform/password-field {:required "required"} "pw")
;; ;;
(hform/submit-button "Kama") (hform/submit-button "Login")
(anti-forgery-field))])) (anti-forgery-field))]))
(defroutes routes (defroutes routes

@ -44,9 +44,7 @@
(domain/find-properties! uuid))) (domain/find-properties! uuid)))
(defn show! [uuid req] (defn show! [uuid req]
(view/show! (instance! uuid) (view/show! (instance! uuid) req))
(domain-attr/find-by-instance! uuid)
req))
(defn edit-form! [uuid req] (defn edit-form! [uuid req]
(let [instance (instance! uuid) (let [instance (instance! uuid)

@ -3,11 +3,13 @@
[form :as hform] [form :as hform]
[core :refer [h]]] [core :refer [h]]]
[ring.util.anti-forgery :refer [anti-forgery-field]] [ring.util.anti-forgery :refer [anti-forgery-field]]
[markdown.core :as md]
[formulare.core :as form] [formulare.core :as form]
[wanijo.instance.domain :as domain] [wanijo.instance.domain :as domain]
[wanijo.framework.view :as view] [wanijo.framework
[wanijo.framework.routing :refer [path]] [view :as view]
[wanijo.framework.time :refer [prettify-dt]])) [routing :refer [path]]
[time :refer [prettify-dt]]]))
(defn list! [schema instances new-form req] (defn list! [schema instances new-form req]
(view/layout! (view/layout!
@ -36,7 +38,7 @@
(:uuid schema)) (:uuid schema))
(hform/submit-button "Create!"))])) (hform/submit-button "Create!"))]))
(defn show! [instance attrs req] (defn show! [instance req]
(view/layout! (view/layout!
:request req :request req
:content :content
@ -47,12 +49,18 @@
[:p [:p
[:small [:a {:href (path :instance-edit-form instance)} [:small [:a {:href (path :instance-edit-form instance)}
"Edit Instance"]]] "Edit Instance"]]]
(for [attr attrs [:h2 "Properties"]
:let [auuid (:uuid attr) (for [prop (:properties instance)
prop (first (filter #(= auuid (-> % :attribute :uuid)) :let [attr (:attribute prop)
(:properties instance)))]] type (:type attr)
(list [:em (h (:name attr))] render-fn (case type
[:p (h (:value prop))]))])) "date" #(str (prettify-dt %))
"markdown" md/md-to-html-string
:else #(str "<p>" % "</p>"))]]
(list [:h3 (h (:name attr))]
[:div {:class (str "instance-content "
"attr-type-" type)}
(render-fn (:value prop))]))]))
(defn edit! [instance form form-data req] (defn edit! [instance form form-data req]
(view/layout! (view/layout!

Loading…
Cancel
Save