Browse Source

title extraction added to preview

master
Christian Mueller 14 years ago
parent
commit
1ad381cfee
  1. 5
      src/NoteHub/views/common.clj
  2. 11
      src/NoteHub/views/pages.clj

5
src/NoteHub/views/common.clj

@ -46,7 +46,10 @@
:font-size :1.3em) :font-size :1.3em)
(rule "article" (rule "article"
:font-family :Georgia :font-family :Georgia
:font-size :1.2em) :font-size :1.2em
(rule "& > h1:first-child"
:text-align :center
:margin :2em))
(rule "*:focus" (rule "*:focus"
:outline [:0px :none :transparent]) :outline [:0px :none :transparent])
(rule "textarea" (rule "textarea"

11
src/NoteHub/views/pages.clj

@ -1,6 +1,8 @@
(ns NoteHub.views.pages (ns NoteHub.views.pages
(:require [NoteHub.views.common :as common]) (:require [NoteHub.views.common :as common])
(:use [noir.core :only [defpage]] (:use
[clojure.string :rename {replace sreplace} :only [trim split replace]]
[noir.core :only [defpage]]
[hiccup.form]) [hiccup.form])
(:import [org.pegdown PegDownProcessor])) (:import [org.pegdown PegDownProcessor]))
@ -23,6 +25,7 @@
; Actions. ; Actions.
(defpage [:post "/preview-note"] {:keys [draft]} (defpage [:post "/preview-note"] {:keys [draft]}
(common/layout "Preview of ..." (let [get-title (comp trim #(sreplace % "#" "") first #(split % #"\n"))]
[:article.central-body (common/layout (get-title draft)
(.markdownToHtml (PegDownProcessor.) draft)])) [:article.central-body
(.markdownToHtml (PegDownProcessor.) draft)])))

Loading…
Cancel
Save