translating MD on the server side now
This commit is contained in:
@@ -4,6 +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"]
|
||||||
[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"]
|
||||||
|
|||||||
@@ -39,14 +39,6 @@ function onLoad() {
|
|||||||
if(iosDetected) $note.className += " ui-border"; else $note.focus();
|
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");
|
var links = $("links");
|
||||||
if(links){
|
if(links){
|
||||||
if(window.innerHeight * 0.85 >= document.body.clientHeight) {
|
if(window.innerHeight * 0.85 >= document.body.clientHeight) {
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ textarea {
|
|||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
height: 500px;
|
height: 500px;
|
||||||
}
|
}
|
||||||
.hidden, .markdown, #links {
|
.hidden, #links {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#dashed-line {
|
#dashed-line {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
[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]
|
||||||
@@ -48,7 +49,7 @@
|
|||||||
|
|
||||||
(defroutes app-routes
|
(defroutes app-routes
|
||||||
(GET "/api" [] (layout (get-message :api-title)
|
(GET "/api" [] (layout (get-message :api-title)
|
||||||
(md-node :article (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"))
|
||||||
|
|||||||
+5
-12
@@ -9,6 +9,7 @@
|
|||||||
[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]))
|
||||||
|
|
||||||
(def get-message (get-map "messages"))
|
(def get-message (get-map "messages"))
|
||||||
@@ -32,14 +33,6 @@
|
|||||||
(if-not (get-setting :dev-mode) (include-js "/js/google-analytics.js"))]
|
(if-not (get-setting :dev-mode) (include-js "/js/google-analytics.js"))]
|
||||||
[:body {:onload "onLoad()"} content]))
|
[: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
|
(defn- sanitize
|
||||||
"Breakes all usages of <script> & <iframe>"
|
"Breakes all usages of <script> & <iframe>"
|
||||||
[input]
|
[input]
|
||||||
@@ -72,10 +65,10 @@
|
|||||||
[:br]
|
[:br]
|
||||||
[:a.landing-button {:href "/new" :style "color: white"} (get-message :new-page)]]
|
[:a.landing-button {:href "/new" :style "color: white"} (get-message :new-page)]]
|
||||||
[:div#dashed-line]
|
[:div#dashed-line]
|
||||||
(md-node :article.helvetica.bottom-space
|
[:article.helvetica.bottom-space
|
||||||
{:style "font-size: 1em"}
|
{:style "font-size: 1em"}
|
||||||
(slurp "LANDING.md"))
|
(md/to-html (slurp "LANDING.md"))]
|
||||||
(md-node :div.centered.helvetica (get-message :footer))))
|
[:div.centered.helvetica (md/to-html (get-message :footer))]))
|
||||||
|
|
||||||
|
|
||||||
(defn statistics-page [resp]
|
(defn statistics-page [resp]
|
||||||
@@ -109,7 +102,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 (:title 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)
|
(let [urls {:short-url (api/url short-url)
|
||||||
:notehub "/"}
|
:notehub "/"}
|
||||||
links (map #(link-to
|
links (map #(link-to
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
:signature (sign session-key test-note)})]
|
:signature (sign session-key test-note)})]
|
||||||
(is (has-status resp 302))
|
(is (has-status resp 302))
|
||||||
(is (note-exists? (build-key date title)))
|
(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)))
|
((send-request (url year month day title)) :body)))
|
||||||
(is (do
|
(is (do
|
||||||
(delete-note (build-key date title))
|
(delete-note (build-key date title))
|
||||||
|
|||||||
Reference in New Issue
Block a user