Add a fairly nice login page

master
Ryan Rix 8 years ago
parent 254cd4788d
commit 2c8d99fd2c

@ -7,6 +7,7 @@
[hiccup "1.0.5"]
[com.datomic/datomic-free "0.9.5201"]
[ring/ring-defaults "0.1.2"]
[com.cemerick/friend "0.2.0-SNAPSHOT"]
[org.clojure/tools.nrepl "0.2.10"]]
:plugins [[lein-ring "0.9.2"]]
:ring {:handler verse.handler/app
@ -21,6 +22,7 @@
cider.nrepl.middleware.macroexpand/wrap-macroexpand
cider.nrepl.middleware.ns/wrap-ns
cider.nrepl.middleware.resource/wrap-resource
cider.nrepl.middleware.debug/wrap-debug
cider.nrepl.middleware.stacktrace/wrap-stacktrace
cider.nrepl.middleware.test/wrap-test
cider.nrepl.middleware.trace/wrap-trace

@ -14,3 +14,9 @@ li div.model {
border: 1px solid #dddddd;
min-height: 200px;
}
.info {
font-style: italic;
font-size: 0.8em;
margin-top: 20px;
}

@ -8,12 +8,33 @@
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
[clojure.tools.nrepl.server :as nrepl-server]
[cider.nrepl :refer (cider-nrepl-handler)]
[verse.web.home]))
[cider.nrepl.middleware.debug :refer [wrap-debug]]
[verse.web.home]
[verse.web.profile]
[verse.models.model]
[verse.models.user]))
(defroutes app-routes
(GET "/" {session :session :as request} (verse.web.home/render session request))
(GET "/" [request]
(verse.web.home/render request))
(context "/profile" []
(GET "/" request
(verse.web.profile/new request))
(GET "/new" request
(verse.web.profile/new request))
(POST "/new" request
(verse.web.profile/post-new request)))
(route/not-found "<b>Not Found</b>"))
(defn wrap-trace [handler]
(fn [req]
(prn "REQ =======================>")
(clojure.pprint/pprint req)
(let [resp (handler req)]
(prn "RESP ======================>")
(clojure.pprint/pprint resp)
resp)))
(def app
(-> (wrap-resource app-routes "public")
wrap-content-type

@ -14,15 +14,18 @@
(defn fetch "Get an object from the datatstore by ID" [id]
(massage (coll/get-object id)))
(defn save "Save an object to the datastore" [model]
(coll/put model))
(defn save "Save an object to the datastore, whitelisting to only keys we care about. If you want to just cram data in to the datastore use `coll/put'" [model]
(coll/put {:db/id (or (:id model)
(d/tempid :db.part/user))
:model/name (:name model)
:model/person (:person model)}))
(defn seed "Seed test models in to the datastore" []
(coll/put {:model/name "The Mother of Dragon Dicks"
:model/person (:db/id (user/get-by-username "dbutts"))})
(coll/put {:model/name "G-Vibe"
:model/person (:db/id (user/get-by-username "rrix"))})
(coll/put {:model/name "Barley Twist Coat Hook"
:model/person (:db/id (user/get-by-username "rrix"))})
(coll/put {:model/name "The Pride of Akron"
:model/person (:db/id (user/get-by-username "dbutts"))}))
(save {:name "The Mother of Dragon Dicks"
:person (user/get-by-username "dbutts")})
(save {:name "G-Vibe"
:person (user/get-by-username "rrix")})
(save {:name "Barley Twist Coat Hook"
:person (user/get-by-username "rrix")})
(save {:name "The Pride of Akron"
:person (user/get-by-username "dbutts")}))

@ -42,368 +42,3 @@
:db/doc "The person who created a model"
:db.install/_attribute :db.part/db}
]
;; [
;; ;;Person
;; {:db/id #db/id[:db.part/db]
;; :db/ident :person/contact-details
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/many
;; :db/doc "An array of different contacts of the given person."
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :person/address
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "Address of the person"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :person/hub-details
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/many
;; :db/doc "Array of hub details for each person."
;; :db.install/_attribute :db.part/db}
;; ;;Address
;; {:db/id #db/id[:db.part/db]
;; :db/ident :address/city
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "City of Residence"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :address/area
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "Area of Residence"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :address/building
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "Building Name"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :address/flat
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "Building Number and Flat Number"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :address/landmark
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "Landmark near the flat"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :address/street
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "Street Address"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :address/incharge
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "A person incharge for the residence"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :address/incharge
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "A person incharge for the residence"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :address/incharge
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "A person incharge for the residence"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :address/thaali-details
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/many
;; :db/doc "A vector of thaali details for each month for each thaali."
;; :db.install/_attribute :db.part/db}
;; ;;education
;; {:db/id #db/id[:db.part/db]
;; :db/ident :edu/start-year
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "First Year of Education"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :edu/end-year
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "Projected last Year of education"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :edu/field-of-study
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "Field of Study"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :edu/degree
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "Degree being Persued"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :edu/college
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "Degree being Persued"
;; :db.install/_attribute :db.part/db}
;; ;; [year, month, single, double, delivered, pick-up, delivered-by, started-on [], stoped-on [], skip - [[1 12/13/2013]]]
;; ;;thaali-details
;; {:db/id #db/id[:db.part/db]
;; :db/ident :thaali/size
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "Size of thaali"
;; :db.install/_attribute :db.part/db}
;; ;; thaali/size enum values
;; [:db/add #db/id[:db.part/user] :db/ident :thaali.size/half]
;; [:db/add #db/id[:db.part/user] :db/ident :thaali.size/full]
;; {:db/id #db/id[:db.part/db]
;; :db/ident :thaali/num
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/unique :db.unique/identity
;; :db/doc "Thaali Number"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :thaali/delivery-mode
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "The mode by which thaali is delivered."
;; :db.install/_attribute :db.part/db}
;; ;; thaali/delivery-mode enum values
;; [:db/add #db/id[:db.part/user] :db/ident :thaali.delivery-mode/pickup]
;; [:db/add #db/id[:db.part/user] :db/ident :thaali.delivery-mode/transported]
;; {:db/id #db/id[:db.part/db]
;; :db/ident :thaali/delivered-by
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "Delivery service provided by."
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :thaali/caterer
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "The caterer providing the thaali."
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :thaali/remarks
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "Any relavent remarks"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :thaali/skip-dates
;; :db/valueType :db.type/boolean
;; :db/cardinality :db.cardinality/many
;; :db/doc "Dates on which it was informed that thaali is not to be prepared."
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :thaali/not-picked-dates
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/many
;; :db/doc "Dates on which thaali was not picked up."
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :thaali/started-on
;; :db/valueType :db.type/boolean
;; :db/cardinality :db.cardinality/one
;; :db/doc "Date thaali was started in the current month"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :thaali/stopped-on
;; :db/valueType :db.type/boolean
;; :db/cardinality :db.cardinality/one
;; :db/doc "Date thaali was stopped in the current month. This is a long term stop. If for a few days, then enter in skip-dates."
;; :db.install/_attribute :db.part/db}
;; ;; Common Elements
;; {:db/id #db/id[:db.part/db]
;; :db/ident :common/tags
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/many
;; :db/doc "Tags that can be attached to a an entity"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :common/roles
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/many
;; :db/doc "Roles that can be assigned to a person."
;; :db.install/_attribute :db.part/db}
;; [:db/add #db/id[:db.part/user] :db/ident :common.roles/admin]
;; [:db/add #db/id[:db.part/user] :db/ident :common.roles/transporter]
;; [:db/add #db/id[:db.part/user] :db/ident :common.roles/khidmatguzar]
;; [:db/add #db/id[:db.part/user] :db/ident :common.roles/caterer]
;; {:db/id #db/id[:db.part/db]
;; :db/ident :common/entity-type
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "Type of Entity"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :common/hijri-year
;; :db/valueType :db.type/long
;; :db/cardinality :db.cardinality/one
;; :db/doc "Hijri Year"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :common/hijri-month
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "Hijri Month"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :common/gregorian-year
;; :db/valueType :db.type/long
;; :db/cardinality :db.cardinality/one
;; :db/doc "Year"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :common/gregorian-month
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "Month"
;; :db.install/_attribute :db.part/db}
;; [:db/add #db/id[:db.part/user] :db/ident :common.entity-type/person]
;; [:db/add #db/id[:db.part/user] :db/ident :common.entity-type/address]
;; [:db/add #db/id[:db.part/user] :db/ident :common.entity-type/vendor]
;; ;; Hub
;; {:db/id #db/id[:db.part/db]
;; :db/ident :hub/pledged
;; :db/valueType :db.type/long
;; :db/cardinality :db.cardinality/one
;; :db/doc "Hub Pledged"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :hub/amount-received
;; :db/valueType :db.type/long
;; :db/cardinality :db.cardinality/many
;; :db/doc "Hub Amount Received"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :hub/received-on
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/many
;; :db/doc "Hub Amount Received On"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :hub/received-by
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/many
;; :db/doc "Hub Amount Received"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :hub/due-date
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/doc "Hub Due Date"
;; :db.install/_attribute :db.part/db}
;; ;; Vendors
;; ;; [:vendor/name :vendor/contacts [ref of persons] :vendor/address]
;; {:db/id #db/id[:db.part/db]
;; :db/ident :vendor/name
;; :db/valueType :db.type/string
;; :db/unique :db.unique/identity
;; :db/cardinality :db.cardinality/one
;; :db/doc "Name of the vendor"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :vendor/contact-persons
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/many
;; :db/doc "Persons that will be associated as contacts for this vendor"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :vendor/address
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "Business address of the vendor"
;; :db.install/_attribute :db.part/db}
;; ;; contacts-details
;; {:db/id #db/id[:db.part/db]
;; :db/ident :contact/type
;; :db/valueType :db.type/ref
;; :db/cardinality :db.cardinality/one
;; :db/doc "Type of the contact"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :contact/mobile
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/unique :db.unique/identity
;; :db/doc "mobile number"
;; :db.install/_attribute :db.part/db}
;; {:db/id #db/id[:db.part/db]
;; :db/ident :contact/email
;; :db/valueType :db.type/string
;; :db/cardinality :db.cardinality/one
;; :db/unique :db.unique/identity
;; :db/doc "email address"
;; :db.install/_attribute :db.part/db}
;; ]

@ -1,7 +1,9 @@
(ns verse.web
(:require [compojure.core :refer :all]
[hiccup.core :as h]
[verse.coll :as coll]
[verse.util :as util]
[compojure.core :refer :all]
[hiccup.core :as h]
[verse.util :as util]))
(defn profile-dropdown [session]
@ -45,5 +47,11 @@
[:div#header (header-template session title quip)]
[:div#content content-form]
[:script {:src "/js/vendor/jquery.js"}]
[:script {:src "/js/vendor/foundation.min.js"}]
[:script {:src "/js/foundation.min.js"}]
[:script "$(document).foundation();"]]]))
(defn about-snippet [session]
(h/html [:div.brand-row [:div.row.space-top
[:div.small-12.columns
[:div#about
[:p "Dongiverse is a 3D model warehouse where artists can connect with people looking for unique art unattainable at other modelling sites. At Dongiverse, your fantasy can become reality, whether you design and print it yourself or allow someone else to help craft your vision in to reality. We bring together some of the most talented 3D mode2llers with a team of skilled 3D printer operators and plastics engineers to craft high quality toys; whether you want to display them as art, or enjoy them in other ways, the Dongiverse will help bring those dreams to fruition."]]]]]))

@ -1,28 +1,21 @@
(ns verse.web.home
(:require [compojure.core :refer :all]
(:require [verse.coll :as coll]
[verse.util :as util]
[hiccup.core :as h]
[verse.web :as web]
[verse.coll :as coll]
[verse.models.model :as model]
[verse.util :as util]))
(defn about-snippet [session]
(h/html [:div#about
[:p "Dongiverse is a 3D model warehouse where artists can connect with people looking for unique art unattainable at other modelling sites. At Dongiverse, your fantasy can become reality, whether you design and print it yourself or allow someone else to help craft your vision in to reality."]
[:p "We bring together some of the most talented 3D modellers with a team of skilled 3D printer operators and plastics engineers to craft high quality toys; whether you want to display them as art, or enjoy them in other ways, the Dongiverse will help bring those dreams to fruition."]]))
[verse.models.model :as model]))
(defn home-snippet [session quip]
(let [objects (take coll/page-size (model/get-all))]
(concat
(h/html [:div.brand-row [:div.row.space-top
[:div.small-12.columns
(about-snippet session)]]])
(web/about-snippet session)
(h/html [:div.row
[:ul.small-block-grid-4
(for [item objects]
(util/model-grid-for item))]]))))
(defn render [session request]
(let [quip (verse.util/quip)]
(defn render [request]
(let [quip (verse.util/quip)
session (:session request)]
(web/main-template session "Dongiverse" quip
(home-snippet session quip))))

@ -0,0 +1,80 @@
(ns verse.web.profile
(:require [compojure.core :refer :all]
[hiccup.core :as h]
[verse.web :as web]
[verse.coll :as coll]
[verse.models.user :as user]
[verse.util :as util]
[ring.middleware.anti-forgery :as af]))
(defn signup-form "Render an HTML form for logging in" [session]
[:form {:style "margin-top: 1em;" :action "/profile/new" :method "post" :data-abide "true"}
[:input {:type "hidden" :name "__anti-forgery-token" :value af/*anti-forgery-token*}]
[:div.row
[:div.small-10.columns
[:label "My handle"
[:input {:type "text" :name "username" :required "true" :pattern "[a-zA-Z]+"}]]
[:small.error "Handle is required and contain just alphabet characters."]]
[:div.small-2.columns
[:span.has-tip {:data-tooltip "true" :aria-haspopup "true" :title "This is a name that you can share with others to find you on the Dongiverse. You'll get your very own super cool dongiverse.com/profile/my-handle URL that you can share with whomever your heart desires."}
"What's this?"]]]
[:div.row
[:div.small-10.columns
[:label "My name or nickname"
[:input {:type "text" :name "name"}]]]
[:div.small-2.columns
[:span.has-tip {:data-tooltip "true" :aria-haspopup "true" :title "This is how your name will look on the site. Use a real name, or a stylized version of your handle, if you want. If you leave it blank, we'll use your handle"}
"What's this?"]]]
[:div.row
[:div.small-12.medium-6.columns
[:label "My password"
[:input {:type "password" :name "pass" :id "pass" :required "true"}]]
[:small.error "You need to type in a password."]]
[:div.small-12.medium-6.columns
[:label "My password again"
[:input {:type "password" :name "passconf" :required "true" :data-equalto "pass"}]]
[:small.error "Your password confirmation needs to match your password."]]]
[:div.row
[:div.small-12.columns
[:label "My email address"
[:input {:type "email" :name "email" :required "true"}]]
[:small.error "Email address is required."]]
[:div.small-12.columns
[:p.info "We know that spam on the internet is really terrible, we're never going to share your email address with anyone unless we ask you first, and we're going to be super duper easy on the emails we send you directly. Promise 😻"]]]
[:div.row
[:div.small-6.columns
[:label "Do you agree to the terms and conditions of this site?"]
[:input {:name "toc-agree" :type "checkbox" :required "true"}]
[:label {:for "toc-agree"} "Yes I do."]]
[:div.small-6.columns
[:label "Are you at least 18 years of age?"]
[:input {:name "age-agree" :type "checkbox" :required "true"}]
[:label {:for "age-agree"} "Yes I am."]]]
[:div.row
[:div.small-12.medium-6.columns.medium-centered
[:button.expand {:type "submit"} "Join the Dongiverse"]]]])
(defn signup-page "Return a hiccup map of the signup page" [session quip]
(h/html [:div.brand-row
[:div.row
[:div.small-12.columns
[:h3 "Join the Dongiverse"]]]]
(web/about-snippet session)
[:div.brand-row
[:div.row
[:div.small-12.columns
[:div#about
[:p "Just because you aren't an artist or maker, doesn't mean that a Dongiverse membership is not for you. You gain access to a forum filled with like-minded connoisseurs of 3D printed paraphenalia, the ability to crate collections and, some day soon, the ability to purchase Dongiverse creations and have them discreetly mailed to you."]]]]]
[:div.row
[:div.small-12.medium-10.columns.medium-centered
(signup-form session)]]))
(defn new "Render the signup page" [request]
(let [quip (verse.util/quip)
session (:session request)]
(web/main-template session "Dongiverse" quip
(signup-page session quip))))
(defn post-new "Create a new user object from a POST body" [request]
(let [session (:session request)]
(h/html "hi")))
Loading…
Cancel
Save