Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
;; Copyright (C) 2015, Jozef Wagner. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0
;; ( which can be
;; found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound
;; by the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns jogurt.ring.routes
"Web app routes"
(:api dunaj)
[dunaj.resource :refer [IAcquirableFactory]]
[hiccup.core :as hc]
[ :as hp]
[hiccup.element :as he]
[jogurt.util.cfg :as jc]
[ :as jp]
[jogurt.auth :as ja]
[ :as js]
[dunaj.uuid :as du]
[ring.util.response :as rur]
[ :as jsg]
[compojure.core :as cc
:refer [defroutes GET POST DELETE ANY context]])
[compojure.route :only [files not-found resources]]
[compojure.handler :only [site]]))
(defn sign-out
;; TODO: guard against CSRF attack so that sign out cannot be
;; automated
(assoc (rur/redirect "/") :session nil))
(defn make-routes
[cfg auth store]
(GET "/" [] (partial jp/index-page cfg auth store))
(GET "/post/:pid" [] (partial jp/post-page cfg auth store))
(GET "/new" [] (partial jp/new-page cfg auth store))
(POST "/submitpost" [] (partial jp/new-post cfg auth store))
(GET "/authback" [] (partial ja/callback auth))
(GET "/signout" [] sign-out)
(resources "/static/")
(not-found "<p>Page not found.</p>")))
(defrecord RoutesFactory [cfg auth store]
(-acquire! [this]
(let [schema (get cfg :schema [:users :posts])]
(apply js/init! store schema))
(site (make-routes cfg auth store)
{:session {:store (jsg/memory-store)}})))
(def routes-factory
(->RoutesFactory nil nil nil))