refactor markdown rendering functions

This commit is contained in:
Gered 2014-03-29 08:51:25 -04:00
parent 1999482b16
commit 82923bc171
3 changed files with 9 additions and 13 deletions

View file

@ -1,13 +1,13 @@
(ns blarg.routes.rss
(:use [blarg.routes.helpers]
[compojure.core])
(:require [markdown.core :as md]
[noir.response :refer [xml]]
(:require [noir.response :refer [xml]]
[clj-rss.core :as rss]
[clj-time.core]
[clj-time.coerce]
[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-site-url "http://www.blarg.ca/")
@ -25,7 +25,7 @@
{:title (:title post)
:pubDate (clj-time.coerce/to-date (:created_at post))
: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))))))
(register-routes rss-routes

View file

@ -19,12 +19,8 @@
[file]
(parse-stream (io/reader (io/resource file)) true))
(defn md->html
"reads a markdown file from public/md and returns an HTML string"
[filename]
(->>
(noir.io/slurp-resource filename)
(md/md-to-html-string)))
(defn md->html [s]
(md/md-to-html-string s))
(defn string->int
([s] (string->int s nil))

View file

@ -2,12 +2,12 @@
(:use [blarg.datetime]
[blarg.routes.helpers])
(:require [clj-jtwig.functions :refer [deftwigfn]]
[markdown.core :as md]
[clj-time.core]
[clj-time.format]))
[clj-time.format]
[blarg.util :refer [md->html]]))
(deftwigfn "md_to_html" [s]
(md/md-to-html-string s))
(md->html s))
(deftwigfn "post_url" [post]
(->> post