summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-07-01 16:04:04 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-07-01 16:04:04 +0200
commit81a34ce78c8080c95274384204049894806d3d79 (patch)
tree68dd0b4cbcd8b0b477bba8bc32e7997da764e7c3
parent7c082abec97e1ca5090a9b5d0956d53549d19a9f (diff)
Move configuration file loading from load-time to run-time.
-rw-r--r--project.clj3
-rw-r--r--src/mulk/benki/config.clj3
-rw-r--r--src/mulk/benki/main.clj7
-rw-r--r--src/mulk/benki/util.clj7
4 files changed, 12 insertions, 8 deletions
diff --git a/project.clj b/project.clj
index 2798b0f..f73140d 100644
--- a/project.clj
+++ b/project.clj
@@ -74,8 +74,7 @@
[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"]]
+ :plugins [[lein-swank "1.4.3"]]
: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]
diff --git a/src/mulk/benki/config.clj b/src/mulk/benki/config.clj
index 0e9429e..c9a9dbe 100644
--- a/src/mulk/benki/config.clj
+++ b/src/mulk/benki/config.clj
@@ -1,5 +1,4 @@
(ns mulk.benki.config
(:refer-clojure))
-(def benki-config
- (atom (read-string (slurp (.getFile (clojure.java.io/resource "config.sexp"))))))
+(def benki-config (atom nil))
diff --git a/src/mulk/benki/main.clj b/src/mulk/benki/main.clj
index 0c2f20f..6908561 100644
--- a/src/mulk/benki/main.clj
+++ b/src/mulk/benki/main.clj
@@ -113,7 +113,10 @@
(assoc-in response [:headers "Content-Type"] exttype)
response))))
-(do-once ::init
+(defn init-config! []
+ (swap! benki-config (read-string (slurp (.getFile (clojure.java.io/resource "config.sexp"))))))
+
+(defn init-middleware! []
(noir.server/add-middleware #(ring.middleware.file-info/wrap-file-info %))
(noir.server/add-middleware #(hiccup.middleware/wrap-base-url % (:base-uri @benki-config)))
(noir.server/add-middleware #(wrap-missing-status-code %))
@@ -142,6 +145,8 @@
(defn -main [& args]
(do
+ (init-config!)
+ (init-middleware!)
(noir.server/load-views-ns 'mulk.benki)
(init-security!)
(future (require 'mulk.benki.xmpp)
diff --git a/src/mulk/benki/util.clj b/src/mulk/benki/util.clj
index 3354b25..366e9c0 100644
--- a/src/mulk/benki/util.clj
+++ b/src/mulk/benki/util.clj
@@ -7,7 +7,8 @@
(:require [noir.session :as session]
[noir.request :as request]
[noir.response :as response]
- [clojure.java.jdbc :as sql])
+ [clojure.java.jdbc :as sql]
+ [clojure.pprint])
(:import [java.text DateFormat]
[java.security SecureRandom]
[java.math BigInteger]
@@ -92,8 +93,8 @@
[[:wiki title & xs]] (fmt nil "/wiki/~a~@[~a~]" title (first xs))
[[:keys]] "/keys"
[[:keys :register]] "/keys/register"
- [[:profile user]] (fmt nil "/~~~a" (user-nickname user))
- ))
+ [[:profile user]] (fmt nil "/~~~a" (user-nickname user))))
+
(defn link [& args]
(resolve-uri (apply linkrel args)))