parent
a6f084d0b8
commit
d90a5bede2
@ -1,22 +0,0 @@
|
||||
(ns wanijo.auth.view
|
||||
(:require [hiccup.form :as hf]
|
||||
[wanijo.view :refer [layout]]
|
||||
[ring.util.anti-forgery :refer [anti-forgery-field]]))
|
||||
|
||||
(defn login [req]
|
||||
(layout
|
||||
:authed? false
|
||||
:content
|
||||
[[:h1 "Kama ken"]
|
||||
(hf/form-to
|
||||
[:post "/login-check"]
|
||||
(when (:flash req) [:section.flash (:flash req)])
|
||||
;;
|
||||
(hf/label "uname" "Nimi")
|
||||
(hf/text-field {:required "required"} "uname")
|
||||
;;
|
||||
(hf/label "pw" "Toki Pimeja")
|
||||
(hf/password-field {:required "required"} "pw")
|
||||
;;
|
||||
(hf/submit-button "Kama")
|
||||
(anti-forgery-field))]))
|
@ -0,0 +1,14 @@
|
||||
(ns wanijo.domain.schema
|
||||
(:require [clojurewerkz.neocons.rest.cypher :as cypher]
|
||||
[wanijo.neo4j :as neo4j]))
|
||||
|
||||
(defn all-created-by! [ident]
|
||||
(->>
|
||||
(cypher/tquery
|
||||
neo4j/conn
|
||||
"MATCH (s:schema)-[created_by]->(u:user)
|
||||
WHERE u.ident = {ident}
|
||||
RETURN s
|
||||
ORDER BY s.created_at"
|
||||
{:ident ident})
|
||||
(map #(:data (get "s")))))
|
@ -0,0 +1,6 @@
|
||||
(ns wanijo.home.routes
|
||||
(:require [compojure.core :refer [defroutes GET]]
|
||||
[wanijo.home.view :as home-view]))
|
||||
|
||||
(defroutes home-routes
|
||||
(GET "/" [] home-view/root!))
|
@ -0,0 +1,5 @@
|
||||
(ns wanijo.home.view
|
||||
(:require [wanijo.view :as view]))
|
||||
|
||||
(defn root! [req]
|
||||
(view/layout! :session (:session req)))
|
@ -1,12 +1,15 @@
|
||||
(ns wanijo.repl
|
||||
(:require [clojurewerkz.neocons.rest.nodes :as nodes]
|
||||
[clojurewerkz.neocons.rest.labels :as labels]
|
||||
[clojurewerkz.neocons.rest.cypher :as cypher]
|
||||
[buddy.hashers :as hashers]
|
||||
[wanijo.neo4j :as neo4j]))
|
||||
|
||||
(defn create-user! [ident pw]
|
||||
(let [node (nodes/create
|
||||
neo4j/conn
|
||||
{:ident ident
|
||||
:pw (hashers/derive pw)})]
|
||||
(labels/add neo4j/conn node "user")))
|
||||
(cypher/tquery
|
||||
neo4j/conn
|
||||
"CREATE (n:user)
|
||||
SET n.ident = {ident}
|
||||
SET n.pw = {pw}"
|
||||
{:ident ident
|
||||
:pw (hashers/derivce pw)}))
|
||||
|
@ -0,0 +1,25 @@
|
||||
(ns wanijo.schema.routes
|
||||
(:require [compojure.core :refer [defroutes GET]]
|
||||
[wanijo.domain.schema :as domain-schemas]
|
||||
[wanijo.view :as view]))
|
||||
|
||||
(defn- overview! [req]
|
||||
(let [session (:session req)
|
||||
ident (:ident session)
|
||||
schemas (domain-schemas/all-created-by! ident)]
|
||||
(view/layout!
|
||||
:session session
|
||||
:content
|
||||
[[:table
|
||||
[:thead
|
||||
[:tr
|
||||
[:th "Nimi"]
|
||||
[:th "Tenpo kama"]]]
|
||||
[:tbody
|
||||
(for [schema schemas]
|
||||
[:tr
|
||||
[:td (:name schema)]
|
||||
[:td (:created_at schema)]])]]])))
|
||||
|
||||
(defroutes schema-routes
|
||||
(GET "/schema" [] overview!))
|
Loading…
Reference in new issue