diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-07-01 16:04:04 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-07-01 16:04:04 +0200 |
commit | 81a34ce78c8080c95274384204049894806d3d79 (patch) | |
tree | 68dd0b4cbcd8b0b477bba8bc32e7997da764e7c3 /src | |
parent | 7c082abec97e1ca5090a9b5d0956d53549d19a9f (diff) |
Move configuration file loading from load-time to run-time.
Diffstat (limited to 'src')
-rw-r--r-- | src/mulk/benki/config.clj | 3 | ||||
-rw-r--r-- | src/mulk/benki/main.clj | 7 | ||||
-rw-r--r-- | src/mulk/benki/util.clj | 7 |
3 files changed, 11 insertions, 6 deletions
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))) |