Browse Source

switched to PegDown directly

master
Christian Mueller 12 years ago
parent
commit
b47c013b28
  1. 2
      project.clj
  2. 1
      resources/public/styles/main.less
  3. 3
      src/notehub/handler.clj
  4. 16
      src/notehub/views.clj

2
project.clj

@ -4,7 +4,7 @@
[org.clojure/core.cache "0.6.3"] [org.clojure/core.cache "0.6.3"]
[hiccup "1.0.0"] [hiccup "1.0.0"]
[zeus "0.1.0"] [zeus "0.1.0"]
[me.raynes/cegdown "0.1.1"] [org.pegdown/pegdown "1.4.2"]
[iokv "0.1.1"] [iokv "0.1.1"]
[cheshire "5.3.1"] [cheshire "5.3.1"]
[ring/ring-core "1.2.0"] [ring/ring-core "1.2.0"]

1
resources/public/styles/main.less

@ -170,6 +170,7 @@ h1, h2, h3, h4, h5, h6 {
font-family: @header_font,'Noticia Text','PT Serif','Georgia'; font-family: @header_font,'Noticia Text','PT Serif','Georgia';
} }
table { table {
width: 100%;
border-collapse: collapse; border-collapse: collapse;
} }
th { th {

3
src/notehub/handler.clj

@ -6,7 +6,6 @@
[clojure.string :rename {replace sreplace} :only [replace]] [clojure.string :rename {replace sreplace} :only [replace]]
[clojure.core.incubator :only [-?>]]) [clojure.core.incubator :only [-?>]])
(:require (:require
[me.raynes.cegdown :as md]
[clojure.core.cache :as cache] [clojure.core.cache :as cache]
[hiccup.util :as util] [hiccup.util :as util]
[compojure.handler :as handler] [compojure.handler :as handler]
@ -49,7 +48,7 @@
(defroutes app-routes (defroutes app-routes
(GET "/api" [] (layout :no-js (get-message :api-title) (GET "/api" [] (layout :no-js (get-message :api-title)
[:article (md/to-html (slurp "API.md"))])) [:article (md-to-html (slurp "API.md"))]))
(context "/api" [] (context "/api" []
#(ring.util.response/content-type (api-routes %) "application/json")) #(ring.util.response/content-type (api-routes %) "application/json"))

16
src/notehub/views.clj

@ -9,11 +9,17 @@
[hiccup.util :only [escape-html]] [hiccup.util :only [escape-html]]
[hiccup.page :only [include-js html5]]) [hiccup.page :only [include-js html5]])
(:require (:require
[me.raynes.cegdown :as md] [notehub.api :as api])
[notehub.api :as api])) (:import (org.pegdown PegDownProcessor Extensions)))
(def get-message (get-map "messages")) (def get-message (get-map "messages"))
(def md-processor
(PegDownProcessor. Extensions/TABLES))
(defn md-to-html [md-text]
(.markdownToHtml md-processor md-text))
; Creates the main html layout ; Creates the main html layout
(defn layout (defn layout
[js? title & content] [js? title & content]
@ -69,8 +75,8 @@
[:div#dashed-line] [:div#dashed-line]
[:article.helvetica.bottom-space [:article.helvetica.bottom-space
{:style "font-size: 1em"} {:style "font-size: 1em"}
(md/to-html (slurp "LANDING.md"))] (md-to-html (slurp "LANDING.md"))]
[:div.centered.helvetica (md/to-html (get-message :footer))])) [:div.centered.helvetica (md-to-html (get-message :footer))]))
(defn statistics-page [resp] (defn statistics-page [resp]
@ -104,7 +110,7 @@
(let [note (api/get-note {:noteID note-id}) (let [note (api/get-note {:noteID note-id})
sanitized-note (sanitize (:note note))] sanitized-note (sanitize (:note note))]
(layout :no-js (:title note) (layout :no-js (:title note)
[:article.bottom-space (md/to-html sanitized-note)] [:article.bottom-space (md-to-html sanitized-note)]
(let [urls {:short-url (api/url short-url) (let [urls {:short-url (api/url short-url)
:notehub "/"} :notehub "/"}
links (map #(link-to links (map #(link-to

Loading…
Cancel
Save