Add basic pipeline plumbing
This commit is contained in:
parent
ef6922ab83
commit
eea6a1e858
|
@ -18,3 +18,4 @@ profiles.clj
|
||||||
resources/posts/
|
resources/posts/
|
||||||
/resources/author/
|
/resources/author/
|
||||||
resources/index/
|
resources/index/
|
||||||
|
.eastwood
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(ns shapey-shifty.index.index
|
(ns shapey-shifty.index.index
|
||||||
(:require [clucy.core :as clucy]
|
(:require [clucy.core :as clucy]
|
||||||
[shapey-shifty.posts.posts-io :as post-io]
|
[shapey-shifty.posts.posts-io :as post-io]))
|
||||||
))
|
|
||||||
|
|
||||||
(def index-path (atom "resources/index"))
|
(def index-path (atom "resources/index"))
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
(ns shapey-shifty.pipeline.core)
|
||||||
|
|
||||||
|
(def pipelines (atom {:load-post []
|
||||||
|
:render-post []
|
||||||
|
:write-post []}))
|
||||||
|
|
||||||
|
(defn update-pipeline [k f]
|
||||||
|
(swap! pipelines #(update % k conj f)))
|
||||||
|
|
||||||
|
(defn add-load-post-step [f]
|
||||||
|
(update-pipeline :load-post f))
|
||||||
|
|
||||||
|
(defn add-render-post-step [f]
|
||||||
|
(update-pipeline :render-post f))
|
||||||
|
|
||||||
|
(defn add-write-post-step [f]
|
||||||
|
(update-pipeline :write-post f))
|
||||||
|
|
||||||
|
(defn execute-pipeline [k params]
|
||||||
|
(let [p (k @pipelines)]
|
||||||
|
((apply comp p) params)))
|
||||||
|
|
||||||
|
(defn add-pipeline [k v]
|
||||||
|
(swap! pipelines #(assoc % k v)))
|
|
@ -2,7 +2,7 @@
|
||||||
(:require
|
(:require
|
||||||
[shapey-shifty.layout :as layout]
|
[shapey-shifty.layout :as layout]
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[shapey-shifty.middleware :as middleware]
|
[shapey-shifty.middleware :as mid]
|
||||||
[ring.util.response]
|
[ring.util.response]
|
||||||
[shapey-shifty.posts.core :as posts]
|
[shapey-shifty.posts.core :as posts]
|
||||||
[shapey-shifty.posts.posts-io :as post-io]
|
[shapey-shifty.posts.posts-io :as post-io]
|
||||||
|
@ -10,12 +10,11 @@
|
||||||
[shapey-shifty.authors.author-core :as author]
|
[shapey-shifty.authors.author-core :as author]
|
||||||
[ring.util.http-response :as response]))
|
[ring.util.http-response :as response]))
|
||||||
|
|
||||||
|
(def middleware (atom [mid/wrap-csrf mid/wrap-formats]))
|
||||||
|
|
||||||
(defn home-page [request]
|
(defn home-page [request]
|
||||||
(layout/render request "home.html" {:docs (-> "docs/docs.md" io/resource slurp)}))
|
(layout/render request "home.html" {:docs (-> "docs/docs.md" io/resource slurp)}))
|
||||||
|
|
||||||
(defn test-view [request]
|
|
||||||
(layout/render request "post.html" {:post (-> (posts/create-empty-post) (posts/set-content "Hey there everyone!") (posts/set-name "Yolo") :properties)}))
|
|
||||||
|
|
||||||
(defn post-view [request]
|
(defn post-view [request]
|
||||||
(let [{:keys [path-params query-params body-params]} request
|
(let [{:keys [path-params query-params body-params]} request
|
||||||
{:keys [year month day n]} path-params
|
{:keys [year month day n]} path-params
|
||||||
|
@ -25,15 +24,12 @@
|
||||||
|
|
||||||
(defn about-page [request]
|
(defn about-page [request]
|
||||||
(layout/render request "h_card.html"
|
(layout/render request "h_card.html"
|
||||||
{
|
{:card (:card (author/load-author (get-in request [:path-params :name])))}))
|
||||||
:card (:card (author/load-author (get-in request [:path-params :name])))
|
|
||||||
}))
|
|
||||||
|
|
||||||
(defn home-routes []
|
(defn home-routes []
|
||||||
[""
|
[""
|
||||||
{:middleware [middleware/wrap-csrf
|
{:middleware @middleware}
|
||||||
middleware/wrap-formats]}
|
|
||||||
["/" {:get home-page}]
|
["/" {:get home-page}]
|
||||||
["/blog/:year/:month/:day/:n" {:get post-view}]
|
["/about/:name" {:get about-page}]
|
||||||
["/about/:name" {:get about-page}]])
|
["/:year/:month/:day/:n" {:get post-view}]])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue