-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgen.clj
More file actions
executable file
·158 lines (122 loc) · 4.4 KB
/
gen.clj
File metadata and controls
executable file
·158 lines (122 loc) · 4.4 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env bb
(require '[babashka.classpath :refer [add-classpath]])
(add-classpath ".")
(require '[clojure.java.shell :refer [sh]]
'[clojure.java.io :as io]
'[site.index :as idx]
'[site.blog :as blog]
'[site.about :as about]
'[site.blog.clg :as clg]
'[site.blog.rain :as rain]
'[site.blog.bb :as bb]
'[tools.generate :as gen])
;;;;;;;;;;;;;;;;;;;;;;;;;;
;; STANDARD PAGE ITEMS ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn head [{:keys [title path2root]}]
[:head
[:title title]
[:meta {:charset "utf-8"}]
[:link {:rel "stylesheet" :href (str path2root "/remedy.css")}]
[:link {:rel "stylesheet" :href (str path2root "/styles.css")}]])
(defn header [{:keys [path2root]}]
[:header
[:a {:class "mxmmz"
:href (str path2root "/about.html")}
[:span "M"]
[:span {:class "hide"} "-"]
[:span "x"]
[:span {:class "spaceleft"} "MM"]
[:span {:class "subscript"} "z"]]])
(defn nav [{:keys [path2root]}]
[:nav
[:p
(gen/a (str path2root "/index.html") "Home")
(gen/a (str path2root "/blog.html") "Blog")
(gen/a (str path2root "/about.html") "About")]
[:hr]])
(def footer
[:footer
[:hr]
[:p
(gen/a "https://github.com/mmzsource" "Github")
(gen/a "https://www.linkedin.com/in/maartenmetz/" "LinkedIn")
(gen/a "https://twitter.com/mmz_" "Twitter")]])
;; left sidebar (used on large screen)
(def sidel
[:div {:class "sidel"}])
;; right sidebar (used on large screens)
(def sider
[:div {:class "sider"}])
;;;;;;;;;;;;;;;;;;;;
;; CONSTRUCT PAGE ;;
;;;;;;;;;;;;;;;;;;;;
(defn wrap [body m]
(str "<!DOCTYPE html>\n"
(gen/html [:html
(head m)
(header m)
(nav m)
sidel
[:main [:article body]]
sider
footer])))
;;;;;;;;;;;;;
;; PUBLISH ;;
;;;;;;;;;;;;;
(defn clean-publish-directories! []
(sh "rm" "publish/index.html" "publish/blog.html" "publish/about.html")
(sh "rm" "publish/remedy.css" "publish/styles.css")
(sh "rm" "-rf" "publish/blog"))
(defn make-publish-directories! []
(sh "mkdir" "-p" "publish/blog/matrixrain-img/")
(sh "mkdir" "-p" "publish/blog/babashka-img/"))
;; Do NOT remove the publish directory.
;; It contains the .git info for the gh-pages branch
;; and the CNAME file
(defn prepare-publish-directories! []
(if (.exists (io/file "publish"))
(do
(clean-publish-directories!)
(make-publish-directories!))
(do
;; First time setup
(sh "mkdir" "publish")
(make-publish-directories!))))
(defn copy-css! []
(sh "cp" "site/remedy.css" "publish/remedy.css")
(sh "cp" "site/styles.css" "publish/styles.css"))
(defn publish-main-pages! []
(let [index (wrap (idx/body) {:title "MxMMz Home" :path2root "."})
blog (wrap (blog/body) {:title "Blog" :path2root "."})
about (wrap (about/body) {:title "About" :path2root "."})]
(spit "publish/index.html" index)
(spit "publish/blog.html" blog)
(spit "publish/about.html" about)))
(defn publish-blog-pages! []
(let [clg (wrap (clg/body)
{:title "Clojure Learning Guide"
:path2root ".."})
rain (wrap (rain/body)
{:title "Matrix Rain"
:path2root ".."})
bb (wrap (bb/body)
{:title "Building a Website with Babashka"
:path2root ".."})]
;; Spit Clojure(Script) learning guide page
(spit "publish/blog/clojure-learning-guide.html" clg)
; Spit MatrixRain page (includes generated js)
(sh "cp" "-r" "site/blog/matrixrain-js" "publish/blog/")
(sh "cp" "site/blog/matrixrain-img/matrix.png" "publish/blog/matrixrain-img/")
(sh "cp" "site/blog/matrixrain-img/raindrop-short.png" "publish/blog/matrixrain-img/")
(spit "publish/blog/matrix-rain-in-clojurescript.html" rain)
; Spit babashka page
(sh "cp" "site/blog/babashka-img/babashka.svg" "publish/blog/babashka-img/")
(sh "cp" "site/blog/babashka-img/dependencies-tweet-gary-bernhardt.png" "publish/blog/babashka-img/")
(sh "cp" "site/blog/babashka-img/mxmmz-tree.png" "publish/blog/babashka-img/")
(spit "publish/blog/building-a-website-with-babashka.html" bb)))
(do
(prepare-publish-directories!)
(copy-css!)
(publish-main-pages!)
(publish-blog-pages!))