A pastebin for markdown pages.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.0 KiB

14 years ago
(ns NoteHub.views.pages
(:require [NoteHub.views.common :as common])
(:use
[clojure.string :rename {replace sreplace} :only [trim split replace]]
[noir.core :only [defpage]]
[hiccup.form])
(:import [org.pegdown PegDownProcessor]))
14 years ago
(defpage "/" {}
(common/layout "Free Markdown Hosting"
14 years ago
[:div#hero
[:h1 "NoteHub"]
[:h2 "Free hosting for markdown pages."]
[:br]
[:br]
[:a.button {:href "/new"} "New Page"]]))
(defpage "/new" {}
(common/layout "New Markdown Note"
[:div.central-body
(form-to [:post "/preview-note"]
(text-area {:class "max-width"} :draft)
(submit-button {:id "preview-button"} "Preview"))]))
14 years ago
; Actions.
(defpage [:post "/preview-note"] {:keys [draft]}
(let [get-title (comp trim #(sreplace % "#" "") first #(split % #"\n"))]
(common/layout (get-title draft)
[:article.central-body
(.markdownToHtml (PegDownProcessor.) draft)])))