You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.5 KiB
91 lines
2.5 KiB
(ns wanijo.infra.view
|
|
(:require [hiccup
|
|
[page :refer [html5 include-js include-css]]
|
|
[core :refer [h]]]
|
|
[wanijo.infra.routing :refer [path]]))
|
|
|
|
(defn btnlink
|
|
([target caption]
|
|
(btnlink target caption ""))
|
|
([target caption clss]
|
|
[:a {:href target}
|
|
[:button {:class clss}
|
|
caption]]))
|
|
|
|
(defn delete-btn []
|
|
[:input {:type "submit"
|
|
:class "delete-btn"
|
|
:value "☒ Delete!"}])
|
|
|
|
(defn flash-error [content]
|
|
[:section.flash--error
|
|
[:h2.flash__heading--error "Warning"]
|
|
content])
|
|
|
|
(defn layout
|
|
[& {:keys [content
|
|
title
|
|
session
|
|
request
|
|
head]
|
|
:or {content []
|
|
title nil
|
|
request {}
|
|
session nil
|
|
head nil}}]
|
|
(let [session (or session (:session request))
|
|
ident (:ident session)
|
|
authed? (some? ident)]
|
|
(html5
|
|
[:head
|
|
[:meta {:charset "utf-8"}]
|
|
[:meta {:name "viewport"
|
|
:content "width=device-width,initial-scale=1,shrink-to-fit=no"}]
|
|
[:title (h (str (when title (str title " - ")) "wanijo"))]
|
|
(include-css "/css/app.css")
|
|
(include-js "/js/scripts.js")
|
|
head]
|
|
[:body
|
|
[:section.grid
|
|
[:header
|
|
[:h1.app-title "wan ijo"
|
|
(when authed?
|
|
[:small.app-title__hello
|
|
"Hi, "
|
|
[:a {:href (path :user-profile)}
|
|
(h ident)]])]
|
|
(when authed?
|
|
[:section.header-content
|
|
(btnlink (path :schema-overview)
|
|
"Schemas"
|
|
"header-content__link")
|
|
(btnlink (path :auth-logout)
|
|
"Logout!"
|
|
"header-content__link")])]
|
|
[:nav
|
|
(when authed?
|
|
(list
|
|
[:section.schemas
|
|
[:h2 "Schemas"]
|
|
[:ul
|
|
(for [schema (:schemas session)]
|
|
[:li [:a {:href (path :instance-list
|
|
{:schema-uuid (:uuid schema)})}
|
|
(h (:name schema))]])]]
|
|
[:secion
|
|
[:h2 "Prefiltered"]
|
|
[:ul
|
|
[:li [:a {:href (path :instance-list-starred)}
|
|
"Starred"]]]]
|
|
[:section
|
|
[:h2 "Visualisation"]
|
|
[:ul
|
|
[:li [:a {:href (path :vis-all-instances)}
|
|
"All Instances"]]]]))]
|
|
(into [:main
|
|
(for [msg (:flash request)]
|
|
(flash-error msg))]
|
|
content)
|
|
[:footer
|
|
[:small "Ilo pali e ijo"]]]])))
|