Add parsing of posts. Need to look into the security of read-string.
This commit is contained in:
parent
8ad5be6cc2
commit
a07bfbd98c
|
@ -15,4 +15,4 @@
|
|||
(assoc-in post [:properties :name] post-name))
|
||||
|
||||
(defn set-content [post post-content]
|
||||
(assoc-in post [:properties :content] post-content))
|
||||
(assoc-in post [:properties :content] post-content))
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
(ns shapey-shifty.posts.posts-io
|
||||
(:require
|
||||
[shapey-shifty.posts.core :as core]))
|
||||
[shapey-shifty.posts.core :as core]))
|
||||
|
||||
(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))))
|
||||
|
|
Loading…
Reference in New Issue