preview with markdown processing added

This commit is contained in:
Christian Mueller
2012-05-27 22:11:13 +02:00
parent 2eef1b0150
commit 967e6d8a32
4 changed files with 24 additions and 13 deletions
+1
View File
@@ -3,6 +3,7 @@
:dependencies [[org.clojure/clojure "1.4.0"]
[hiccup "1.0.0"]
[cssgen "0.2.6"]
[markdown-clj "0.8"]
[noir "1.3.0-beta1"]]
:plugins [[lein-cljsbuild "0.1.10"]]
:cljsbuild {
+4 -4
View File
@@ -11,11 +11,11 @@
[selector]
(dom/get-element selector))
(if-let [write-textarea ($ "write-textarea")]
(focus/focusInputField write-textarea))
(if-let [draft ($ "draft")]
(focus/focusInputField draft))
; Show the Preview button as soon as the user starts typing.
(event/listen ($ "write-textarea")
(event/listen ($ "draft")
:keypress
(fn [e]
(style/setStyle ($ "form-button") "display" "block")))
(style/setStyle ($ "preview-button") "display" "block")))
+5 -3
View File
@@ -44,8 +44,9 @@
(rule ".article-font"
:font-family :Georgia
:font-size :1.3em)
(rule ".max-width"
:width "900px")
(rule "article"
:font-family :Georgia
:font-size :1.2em)
(rule "*:focus"
:outline [:0px :none :transparent])
(rule "textarea"
@@ -53,7 +54,7 @@
:font-size :1.3em
:border :none
:height :600px)
(rule "#form-button"
(rule "#preview-button"
helvetica-neue
:display :none
:cursor :pointer
@@ -62,6 +63,7 @@
:font-size :0.8em
:opacity :0.8)
(rule ".central-body"
:width "900px"
:margin-top :5em
:margin-bottom :5em
:margin-left "auto"
+14 -6
View File
@@ -1,9 +1,10 @@
(ns NoteHub.views.pages
(:require [NoteHub.views.common :as common])
(:use [noir.core :only [defpage]]
[hiccup.form]))
[hiccup.form]
[markdown :only [md-to-html-string]]))
(defpage "/" []
(defpage "/" {}
(common/layout "Free Markdown Hosting"
[:div#hero
[:h1 "NoteHub"]
@@ -12,9 +13,16 @@
[:br]
[:a.button {:href "/new"} "New Page"]]))
(defpage "/new" []
(defpage "/new" {}
(common/layout "New Markdown Note"
[:div.central-body.max-width
(text-area {:class "max-width"} :write-textarea)
(submit-button {:id "form-button"} "Preview")]))
[:div.central-body
(form-to [:post "/preview-note"]
(text-area {:class "max-width"} :draft)
(submit-button {:id "preview-button"} "Preview"))]))
; Actions.
(defpage [:post "/preview-note"] {:keys [draft]}
(common/layout "Preview of ..."
[:article.central-body
(md-to-html-string draft)]))