switched to JS markdown processing only
This commit is contained in:
@@ -16,39 +16,38 @@
|
||||
|
||||
; Creates the main html layout
|
||||
(defpartial generate-layout
|
||||
[params title & content]
|
||||
; for the sake of security: escape all symbols of the param values
|
||||
(let [params (into {} (for [[k v] params] [k (escape-html v)]))]
|
||||
(html5
|
||||
[:head
|
||||
[:title (print-str (get-message :name) "—" title)]
|
||||
[:meta {:charset "UTF-8"}]
|
||||
; generating a link to google's webfonts
|
||||
[:link {:href
|
||||
(clojure.string/replace
|
||||
(str "http://fonts.googleapis.com/css?family="
|
||||
(apply
|
||||
str
|
||||
(interpose "|"
|
||||
; ugly thing, but it cannot be avoided since these
|
||||
; fonts have to be loaded (independently of CSS)
|
||||
(concat ["PT+Serif:700" "Noticia+Text:700"]
|
||||
(vals (select-keys params
|
||||
[:header-font :text-font])))))
|
||||
"&subset=latin,cyrillic") " " "+")
|
||||
:rel "stylesheet"
|
||||
:type "text/css"}]
|
||||
; generating the global CSS
|
||||
[:link {:rel "stylesheet" :type "text/css" :href "/style.css"}]
|
||||
; google analytics code should appear in prod mode only
|
||||
(if-not (dev-mode?) (include-js "/js/google-analytics.js"))]
|
||||
[:body content
|
||||
; we only need JS during a new note creation, so don't render it otherwise
|
||||
(when (params :js)
|
||||
(html
|
||||
(include-js "/js/md5.js")
|
||||
(include-js "/js/marked.js")
|
||||
(include-js "/js/main.js")))])))
|
||||
[params title & content]
|
||||
; for the sake of security: escape all symbols of the param values
|
||||
(let [params (into {} (for [[k v] params] [k (escape-html v)]))]
|
||||
(html5
|
||||
[:head
|
||||
[:title (print-str (get-message :name) "—" title)]
|
||||
[:meta {:charset "UTF-8"}]
|
||||
; generating a link to google's webfonts
|
||||
[:link {:href
|
||||
(clojure.string/replace
|
||||
(str "http://fonts.googleapis.com/css?family="
|
||||
(apply
|
||||
str
|
||||
(interpose "|"
|
||||
; ugly thing, but it cannot be avoided since these
|
||||
; fonts have to be loaded (independently of CSS)
|
||||
(concat ["PT+Serif:700" "Noticia+Text:700"]
|
||||
(vals (select-keys params
|
||||
[:header-font :text-font])))))
|
||||
"&subset=latin,cyrillic") " " "+")
|
||||
:rel "stylesheet"
|
||||
:type "text/css"}]
|
||||
; generating the global CSS
|
||||
[:link {:rel "stylesheet" :type "text/css" :href "/style.css"}]
|
||||
; google analytics code should appear in prod mode only
|
||||
(if-not (dev-mode?) (include-js "/js/google-analytics.js"))]
|
||||
[:body content
|
||||
; we only need JS during a new note creation, so don't render it otherwise
|
||||
(html
|
||||
(include-js "/js/md5.js")
|
||||
(include-js "/js/marked.js")
|
||||
(include-js "/js/main.js"))])))
|
||||
|
||||
(defn layout
|
||||
"Generates the main html layout"
|
||||
|
||||
@@ -14,16 +14,7 @@
|
||||
[noir.core :only [defpage defpartial]]
|
||||
[noir.statuses])
|
||||
(:import
|
||||
[java.util Calendar]
|
||||
[org.pegdown PegDownProcessor]))
|
||||
|
||||
; Create a new Object of the MD-processor
|
||||
(def md-processor
|
||||
(PegDownProcessor.))
|
||||
|
||||
; Markdown -> HTML mapper
|
||||
(defn md-to-html [md-text]
|
||||
(.markdownToHtml md-processor md-text))
|
||||
[java.util Calendar]))
|
||||
|
||||
(defn get-hash
|
||||
"A simple hash-function, which computes a hash from the text field
|
||||
@@ -57,7 +48,7 @@
|
||||
(defn- wrap [short-url params md-text]
|
||||
(when md-text
|
||||
(layout params (params :title)
|
||||
[:article.bottom-space (md-to-html md-text)]
|
||||
[:article.bottom-space.markdown md-text]
|
||||
(let [links (map #(link-to
|
||||
(if (= :short-url %)
|
||||
(url short-url)
|
||||
@@ -78,11 +69,6 @@
|
||||
; Routes
|
||||
; ======
|
||||
|
||||
; This function answers to an AJAX request: it gets a session key and a markdown text.
|
||||
; It returns the html code of the provided markdown and a new session key.
|
||||
(defpage [:post "/preview"] {:keys [session-key draft]}
|
||||
(str "{ preview: " (escape (md-to-html draft) {\" "\\\""}) "}"))
|
||||
|
||||
; Landing Page
|
||||
(defpage "/" {}
|
||||
(layout (get-message :page-title)
|
||||
@@ -92,16 +78,15 @@
|
||||
[:br]
|
||||
[:a.landing-button {:href "/new" :style "color: white"} (get-message :new-page)]]
|
||||
[:div#dashed-line]
|
||||
; dynamically generates three column, retrieving corresponding messages
|
||||
[:article.helvetica-neue.bottom-space {:style "font-size: 1em"}
|
||||
(md-to-html (slurp "LANDING.md"))]
|
||||
[:div.centered.helvetica-neue (md-to-html (get-message :footer))]))
|
||||
[:article.helvetica-neue.bottom-space.markdown {:style "font-size: 1em"}
|
||||
(slurp "LANDING.md")]
|
||||
[:div.centered.helvetica-neue.markdown (get-message :footer)]))
|
||||
|
||||
; input form for the markdown text with a preview area
|
||||
(defpartial input-form [form-url command fields content passwd-msg]
|
||||
(let [css-class (when (= :publish command) :hidden)]
|
||||
(layout {:js true} (get-message :new-note)
|
||||
[:article#preview " "]
|
||||
[:article#preview.markdown " "]
|
||||
[:div#dashed-line {:class css-class}]
|
||||
[:div.central-element.helvetica-neue {:style "margin-bottom: 3em"}
|
||||
(form-to {:autocomplete :off} [:post form-url]
|
||||
|
||||
Reference in New Issue
Block a user