   (context "/api" []
            #(ring.util.response/content-type (api-routes %) "application/json"))
 
-  (GET "/" []
-       (layout (get-message :page-title)
-               [:div#hero
-                [:h1 (get-message :name)]
-                [:h2 (get-message :title)]
-                [:br]
-                [:a.landing-button {:href "/new" :style "color: white"} (get-message :new-page)]]
-               [:div#dashed-line]
-               (md-node :article.helvetica.bottom-space
-                        {:style "font-size: 1em"}
-                        (slurp "LANDING.md"))
-               (md-node :div.centered.helvetica (get-message :footer))))
+  (GET "/" [] landing-page)
 
   (GET "/:year/:month/:day/:title/export" [year month day title]
        (when-let [md-text (:note (api/get-note {:noteID (api/build-key year month day title)}))]


  (GET "/:year/:month/:day/:title/stats" [year month day title]
       (when-let [resp (api/get-note {:noteID (api/build-key year month day title)})]
         (let [stats (:statistics resp)
               statistics (get-message :statistics)]
           (layout statistics
                   [:h2.central-element (api/derive-title (:note resp))]
                   [:h3.central-element.helvetica statistics]
                   [:table#stats.helvetica.central-element
                    (map
                      #(when-let [v (% stats)]
                         [:tr
                          [:td (str (get-message %) ":")]
                          [:td (if (or (= % :published) (= % :edited))
                                 (str (java.util.Date. (Long/parseLong v))) v)]])
                      [:published :edited :publisher :views])]))))

  (GET "/:year/:month/:day/:title/edit" [year month day title]
       (let [noteID (api/build-key year month day title)]
         (input-form "/update-note" :update
                     (html (hidden-field :noteID noteID))
                     (:note (api/get-note {:noteID noteID})) :enter-passwd)))

  (GET "/new" []
       (input-form "/post-note" :publish
                   (html (hidden-field :session (storage/sign (str (rand-int Integer/MAX_VALUE))))
                         (hidden-field {:id :signature} :signature))
                   (get-message :loading) :set-passwd))

  (GET "/:year/:month/:day/:title" [year month day title :as params]
       (let [params (assoc (:query-params params)
                      :year year :month month :day day :title title)
             noteID (api/build-key year month day title)]
         (when (storage/note-exists? noteID)
           (let [note (api/get-note {:noteID noteID})
                 sanitized-note (sanitize (:note note))]
             (layout (:title note)
                     (md-node :article.bottom-space sanitized-note)
                     (let [urls {:short-url (api/url (storage/create-short-url noteID params))
                                 :notehub "/"}
                           links (map #(link-to
                                        (if (urls %)
                                          (urls %)
                                          (str (:longURL note) "/" (name %)))
                                        (get-message %))
                                      [:notehub :stats :edit :export :short-url])
                           links (interpose [:span.middot "&middot;"] links)]
                       [:div#links links]))))))

  (GET "/:short-url" [short-url]
       (when-let [params (storage/resolve-url short-url)]

(ns notehub.handler
  (:use compojure.core
        [notehub.views]
        [notehub.settings]
        [clojure.string :rename {replace sreplace} :only [replace]]
        [clojure.core.incubator :only [-?>]])
  (:require 
    [hiccup.util :as util]
    [compojure.handler :as handler]
    [compojure.route :as route]
    [notehub.api :as api]
    [notehub.storage :as storage]
    [cheshire.core :refer :all]))

; TODO: make sure the status is really set to the response!!!!
(defn- response
