some refactoring
This commit is contained in:
+1
-2
@@ -33,12 +33,11 @@
|
||||
; to the preview layer and scroll to it
|
||||
(.click ($ :#preview-button)
|
||||
(fn [e]
|
||||
(do
|
||||
(fm/remote (get-preview-md (val $session-key) (val $draft)) [{:keys [preview session-key]}]
|
||||
(show $preview-start-line)
|
||||
(inner $preview preview)
|
||||
(val $session-key session-key)
|
||||
(scroll-to $preview-start-line)))))
|
||||
(scroll-to $preview-start-line))))
|
||||
|
||||
(.click ($ :#publish-button)
|
||||
(fn [e]
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
(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
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
(ns NoteHub.views.css-generator
|
||||
(:use [cssgen]
|
||||
[NoteHub.settings]
|
||||
[cssgen.types]))
|
||||
(use 'cssgen.use)
|
||||
(css-ns NoteHub.views.css-generator
|
||||
(:use [NoteHub.settings]))
|
||||
|
||||
(defn- gen-fontlist [& fonts]
|
||||
(apply str
|
||||
@@ -11,8 +10,7 @@
|
||||
|
||||
; CSS Mixins
|
||||
(def page-width
|
||||
(mixin
|
||||
:width (px (get-setting :page-width #(Integer/parseInt %) 800))))
|
||||
(px (get-setting :page-width #(Integer/parseInt %) 800)))
|
||||
|
||||
(def helvetica-neue
|
||||
(mixin
|
||||
@@ -25,7 +23,7 @@
|
||||
|
||||
(def central-element
|
||||
(mixin
|
||||
page-width
|
||||
:width page-width
|
||||
:margin-top :5em
|
||||
:margin-bottom :10em
|
||||
:margin-left "auto"
|
||||
@@ -37,16 +35,16 @@
|
||||
:foreground :#ccc
|
||||
:background-halftone :#444
|
||||
:foreground-halftone :#bbb
|
||||
:link-color {:fresh :#6b8
|
||||
:visited :#496
|
||||
:hover :#7c9 }}
|
||||
:link {:fresh :#6b8
|
||||
:visited :#496
|
||||
:hover :#7c9 }}
|
||||
:default {:background :#fff
|
||||
:foreground :#333
|
||||
:background-halftone :#efefef
|
||||
:foreground-halftone :#888
|
||||
:link-color {:fresh :#097
|
||||
:visited :#054
|
||||
:hover :#0a8 }}} keys))
|
||||
:link {:fresh :#097
|
||||
:visited :#054
|
||||
:hover :#0a8 }}} keys))
|
||||
|
||||
(defn global-css
|
||||
"Generates the entire CSS rules of the app"
|
||||
@@ -59,9 +57,9 @@
|
||||
foreground (color theme :foreground)
|
||||
background-halftone (color theme :background-halftone)
|
||||
foreground-halftone (color theme :foreground-halftone)
|
||||
link-fresh (color theme :link-color :fresh)
|
||||
link-visited (color theme :link-color :visited)
|
||||
link-hover (color theme :link-color :hover)]
|
||||
link-fresh (color theme :link :fresh)
|
||||
link-visited (color theme :link :visited)
|
||||
link-hover (color theme :link :hover)]
|
||||
(css
|
||||
(rule "a"
|
||||
:color link-fresh
|
||||
@@ -97,7 +95,7 @@
|
||||
:text-align :justify
|
||||
:vertical-align :top
|
||||
; Replace this by arithmetic with css-lengths as soon as they fix the bug
|
||||
:width (px (quot (get-setting :page-width #(Integer/parseInt %) 800) 3)))
|
||||
:width (/ page-width 3.0))
|
||||
(rule ".helvetica-neue"
|
||||
helvetica-neue)
|
||||
(rule "#hero"
|
||||
@@ -115,7 +113,7 @@
|
||||
:text-align :justify
|
||||
:font-size :1.2em
|
||||
(rule "p"
|
||||
:line-height (% 140))
|
||||
:line-height (% 140))
|
||||
(rule "& > h1:first-child"
|
||||
:text-align :center
|
||||
:margin :2em))
|
||||
@@ -129,7 +127,7 @@
|
||||
(rule "*:focus"
|
||||
:outline [:0px :none :transparent])
|
||||
(rule "textarea"
|
||||
page-width
|
||||
:width page-width
|
||||
:font-family :Courier
|
||||
:font-size :1em
|
||||
:border :none
|
||||
|
||||
@@ -21,9 +21,13 @@
|
||||
[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 (PegDownProcessor.) md-text))
|
||||
(.markdownToHtml md-processor md-text))
|
||||
|
||||
; Creates a random session token
|
||||
(defn- get-flash-key []
|
||||
@@ -75,7 +79,8 @@
|
||||
(for [e [:column-why :column-how :column-geeks]]
|
||||
(html
|
||||
[:td.one-third-column
|
||||
[:h2 (get-message e)] (md-to-html (get-message (keyword (str (name e) "-long"))))]))]]
|
||||
[:h2 (get-message e)]
|
||||
(md-to-html (get-message (keyword (str (name e) "-long"))))]))]]
|
||||
[:div.centered.helvetica-neue (md-to-html (get-message :created-by))]))
|
||||
|
||||
; New Note Page
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
|
||||
(deftest helper-functions
|
||||
(testing "Markdown generation"
|
||||
(is (= "<h1><em>hello</em> <strong>world</strong></h1><p>test <code>code</code></p>"
|
||||
(md-to-html "#_hello_ __world__\ntest `code`")))))
|
||||
(is (= "<h1><em>hellö</em> <strong>world</strong></h1><p>test <code>code</code></p>"
|
||||
(md-to-html "#_hellö_ __world__\ntest `code`")))))
|
||||
(deftest export-test
|
||||
(testing "Markdown export"
|
||||
(has-body (send-request (url 2012 6 3 "some-title" "export")) test-note)))
|
||||
|
||||
Reference in New Issue
Block a user