diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-11-05 18:45:04 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-11-05 18:45:04 +0100 |
commit | 5ff55cd6309d570a5297c0b26dfd623b1fadd604 (patch) | |
tree | c37e9faae3dde2a56a96cd473abbb5882cbeea4f /src/mulk/benki/main.clj |
Initial checkin.
Diffstat (limited to 'src/mulk/benki/main.clj')
-rw-r--r-- | src/mulk/benki/main.clj | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/mulk/benki/main.clj b/src/mulk/benki/main.clj new file mode 100644 index 0000000..59aa512 --- /dev/null +++ b/src/mulk/benki/main.clj @@ -0,0 +1,46 @@ +(ns mulk.benki.main + (:refer-clojure) + (:use [clojure core repl pprint] + noir.core + [hiccup core page-helpers] + [mulk.benki util]) + (:require noir.server)) + + +(defonce server (noir.server/start 3000)) + +(defn wrap-utf-8 [handler] + (fn [request] + (let [response (handler request) + ctype (get-in response [:headers "Content-Type"]) + utf8ctype (str ctype "; charset=utf-8")] + (if (and ctype + (re-matches #"^(text/html|text/plain|application/xhtml+xml|text/xml)$" ctype)) + (assoc-in response [:headers "Content-Type"] utf8ctype) + response)))) + +(do-once ::init + (noir.server/add-middleware #'wrap-utf-8) + ;;(set! *base-url* nil) + ) + + +(defpage "/welcome" [] + "<h1>Hello World</h1> + + <p>Hi!</p>") + +(defpage "/hello" {name :name} + (layout + [:h1 "Greeting"] + [:p (fmt nil "Hi~@[ ~A~]!" name)])) + +(defpage "/journal/:id" {id :id} + (layout + [:h1 "Journal Entry #" id] + [:p "Bla bla bla."])) + +(defpage "/journal" {} + (layout + [:h1 "Journal"])) + |