summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-06-25 17:46:07 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-06-25 17:46:07 +0200
commit06380786543fbe9c85f62ec2c4caa3e8fb6ff36d (patch)
treebe753d6d53a6cd7decfad711e6c16cd09392e474 /src
parent3688af4b9c335f3cc5d8a98b4371a2f8a33b8e3d (diff)
Upgrade to Noir 1.3.0 and Hiccup 1.0.0.
Diffstat (limited to 'src')
-rw-r--r--src/mulk/benki/auth.clj10
-rw-r--r--src/mulk/benki/book_marx.clj4
-rw-r--r--src/mulk/benki/genkey.clj2
-rw-r--r--src/mulk/benki/id.clj2
-rw-r--r--src/mulk/benki/lazychat.clj6
-rw-r--r--src/mulk/benki/main.clj21
-rw-r--r--src/mulk/benki/util.clj14
-rw-r--r--src/mulk/benki/webutil.clj2
-rw-r--r--src/mulk/benki/wiki.clj5
9 files changed, 37 insertions, 29 deletions
diff --git a/src/mulk/benki/auth.clj b/src/mulk/benki/auth.clj
index 9cbe405..b92b3fa 100644
--- a/src/mulk/benki/auth.clj
+++ b/src/mulk/benki/auth.clj
@@ -1,7 +1,7 @@
(ns mulk.benki.auth
(:refer-clojure)
(:use [clojure core repl pprint]
- [hiccup core page-helpers]
+ [hiccup core page]
[mulk.benki config util db]
[clojure.core.match
:only [match]]
@@ -46,7 +46,7 @@
user (find-user user-id)]
(if user-id
(do (session/put! :user user-id)
- (if-let [return-uri (session/flash-get)]
+ (if-let [return-uri (session/flash-get ::return-uri)]
(redirect return-uri)
(layout {} "Authenticated!" [:p "Welcome back, " (:first_name user) "!"])))
(layout "Authentication Failed"
@@ -69,7 +69,7 @@
(let [record (first (query "SELECT * FROM user_email_addresses WHERE email = ?" email))
user-id (and record (:user record))]
(if user-id
- (let [return-uri (session/flash-get)]
+ (let [return-uri (session/flash-get ::return-uri)]
(session/put! :user user-id)
(response/json {:email email, :returnURI return-uri}))
{:status 422,
@@ -105,7 +105,7 @@
)})
(defpage "/login" []
- (let [return-uri (or (session/flash-get)
+ (let [return-uri (or (session/flash-get ::return-uri)
(get-in (request/ring-request) [:headers "referer"]))]
(with-dbt
(if-let [cert-user-id (and *client-cert*
@@ -121,7 +121,7 @@
(redirect return-uri)
(layout {} "Authenticated!" [:p "Welcome back, " (:first_name cert-user) "!"])))
(do
- (session/flash-put! return-uri)
+ (session/flash-put! ::return-uri return-uri)
(layout login-page-layout "Benki Login"
[:div#browserid-box
[:h2 "BrowserID login"]
diff --git a/src/mulk/benki/book_marx.clj b/src/mulk/benki/book_marx.clj
index df5c2ad..bc3882c 100644
--- a/src/mulk/benki/book_marx.clj
+++ b/src/mulk/benki/book_marx.clj
@@ -1,11 +1,11 @@
(ns mulk.benki.book_marx
(:refer-clojure)
(:use [clojure repl]
- [hiccup core page-helpers]
+ [hiccup core page]
[clojureql predicates]
[clojure.core.match :only [match]]
- [hiccup.core :only [escape-html]]
[ring.util.codec :only [url-encode]]
+ [hiccup.util :only [escape-html]]
noir.core
[mulk.benki util db auth config webutil feed])
(:require [clojure.algo.monads :as m]
diff --git a/src/mulk/benki/genkey.clj b/src/mulk/benki/genkey.clj
index 381bc00..cd84ba3 100644
--- a/src/mulk/benki/genkey.clj
+++ b/src/mulk/benki/genkey.clj
@@ -1,7 +1,7 @@
(ns mulk.benki.genkey
(:refer-clojure)
(:use [clojure core repl pprint]
- [hiccup core page-helpers]
+ [hiccup core page]
[mulk.benki config util db webutil]
[clojure.core.match
:only [match]]
diff --git a/src/mulk/benki/id.clj b/src/mulk/benki/id.clj
index a6ba042..1054476 100644
--- a/src/mulk/benki/id.clj
+++ b/src/mulk/benki/id.clj
@@ -1,7 +1,7 @@
(ns mulk.benki.id
(:refer-clojure)
(:use [clojure core repl pprint]
- [hiccup core page-helpers]
+ [hiccup core page]
[mulk.benki config util db]
[clojure.core.match
:only [match]]
diff --git a/src/mulk/benki/lazychat.clj b/src/mulk/benki/lazychat.clj
index b1e8c51..b32e3af 100644
--- a/src/mulk/benki/lazychat.clj
+++ b/src/mulk/benki/lazychat.clj
@@ -1,16 +1,16 @@
(ns mulk.benki.lazychat
(:refer-clojure)
(:use [clojure repl]
- [hiccup core page-helpers]
+ [hiccup core page]
[noir core]
[noir-async core]
[mulk.benki auth config db util webutil feed]
;;
[clojure.core.match :only [match]]
- [hiccup.core :only [escape-html]]
[ring.util.codec :only [url-encode]]
[lamina.core :only [channel enqueue enqueue-and-close receive-all
- map* filter*]])
+ map* filter*]]
+ [hiccup.util :only [escape-html]])
(:require [clojure.algo.monads :as m]
[clojure.java.jdbc :as sql]
[clojure.string :as string]
diff --git a/src/mulk/benki/main.clj b/src/mulk/benki/main.clj
index c5ddfd6..fec1c85 100644
--- a/src/mulk/benki/main.clj
+++ b/src/mulk/benki/main.clj
@@ -2,9 +2,10 @@
(:refer-clojure)
(:use [clojure core repl pprint]
noir.core
- [hiccup core page-helpers]
+ [hiccup core page]
[mulk.benki util config db])
- (:require [noir server options]
+ (:require [noir.core]
+ [noir server options]
[mulk.benki wiki auth book_marx id lazychat xmpp genkey]
[ring.middleware.file]
[noir.session :as session]
@@ -15,11 +16,17 @@
[aleph.formats :as aformats]
[ring.util.codec :as codec]
[clojure.algo.monads :as m]
- [clojure.data.json :as json])
+ [clojure.data.json :as json]
+ )
(:import [java.math BigDecimal BigInteger])
(:gen-class))
+(defn wrap-missing-status-code [handler]
+ (fn [request]
+ (let [response (handler request)]
+ (assoc response :status (get response :status 404)))))
+
(defn wrap-utf-8 [handler]
(fn [request]
(let [response (handler request)
@@ -30,12 +37,6 @@
(assoc-in response [:headers "Content-Type"] utf8ctype)
response))))
-(defn wrap-base-uri [handler]
- (fn [request]
- (let [base-uri (:base-uri @benki-config)]
- (hiccup.core/with-base-url base-uri
- ((noir.options/wrap-options handler {:base-url base-uri}) request)))))
-
(defn wrap-cache-control [handler]
(fn [request]
(let [response (handler request)]
@@ -111,8 +112,8 @@
response))))
(do-once ::init
+ (noir.server/add-middleware #(wrap-missing-status-code %))
(noir.server/add-middleware #(wrap-utf-8 %))
- (noir.server/add-middleware #(wrap-base-uri %))
(noir.server/add-middleware #(wrap-auth-token %))
(noir.server/add-middleware #(wrap-client-cert %))
(noir.server/add-middleware #(wrap-cache-control %))
diff --git a/src/mulk/benki/util.clj b/src/mulk/benki/util.clj
index 4c8a141..3354b25 100644
--- a/src/mulk/benki/util.clj
+++ b/src/mulk/benki/util.clj
@@ -1,8 +1,8 @@
(ns mulk.benki.util
(:refer-clojure)
- (:use [hiccup core page-helpers]
+ (:use [hiccup core page]
[clojure.core.match :only [match]]
- noir.core
+ [noir core]
[mulk.benki config db])
(:require [noir.session :as session]
[noir.request :as request]
@@ -25,6 +25,11 @@
(defonce #^:private finished-initializations (atom #{}))
+
+(defn resolve-uri [uri]
+ (.toString (.resolve (java.net.URI. (:base-uri @benki-config)) uri)))
+
+
(defmacro do-once [key & body]
`(while (not (@(deref #'finished-initializations) key))
(let [fininit-copy# @(deref #'finished-initializations)]
@@ -51,7 +56,7 @@
[:script {:type "text/javascript"
:src (resolve-uri "/3rdparty/jquery/jquery-1.7.min.js")}]
[:script {:type "text/javascript"
- :src (resolve-uri "https://browserid.org/include.js")}]
+ :src "https://browserid.org/include.js"}]
[:script {:type "text/javascript"
:src (resolve-uri "/js/browserid.js")}]
[:link {:type "text/css"
@@ -99,7 +104,8 @@
(defn call-with-auth [thunk]
(if *user*
(thunk)
- (do (session/flash-put! (str (:uri (request/ring-request))
+ (do (session/flash-put! :mulk.benki.auth/return-uri
+ (str (:uri (request/ring-request))
(if-let [q (:query-string (request/ring-request))]
(str "?" q)
"")))
diff --git a/src/mulk/benki/webutil.clj b/src/mulk/benki/webutil.clj
index 88516e6..11e316e 100644
--- a/src/mulk/benki/webutil.clj
+++ b/src/mulk/benki/webutil.clj
@@ -1,6 +1,6 @@
(ns mulk.benki.webutil
(:refer-clojure)
- (:use [hiccup core page-helpers]
+ (:use [hiccup core page]
[clojure.core.match :only [match]]
noir.core
[mulk.benki db util])
diff --git a/src/mulk/benki/wiki.clj b/src/mulk/benki/wiki.clj
index f5e7f30..d0c46f8 100644
--- a/src/mulk/benki/wiki.clj
+++ b/src/mulk/benki/wiki.clj
@@ -2,12 +2,13 @@
(:refer-clojure :exclude [distinct conj! case compile drop take sort disj!
resultset-seq])
(:use [clojure repl pprint]
- [hiccup core page-helpers]
- [hiccup.core :only [escape-html]]
+ [hiccup core page]
[mulk.benki util db]
[clojure.core.match
:only [match]]
[clojureql core predicates]
+ [hiccup.util
+ :only [escape-html]]
noir.core)
(:require [noir.session :as session]
[noir.response :as response]