Add parsing of posts. Need to look into the security of read-string.

This commit is contained in:
Charlotte Allen 2020-01-27 19:16:48 -08:00
parent 8ad5be6cc2
commit a07bfbd98c
No known key found for this signature in database
GPG Key ID: 3A64C3A6C69860B0
2 changed files with 13 additions and 7 deletions

View File

@ -5,7 +5,6 @@
(def post-filename "post.json")
(def base-path "resources/posts")
(defn create-path-by-date [year month day]
{:year year :month month :day day})
@ -29,3 +28,10 @@
(clojure.java.io/make-parents final-path)
(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))))