translating MD on the server side now
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
[org.clojure/core.cache "0.6.3"]
|
||||
[hiccup "1.0.0"]
|
||||
[zeus "0.1.0"]
|
||||
[me.raynes/cegdown "0.1.1"]
|
||||
[iokv "0.1.1"]
|
||||
[cheshire "5.3.1"]
|
||||
[ring/ring-core "1.2.0"]
|
||||
|
||||
@@ -39,14 +39,6 @@ function onLoad() {
|
||||
if(iosDetected) $note.className += " ui-border"; else $note.focus();
|
||||
}
|
||||
|
||||
var mdDocs = document.getElementsByClassName("markdown");
|
||||
for(var i = 0; i < mdDocs.length; i++){
|
||||
var elem = mdDocs[i];
|
||||
var child = elem.childNodes[0];
|
||||
elem.innerHTML = md2html(child.value);
|
||||
show(elem);
|
||||
}
|
||||
|
||||
var links = $("links");
|
||||
if(links){
|
||||
if(window.innerHeight * 0.85 >= document.body.clientHeight) {
|
||||
|
||||
@@ -158,7 +158,7 @@ textarea {
|
||||
font-size: 1em;
|
||||
height: 500px;
|
||||
}
|
||||
.hidden, .markdown, #links {
|
||||
.hidden, #links {
|
||||
display: none;
|
||||
}
|
||||
#dashed-line {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
[clojure.string :rename {replace sreplace} :only [replace]]
|
||||
[clojure.core.incubator :only [-?>]])
|
||||
(:require
|
||||
[me.raynes.cegdown :as md]
|
||||
[clojure.core.cache :as cache]
|
||||
[hiccup.util :as util]
|
||||
[compojure.handler :as handler]
|
||||
@@ -48,7 +49,7 @@
|
||||
|
||||
(defroutes app-routes
|
||||
(GET "/api" [] (layout (get-message :api-title)
|
||||
(md-node :article (slurp "API.md"))))
|
||||
[:article (md/to-html (slurp "API.md"))]))
|
||||
|
||||
(context "/api" []
|
||||
#(ring.util.response/content-type (api-routes %) "application/json"))
|
||||
|
||||
+5
-12
@@ -9,6 +9,7 @@
|
||||
[hiccup.util :only [escape-html]]
|
||||
[hiccup.page :only [include-js html5]])
|
||||
(:require
|
||||
[me.raynes.cegdown :as md]
|
||||
[notehub.api :as api]))
|
||||
|
||||
(def get-message (get-map "messages"))
|
||||
@@ -32,14 +33,6 @@
|
||||
(if-not (get-setting :dev-mode) (include-js "/js/google-analytics.js"))]
|
||||
[:body {:onload "onLoad()"} content]))
|
||||
|
||||
(defn md-node
|
||||
"Returns an HTML element with a textarea inside
|
||||
containing the markdown text (to keep all chars unescaped)"
|
||||
([cls input] (md-node cls {} input))
|
||||
([cls opts input]
|
||||
[(keyword (str (name cls) ".markdown")) opts
|
||||
[:textarea input]]))
|
||||
|
||||
(defn- sanitize
|
||||
"Breakes all usages of <script> & <iframe>"
|
||||
[input]
|
||||
@@ -72,10 +65,10 @@
|
||||
[:br]
|
||||
[:a.landing-button {:href "/new" :style "color: white"} (get-message :new-page)]]
|
||||
[:div#dashed-line]
|
||||
(md-node :article.helvetica.bottom-space
|
||||
[:article.helvetica.bottom-space
|
||||
{:style "font-size: 1em"}
|
||||
(slurp "LANDING.md"))
|
||||
(md-node :div.centered.helvetica (get-message :footer))))
|
||||
(md/to-html (slurp "LANDING.md"))]
|
||||
[:div.centered.helvetica (md/to-html (get-message :footer))]))
|
||||
|
||||
|
||||
(defn statistics-page [resp]
|
||||
@@ -109,7 +102,7 @@
|
||||
(let [note (api/get-note {:noteID note-id})
|
||||
sanitized-note (sanitize (:note note))]
|
||||
(layout (:title note)
|
||||
(md-node :article.bottom-space sanitized-note)
|
||||
[:article.bottom-space (md/to-html sanitized-note)]
|
||||
(let [urls {:short-url (api/url short-url)
|
||||
:notehub "/"}
|
||||
links (map #(link-to
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
:signature (sign session-key test-note)})]
|
||||
(is (has-status resp 302))
|
||||
(is (note-exists? (build-key date title)))
|
||||
(is (substring? "Hello _world_"
|
||||
(is (substring? "Hello <em>world</em>"
|
||||
((send-request (url year month day title)) :body)))
|
||||
(is (do
|
||||
(delete-note (build-key date title))
|
||||
|
||||
Reference in New Issue
Block a user