title added to the article page + redirect after creation
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
dump.rdb
|
||||||
resources/
|
resources/
|
||||||
pom.xml
|
pom.xml
|
||||||
*jar
|
*jar
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
[hiccup.element :only [javascript-tag]]))
|
[hiccup.element :only [javascript-tag]]))
|
||||||
|
|
||||||
(defn gen-comma-list [& fonts] (apply str (interpose "," fonts)))
|
(defn gen-comma-list [& fonts] (apply str (interpose "," fonts)))
|
||||||
|
(def page-width
|
||||||
|
(mixin
|
||||||
|
:width :900px))
|
||||||
(def helvetica-neue
|
(def helvetica-neue
|
||||||
(mixin
|
(mixin
|
||||||
:font-weight 300
|
:font-weight 300
|
||||||
@@ -17,8 +20,6 @@
|
|||||||
|
|
||||||
(def global-css
|
(def global-css
|
||||||
(css
|
(css
|
||||||
(rule ".centerized"
|
|
||||||
:text-align :center)
|
|
||||||
(rule ".landing-button"
|
(rule ".landing-button"
|
||||||
:box-shadow [0 :2px :5px :#aaa]
|
:box-shadow [0 :2px :5px :#aaa]
|
||||||
:text-decoration :none
|
:text-decoration :none
|
||||||
@@ -41,9 +42,6 @@
|
|||||||
:text-align :center
|
:text-align :center
|
||||||
(rule "h2"
|
(rule "h2"
|
||||||
helvetica-neue))
|
helvetica-neue))
|
||||||
(rule ".article-font"
|
|
||||||
:font-family :Georgia
|
|
||||||
:font-size :1.3em)
|
|
||||||
(rule "article"
|
(rule "article"
|
||||||
:font-family :Georgia
|
:font-family :Georgia
|
||||||
:font-size :1.2em
|
:font-size :1.2em
|
||||||
@@ -58,10 +56,11 @@
|
|||||||
(rule "*:focus"
|
(rule "*:focus"
|
||||||
:outline [:0px :none :transparent])
|
:outline [:0px :none :transparent])
|
||||||
(rule "textarea"
|
(rule "textarea"
|
||||||
:width "900px"
|
page-width
|
||||||
:font-family :Courier
|
:font-family :Courier
|
||||||
:font-size :1.2em
|
:font-size :1.2em
|
||||||
:border :none
|
:border :none
|
||||||
|
; TODO: make this dynamic
|
||||||
:height :600px
|
:height :600px
|
||||||
:margin-bottom :2em)
|
:margin-bottom :2em)
|
||||||
(rule ".hidden"
|
(rule ".hidden"
|
||||||
@@ -75,7 +74,7 @@
|
|||||||
:font-size :1em
|
:font-size :1em
|
||||||
:background :white)
|
:background :white)
|
||||||
(rule ".central-body"
|
(rule ".central-body"
|
||||||
:width "900px"
|
page-width
|
||||||
:margin-top :5em
|
:margin-top :5em
|
||||||
:margin-bottom :10em
|
:margin-bottom :10em
|
||||||
:margin-left "auto"
|
:margin-left "auto"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
(:require [NoteHub.views.common :as common] [digest :as digest])
|
(:require [NoteHub.views.common :as common] [digest :as digest])
|
||||||
(:use
|
(:use
|
||||||
[NoteHub.storage :rename {get s-get set s-set} :only [set get]]
|
[NoteHub.storage :rename {get s-get set s-set} :only [set get]]
|
||||||
[noir.response :only [content-type]]
|
[noir.response :only [redirect]]
|
||||||
[clojure.string :rename {replace sreplace} :only [split replace lower-case]]
|
[clojure.string :rename {replace sreplace} :only [split replace lower-case]]
|
||||||
[noir.core :only [defpage render]]
|
[noir.core :only [defpage render]]
|
||||||
[hiccup.form]
|
[hiccup.form]
|
||||||
@@ -30,11 +30,17 @@
|
|||||||
[:div#preview-start]
|
[:div#preview-start]
|
||||||
[:article#preview.central-body]))
|
[:article#preview.central-body]))
|
||||||
|
|
||||||
|
(defn get-storage-key [year month day title]
|
||||||
|
(str "note-" (digest/md5 (str year month day title))))
|
||||||
|
|
||||||
(defpage "/:year/:month/:day/:title" {:keys [year month day title]}
|
(defpage "/:year/:month/:day/:title" {:keys [year month day title]}
|
||||||
(let [key (str "note-" (digest/md5 (str year month day title)))]
|
(let [key (get-storage-key year month day title)
|
||||||
(common/layout "TEST"
|
post (s-get key)
|
||||||
|
title (sreplace (-> post (split #"\n") first) #"[_\*#]" "")]
|
||||||
|
(common/layout title
|
||||||
[:article.central-body
|
[:article.central-body
|
||||||
(md-to-html (s-get key))])))
|
; TODO: deal with 404!
|
||||||
|
(md-to-html post)])))
|
||||||
|
|
||||||
(defpage [:post "/post-note"] {:keys [draft]}
|
(defpage [:post "/post-note"] {:keys [draft]}
|
||||||
(let [[year month day] (split (.format (java.text.SimpleDateFormat. "yyyy-MM-dd") (java.util.Date.)) #"-")
|
(let [[year month day] (split (.format (java.text.SimpleDateFormat. "yyyy-MM-dd") (java.util.Date.)) #"-")
|
||||||
@@ -43,12 +49,11 @@
|
|||||||
trim (fn [s] (apply str (drop-while #(= \- %) s)))
|
trim (fn [s] (apply str (drop-while #(= \- %) s)))
|
||||||
title-uncut (-> untrimmed-line trim reverse trim reverse)
|
title-uncut (-> untrimmed-line trim reverse trim reverse)
|
||||||
title (apply str (take max-title-length title-uncut))
|
title (apply str (take max-title-length title-uncut))
|
||||||
key (str "note-" (digest/md5 (str year month day title)))]
|
; TODO: deal with collisions!
|
||||||
|
key (get-storage-key year month day title)]
|
||||||
(do
|
(do
|
||||||
(s-set key draft)
|
(s-set key draft)
|
||||||
(render "/:year/:month/:day/:title" {:year year :month month :day day :title title}))))
|
(redirect (apply str (interpose "/" ["" year month day title]))))))
|
||||||
|
|
||||||
; Actions.
|
|
||||||
|
|
||||||
(defremote md-to-html [draft]
|
(defremote md-to-html [draft]
|
||||||
(.markdownToHtml (PegDownProcessor.) draft))
|
(.markdownToHtml (PegDownProcessor.) draft))
|
||||||
|
|||||||
Reference in New Issue
Block a user