refactor markdown rendering functions
This commit is contained in:
parent
1999482b16
commit
82923bc171
|
@ -1,13 +1,13 @@
|
||||||
(ns blarg.routes.rss
|
(ns blarg.routes.rss
|
||||||
(:use [blarg.routes.helpers]
|
(:use [blarg.routes.helpers]
|
||||||
[compojure.core])
|
[compojure.core])
|
||||||
(:require [markdown.core :as md]
|
(:require [noir.response :refer [xml]]
|
||||||
[noir.response :refer [xml]]
|
|
||||||
[clj-rss.core :as rss]
|
[clj-rss.core :as rss]
|
||||||
[clj-time.core]
|
[clj-time.core]
|
||||||
[clj-time.coerce]
|
[clj-time.coerce]
|
||||||
[blarg.models.posts :as posts]
|
[blarg.models.posts :as posts]
|
||||||
[blarg.route-utils :refer [register-routes]]))
|
[blarg.route-utils :refer [register-routes]]
|
||||||
|
[blarg.util :refer [md->html]]))
|
||||||
|
|
||||||
(def rss-title "blarg.ca")
|
(def rss-title "blarg.ca")
|
||||||
(def rss-site-url "http://www.blarg.ca/")
|
(def rss-site-url "http://www.blarg.ca/")
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
{:title (:title post)
|
{:title (:title post)
|
||||||
:pubDate (clj-time.coerce/to-date (:created_at post))
|
:pubDate (clj-time.coerce/to-date (:created_at post))
|
||||||
:link (str rss-site-url (subs (get-post-url post) 1))
|
:link (str rss-site-url (subs (get-post-url post) 1))
|
||||||
:description (md/md-to-html-string (:body post))}))
|
:description (md->html (:body post))}))
|
||||||
(doall))))))
|
(doall))))))
|
||||||
|
|
||||||
(register-routes rss-routes
|
(register-routes rss-routes
|
||||||
|
|
|
@ -19,12 +19,8 @@
|
||||||
[file]
|
[file]
|
||||||
(parse-stream (io/reader (io/resource file)) true))
|
(parse-stream (io/reader (io/resource file)) true))
|
||||||
|
|
||||||
(defn md->html
|
(defn md->html [s]
|
||||||
"reads a markdown file from public/md and returns an HTML string"
|
(md/md-to-html-string s))
|
||||||
[filename]
|
|
||||||
(->>
|
|
||||||
(noir.io/slurp-resource filename)
|
|
||||||
(md/md-to-html-string)))
|
|
||||||
|
|
||||||
(defn string->int
|
(defn string->int
|
||||||
([s] (string->int s nil))
|
([s] (string->int s nil))
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
(:use [blarg.datetime]
|
(:use [blarg.datetime]
|
||||||
[blarg.routes.helpers])
|
[blarg.routes.helpers])
|
||||||
(:require [clj-jtwig.functions :refer [deftwigfn]]
|
(:require [clj-jtwig.functions :refer [deftwigfn]]
|
||||||
[markdown.core :as md]
|
|
||||||
[clj-time.core]
|
[clj-time.core]
|
||||||
[clj-time.format]))
|
[clj-time.format]
|
||||||
|
[blarg.util :refer [md->html]]))
|
||||||
|
|
||||||
(deftwigfn "md_to_html" [s]
|
(deftwigfn "md_to_html" [s]
|
||||||
(md/md-to-html-string s))
|
(md->html s))
|
||||||
|
|
||||||
(deftwigfn "post_url" [post]
|
(deftwigfn "post_url" [post]
|
||||||
(->> post
|
(->> post
|
||||||
|
|
Reference in a new issue