persistence to redis implemented
This commit is contained in:
@@ -51,8 +51,9 @@
|
||||
:text-align :center
|
||||
:margin :2em))
|
||||
(rule "pre"
|
||||
:border-radius :3px
|
||||
:padding :1em
|
||||
:border [:1px :dashed :gray]
|
||||
:border [:1px :dotted :gray]
|
||||
:background :#efefef)
|
||||
(rule "*:focus"
|
||||
:outline [:0px :none :transparent])
|
||||
@@ -66,10 +67,11 @@
|
||||
(rule ".hidden"
|
||||
:display :none)
|
||||
(rule ".button"
|
||||
:border-radius :3px
|
||||
helvetica-neue
|
||||
:cursor :pointer
|
||||
:border [:1px :solid]
|
||||
:opacity 0.7
|
||||
:opacity 0.8
|
||||
:font-size :1em
|
||||
:background :white)
|
||||
(rule ".central-body"
|
||||
@@ -82,7 +84,7 @@
|
||||
:font-size :2em)
|
||||
(rule "#preview-start"
|
||||
:border-bottom [:1px :dashed :gray]
|
||||
:margin-bottom :10em)
|
||||
:margin-bottom :5em)
|
||||
(rule "h1, h2, h3, h4"
|
||||
:font-family (gen-comma-list
|
||||
"'Noticia Text'" "Georgia"))))
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
(ns NoteHub.views.pages
|
||||
(:require [NoteHub.views.common :as common])
|
||||
(:require [NoteHub.views.common :as common] [digest :as digest])
|
||||
(:use
|
||||
[NoteHub.storage :rename {get s-get set s-set} :only [set get]]
|
||||
[noir.response :only [content-type]]
|
||||
[clojure.string :rename {replace sreplace} :only [trim split replace]]
|
||||
[noir.core :only [defpage]]
|
||||
[clojure.string :rename {replace sreplace} :only [split replace lower-case]]
|
||||
[noir.core :only [defpage render]]
|
||||
[hiccup.form]
|
||||
[noir.fetch.remotes])
|
||||
(:import [org.pegdown PegDownProcessor]))
|
||||
|
||||
(def max-title-length 80)
|
||||
|
||||
(defpage "/" {}
|
||||
(common/layout "Free Markdown Hosting"
|
||||
[:div#hero
|
||||
[:h1 "NoteHub"]
|
||||
[:h2 "Free hosting for markdown pages."]
|
||||
[:br]
|
||||
[:br]
|
||||
[:a.landing-button {:href "/new"} "New Page"]]))
|
||||
|
||||
(defpage "/new" {}
|
||||
(common/layout "New Markdown Note"
|
||||
[:div.central-body
|
||||
(form-to [:get "/preview-note"]
|
||||
(form-to [:post "/post-note"]
|
||||
(text-area {:class "max-width"} :draft)
|
||||
[:div#buttons.hidden
|
||||
(submit-button {:style "float: left" :class "button"} "Publish")
|
||||
@@ -28,6 +30,24 @@
|
||||
[:div#preview-start]
|
||||
[:article#preview.central-body]))
|
||||
|
||||
(defpage "/:year/:month/:day/:title" {:keys [year month day title]}
|
||||
(let [key (str "note-" (digest/md5 (str year month day title)))]
|
||||
(common/layout "TEST"
|
||||
[:article.central-body
|
||||
(md-to-html (s-get key))])))
|
||||
|
||||
(defpage [:post "/post-note"] {:keys [draft]}
|
||||
(let [[year month day] (split (.format (java.text.SimpleDateFormat. "yyyy-MM-dd") (java.util.Date.)) #"-")
|
||||
untrimmed-line (filter #(or (= \- %) (Character/isLetterOrDigit %))
|
||||
(-> draft (split #"\n") first (sreplace " " "-") lower-case))
|
||||
trim (fn [s] (apply str (drop-while #(= \- %) s)))
|
||||
title-uncut (-> untrimmed-line trim reverse trim reverse)
|
||||
title (apply str (take max-title-length title-uncut))
|
||||
key (str "note-" (digest/md5 (str year month day title)))]
|
||||
(do
|
||||
(s-set key draft)
|
||||
(render "/:year/:month/:day/:title" {:year year :month month :day day :title title}))))
|
||||
|
||||
; Actions.
|
||||
|
||||
(defremote md-to-html [draft]
|
||||
|
||||
Reference in New Issue
Block a user