Skip to content

Commit 26f0b88

Browse files
Merge pull request #200 from ClojureCivitas/authors
add author post listing pages
2 parents e9c587c + 4450382 commit 26f0b88

File tree

3 files changed

+94
-47
lines changed

3 files changed

+94
-47
lines changed

site/db.edn

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
{:id :kloimhardt
120120
:name "Markus Agwin Kloimwieder"
121121
:url "https://github.com/kloimhardt"
122+
:image "https://github.com/kloimhardt.png"
122123
:affiliation [:scicloj]}
123124
{:id :edwardaw
124125
:name "Edward Widjaja"
@@ -135,17 +136,22 @@
135136
:links [{:icon "github" :href "https://github.com/tombarys"}]}
136137
{:id :mattb
137138
:name "Matthias Buehlmaier"
139+
:url "https://github.com/buehlmaier"
140+
:image "https://github.com/buehlmaier.png"
138141
:affiliation [:cim]}
139142
{:id :tanvi
140143
:name "Tanvi Nagar"
141144
142145
:affiliation [:cim]}
143146
{:id :luke-zeitlin
144147
:name "Luke Zeitlin"
148+
:url "https://github.com/larzeitlin"
149+
:image "https://github.com/larzeitlin.png"
145150
:affiliation []}
146151
{:id :ludgersolbach
147152
:name "Ludger Solbach"
148153
:url "https://github.com/lsolbach"
154+
:image "https://github.com/lsolbach.png"
149155
:links [{:icon "github" :href "https://github.com/lsolbach"}]
150156
:affiliation []}
151157
{:id :bsless

src/civitas/authors.clj

Lines changed: 84 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,56 @@
11
^:kindly/hide-code
2-
^{:clay {:title "Authors"
2+
^{:clay {:title "Authors"
33
:quarto {:type :page}}}
44
(ns civitas.authors
5-
(:require [civitas.db :as db]
5+
(:require [camel-snake-kebab.core :as csk]
6+
[civitas.db :as db]
7+
[civitas.explorer.geometry :as geom]
8+
[civitas.explorer.svg :as svg]
9+
[civitas.why.village.color :as color]
10+
[clj-yaml.core :as yaml]
11+
[clojure.java.io :as io]
12+
[clojure.string :as str]
613
[scicloj.kindly.v4.kind :as kind]))
714

8-
;; You belong here!
15+
;; You belong here! Thank you for sharing your ideas.
916

10-
;; Thank you for sharing your ideas.
17+
^:kindly/hide-code
18+
(def authors (->> (:author @db/db)
19+
(sort-by :name)))
20+
21+
^:kindly/hide-code
22+
(defn authors-hexagon []
23+
(let [colors (cycle (take 11 color/palette))
24+
r 6]
25+
[:g
26+
[:g {:transform "scale(0.8)"}
27+
(for [[{:keys [image name]} [x y] color] (map vector authors (geom/spiral 100) colors)]
28+
[:a {:href (str "/" (csk/->Camel_Snake_Case name) ".html")}
29+
[:title name]
30+
[:g {:transform (str "translate(" (* r x) "," (* r y) ")")}
31+
(svg/polygon {:fill color
32+
:stroke "#5881D8"
33+
:stroke-width 1}
34+
(geom/hex r))
35+
[:image {:x -5
36+
:y -5
37+
:width 10
38+
:height 10
39+
:href image
40+
:clip-path "url(#hex)"
41+
:preserveAspectRatio "xMidYMid slice"}]]])]]))
42+
43+
^:kind/hiccup ^:kindly/hide-code
44+
[:svg
45+
{:xlmns "http://www.w3.org/2000/svg"
46+
:viewBox "-30 -30 60 60"
47+
:width "100%"}
48+
[:defs
49+
[:clipPath {:id "hex"}
50+
[:polygon {:points (str/join " "
51+
(map #(str/join "," %) (geom/hex 5)))}]]]
52+
[:text {:x -30, :y -15 :fill "#5881D8"} (str (count authors))]
53+
(authors-hexagon)]
1154

1255
^:kindly/hide-code
1356
(defn card-link [href icon text]
@@ -18,23 +61,43 @@
1861

1962
^:kindly/hide-code
2063
(defn card [{:keys [name url links affiliation image]} affiliations]
21-
(kind/hiccup
22-
[:div.card
23-
(when image [:img.card-img-top {:src image}])
24-
[:div.card-body
25-
[:h5.card-title name]
26-
[:div
27-
(when url (card-link url nil nil))
28-
(for [{:keys [href icon]} links]
29-
(card-link href icon nil))]
30-
(for [{:keys [name url]} (map affiliations affiliation)]
31-
(card-link url nil name))]]))
64+
[:tr
65+
[:td (when image [:img {:src image :width "50px"}])]
66+
[:td name]
67+
[:td (for [{:keys [name url]} (map affiliations affiliation)]
68+
(card-link url nil name))]
69+
[:td (card-link (str "/" (csk/->Camel_Snake_Case name) ".html") nil "posts")]])
3270

3371
^:kindly/hide-code
3472
(let [affiliations (db/index-by :id (:affiliation @db/db))]
35-
(into ^:kind/hiccup [:div]
36-
(comp (map #(card % affiliations))
37-
(partition-all 5)
38-
(map #(into [:div.card-group] %)))
39-
(->> (:author @db/db)
40-
(sort-by :name))))
73+
^:kind/hiccup
74+
[:table
75+
[:thead
76+
[:tr
77+
[:th ""]
78+
[:th "Name"]
79+
[:th "Affiliation"]
80+
[:th "Posts"]]]
81+
[:tbody
82+
(map #(card % affiliations)
83+
authors)]])
84+
85+
^:kindly/hide-code
86+
^:kind/hidden
87+
(doseq [author authors]
88+
(let [front-matter {:title (:name author)
89+
:about (assoc (select-keys author [:image :links])
90+
:template "trestles")
91+
:author author
92+
:listing {:contents [".", "!./*.qmd"]
93+
:include {:type :post
94+
:author (str "{" (:name author) "}" "*")}
95+
:sort ["date desc" "title desc"]
96+
:sort-ui true
97+
:filter-ui true}}]
98+
(doto (io/file "site"
99+
(str (csk/->Camel_Snake_Case (:name author)) ".qmd"))
100+
(io/make-parents)
101+
(spit (str "---\n"
102+
(yaml/generate-string front-matter)
103+
"\n---\n")))))

src/civitas/why/village/scene.clj

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
:image "preview.png"
1010
:category :collaboration
1111
:tags [:clojure :writing :workflow :motivation :community]}}}
12-
(:require [civitas.db :as db]
12+
(:require [civitas.authors :as authors]
1313
[civitas.explorer.geometry :as geom]
1414
[civitas.explorer.svg :as svg]
1515
[civitas.why.village.color :as color]
@@ -406,30 +406,6 @@
406406
(t (cylinder 1 10 6 (:sstone col)))
407407
(t (oblong-mesh 0 0 10 3 3 1 (:sstone col) "slate"))])
408408

409-
(defn authors []
410-
(let [authors (->> (:author @db/db)
411-
(sort-by :name))
412-
n (count authors)
413-
colors (cycle (take 11 color/palette))
414-
r 6]
415-
[:g
416-
[:g {:transform "translate(0,-8)"}
417-
(mu/mo (str n " authors"))]
418-
[:g {:transform "scale(0.8)"}
419-
(for [[{:keys [image]} [x y] color] (map vector authors (geom/spiral 100) colors)]
420-
[:g {:transform (str "translate(" (* r x) "," (* r y) ")")}
421-
(svg/polygon {:fill color
422-
:stroke (:dblue col)
423-
:stroke-width 1}
424-
(geom/hex r))
425-
[:image {:x -5
426-
:y -5
427-
:width 10
428-
:height 10
429-
:href image
430-
:clip-path "url(#hex)"
431-
:preserveAspectRatio "xMidYMid slice"}]])]]))
432-
433409
(defn posts []
434410
(let [r 3
435411
n 80
@@ -1278,7 +1254,9 @@ where you can view the code, or clone the repo to experiment locally."]
12781254

12791255
[{:fill (:lblue col)}
12801256
[:g {}
1281-
(authors)]
1257+
(authors/authors-hexagon)
1258+
[:g {:transform "translate(0,-8)"}
1259+
(mu/mo (str (count authors/authors) " authors"))]]
12821260
"Thank you so much to the many authors for sharing your ideas!
12831261
30 authors have contributed blog posts.
12841262
I hope that you will join us, and write your own post."]

0 commit comments

Comments
 (0)