-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.boot
64 lines (57 loc) · 2.17 KB
/
build.boot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(set-env!
:source-paths #{"src" "content" "styles"}
:resource-paths #{"resources"}
:dependencies '[[perun "0.4.2-SNAPSHOT" :scope "test"]
[pandeiro/boot-http "0.8.1" :scope "test"]
[deraen/boot-sass "0.3.1" :scope "test"]
[hiccup "1.0.5"]
[clj-time "0.14.0"]])
(require '[boot.pod :as pod]
'[io.perun :as p]
'[pandeiro.boot-http :refer [serve]]
'[deraen.boot-sass :refer [sass]])
(defn- create-pod [deps]
(-> (get-env)
(update-in [:dependencies] into deps)
pod/make-pod
future))
(def highlight-deps
'[[org.clojure/tools.namespace "0.3.0-alpha3"]
[enlive "1.1.5"]
[clygments "1.0.0"]])
(def highlight-defaults
{:filterer identity
:extensions [".html"]})
(deftask highlight
[_ filterer FILTER code "predicate to use for selecting entries (default: `identity`)"
e extensions EXTENSIONS [str] "extensions of files to include"]
(let [pod (create-pod highlight-deps)
options (merge highlight-defaults *opts*)]
(p/content-task
{:render-form-fn (fn [data] `(tech.jstaffans.highlight/highlight-code-blocks ~data))
:paths-fn #(p/content-paths % options)
:passthru-fn p/content-passthru
:task-name "highlight"
:tracer :tech.jstaffans/highlight
:pod pod})))
(deftask build
[]
(let [post? (fn [{:keys [path]}] (.startsWith path "public/posts"))
page? (fn [{:keys [path]}] (.startsWith path "public/pages"))
clojure-post? (fn [{:keys [tags] :as entry}]
(and (post? entry) (some #{"clojure"} tags)))]
(comp (sass)
(sift :move {#"main.css" "public/styles/main.css"})
(p/global-metadata)
(p/markdown)
(highlight)
(p/collection :renderer 'tech.jstaffans.core/index :filterer post? :sortby :date-published)
(p/render :renderer 'tech.jstaffans.core/post :filterer post?)
(p/render :renderer 'tech.jstaffans.core/page :filterer page?)
(p/atom-feed :filterer post?)
(p/atom-feed :filename "feed_clojure.xml" :filterer clojure-post?))))
(deftask dev
[]
(comp (serve :resource-root "public" :port 4000)
(watch)
(build)))