add load-clj and load-json functions (based on load-config)
This commit is contained in:
parent
72b277439d
commit
88ce5616e0
|
@ -13,7 +13,8 @@
|
|||
[com.ashafa/clutch "0.4.0-RC1"]
|
||||
[slugger "1.0.1"]
|
||||
[clj-time "0.5.0"]
|
||||
[org.clojure/math.numeric-tower "0.0.2"]]
|
||||
[org.clojure/math.numeric-tower "0.0.2"]
|
||||
[cheshire "5.1.2"]]
|
||||
:plugins [[lein-ring "0.8.5"]]
|
||||
:ring {:handler blarg.handler/war-handler
|
||||
:init blarg.handler/init
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
(ns blarg.config
|
||||
(:use [blarg.util])
|
||||
(:require [clojure.java.io :as io])
|
||||
(:import [java.io PushbackReader]))
|
||||
|
||||
(def site-config (atom nil))
|
||||
|
||||
(defn load-config []
|
||||
(with-open [r (PushbackReader. (io/reader (io/resource "site.config")))]
|
||||
(read r)))
|
||||
(load-clj "site.config"))
|
||||
|
||||
(defn get-config
|
||||
"returns the entire site configuration"
|
||||
|
|
|
@ -1,12 +1,27 @@
|
|||
(ns blarg.util
|
||||
(:require [noir.io :as io]
|
||||
[markdown.core :as md]))
|
||||
(:require [clojure.java.io :as io]
|
||||
[markdown.core :as md]
|
||||
[noir.io]
|
||||
[cheshire.core :refer :all])
|
||||
(:import [java.io PushbackReader]))
|
||||
|
||||
(defn load-clj
|
||||
"loads a file from the resources directory, parses and returns it as clojure"
|
||||
[file]
|
||||
(with-open [r (PushbackReader. (io/reader (io/resource file)))]
|
||||
(read r)))
|
||||
|
||||
(defn load-json
|
||||
"loads a file from the resources directory, parses it as JSON and returns it
|
||||
as an equivalent clojure object"
|
||||
[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]
|
||||
(->>
|
||||
(io/slurp-resource filename)
|
||||
(noir.io/slurp-resource filename)
|
||||
(md/md-to-html-string)))
|
||||
|
||||
(defn string->int
|
||||
|
|
Reference in a new issue