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]]
[buddy/buddy-hashers "1.3.0"
: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"]
[ring/ring-mock "0.3.2"]]

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

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

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

Loading…
Cancel
Save