diff options
-rw-r--r-- | project.clj | 39 | ||||
-rw-r--r-- | src/mulk/benki/auth.clj | 10 | ||||
-rw-r--r-- | src/mulk/benki/book_marx.clj | 4 | ||||
-rw-r--r-- | src/mulk/benki/genkey.clj | 2 | ||||
-rw-r--r-- | src/mulk/benki/id.clj | 2 | ||||
-rw-r--r-- | src/mulk/benki/lazychat.clj | 6 | ||||
-rw-r--r-- | src/mulk/benki/main.clj | 21 | ||||
-rw-r--r-- | src/mulk/benki/util.clj | 14 | ||||
-rw-r--r-- | src/mulk/benki/webutil.clj | 2 | ||||
-rw-r--r-- | src/mulk/benki/wiki.clj | 5 |
10 files changed, 64 insertions, 41 deletions
diff --git a/project.clj b/project.clj index 51f4033..ab0b79e 100644 --- a/project.clj +++ b/project.clj @@ -21,17 +21,17 @@ [org.clojure/tools.trace "0.7.1"] ;; Web app utilities - [ring "1.0.2"] - [noir "1.2.1"] - [hiccup "0.3.7"] + [ring "1.1.1"] + [noir "1.3.0-beta10"] + [hiccup "1.0.0"] [cssgen "0.2.5"] - [aleph "0.2.1-beta2"] - [noir-async "1.0.0-SNAPSHOT"] + [aleph "0.3.0-alpha2"] + [lamina "0.5.0-alpha3"] + [noir-async "1.1.0-beta1"] ;; Relational database access [clojureql "1.0.3"] - [korma "0.2.1"] - [postgresql "9.0-801.jdbc4"] + [postgresql "9.1-901.jdbc4"] [org.clojure/java.jdbc "0.1.1"] ;; Additional libraries @@ -40,6 +40,7 @@ [org.openid4java/openid4java-server "0.9.6" :extension "pom"] [org.openid4java/openid4java-xri "0.9.6" :extension "pom"] [org.openid4java/openid4java-infocard "0.9.6" :extension "pom"] + [xerces "2.4.0"] ;log4j needs this; OpenID4Java needs log4j [org.jsoup/jsoup "1.6.1"] [org.apache.abdera/abdera-parser "1.1.2"] [org.apache.ws.commons.axiom/axiom-api "1.2.12"] @@ -48,14 +49,29 @@ [jivesoftware/smack "3.1.0"] [jivesoftware/smackx "3.1.0"] [joda-time/joda-time "2.1"] + ;;[org.bouncycastle/bcmail-jdk15on "1.46"] [org.bouncycastle/bcprov-jdk15on "1.47"] + ;;[org.bouncycastle/bcpg-jdk15on "1.46"] [org.bouncycastle/bcpkix-jdk15on "1.47"] - ] - :plugins [[lein-swank "1.4.3"]] - :exclusions [org.clojure/clojure-contrib] ;you know, the old pre-1.3.0 versions + ;;[org.bouncycastle/bcprov-ext-jdk15on "1.46"] + ;;[org.bouncycastle/bctsp-jdk15on "1.46"] + + ;; Semantic Web/RDF stuff + [org.apache.jena/jena-arq "2.9.1"] + [org.apache.jena/jena-tdb "0.9.1"] + [org.apache.jena/jena-larq "1.0.0-incubating"] + [org.apache.jena/jena-iri "0.9.1"]] + :plugins [[lein-swank "1.4.3"] + [lein-ring "0.6.6"]] + :exclusions [org.clojure/clojure-contrib ;you know, the old pre-1.3.0 versions + org.clojure/clojure ;so that we can enforce our preferred version + org.clojure.contrib/prxml] ;;:hooks [leiningen.hooks.difftest] ;;:warn-on-reflection true ;breaks M-x clojure-jack-in - :repositories {"sonatype-snapshots" + :profiles {:dev {} + :tomcat {:plugins [[lein-ring "0.6.6"]]}} + :repositories { + "sonatype-snapshots" ;;https confuses leiningen (but not cake) {:url "http://oss.sonatype.org/content/repositories/snapshots/" :snapshots true}, @@ -80,4 +96,3 @@ ;;:jvm-opts ["-Xms32m"] :main mulk.benki.main :min-lein-version "2.0.0") - 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] |