diff options
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))) |