Add parsing of posts. Need to look into the security of read-string.
This commit is contained in:
parent
8ad5be6cc2
commit
a07bfbd98c
|
@ -5,7 +5,6 @@
|
||||||
(def post-filename "post.json")
|
(def post-filename "post.json")
|
||||||
(def base-path "resources/posts")
|
(def base-path "resources/posts")
|
||||||
|
|
||||||
|
|
||||||
(defn create-path-by-date [year month day]
|
(defn create-path-by-date [year month day]
|
||||||
{:year year :month month :day day})
|
{:year year :month month :day day})
|
||||||
|
|
||||||
|
@ -29,3 +28,10 @@
|
||||||
(clojure.java.io/make-parents final-path)
|
(clojure.java.io/make-parents final-path)
|
||||||
(spit final-path post)))
|
(spit final-path post)))
|
||||||
|
|
||||||
|
(defn read-post [dt-path n]
|
||||||
|
(let [path (format "%s/%s/%d/%s" base-path (pathmap-to-path dt-path) n post-filename)
|
||||||
|
f (clojure.java.io/file path)]
|
||||||
|
(when (.exists f)
|
||||||
|
(-> f
|
||||||
|
slurp
|
||||||
|
read-string))))
|
||||||
|
|
Loading…
Reference in New Issue