(ns notehub.handler (:use compojure.core [notehub.settings] [clojure.string :rename {replace sreplace} :only [escape split replace blank? split-lines lower-case]] [clojure.core.incubator :only [-?>]] [hiccup.form] [hiccup.core] [hiccup.element] [hiccup.util :only [escape-html]] [hiccup.page :only [include-js html5]]) (:require [compojure.handler :as handler] [compojure.route :as route] [hiccup.util :as util] [notehub.api :as api] [notehub.storage :as storage] [cheshire.core :refer :all])) ; Creates the main html layout (defn layout [title & content] (html5 [:head [:title (print-str (get-message :name) "—" title)] [:meta {:charset "UTF-8"}] [:meta {:name "viewport" :content "width=device-width, initial-scale=1.0"}] [:link {:rel "stylesheet/less" :type "text/css" :href "/styles/main.less"}] (html (include-js "/js/less.js") (include-js "/js/themes.js") (include-js "/js/md5.js") (include-js "/js/marked.js") (include-js "/js/main.js")) ; google analytics code should appear in prod mode only (if-not (get-setting :dev-mode) (include-js "/js/google-analytics.js"))] [:body {:onload "onLoad()"} content])) (defn md-node "Returns an HTML element with a textarea inside containing the markdown text (to keep all chars unescaped)" ([cls input] (md-node cls {} input)) ([cls opts input] [(keyword (str (name cls) ".markdown")) opts [:textarea input]])) (when-not (storage/valid-publisher? "NoteHub") (storage/register-publisher "NoteHub")) (defn sanitize "Breakes all usages of