|
1 | 1 | ^:kindly/hide-code |
2 | | -^{:clay {:title "Authors" |
| 2 | +^{:clay {:title "Authors" |
3 | 3 | :quarto {:type :page}}} |
4 | 4 | (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] |
6 | 13 | [scicloj.kindly.v4.kind :as kind])) |
7 | 14 |
|
8 | | -;; You belong here! |
| 15 | +;; You belong here! Thank you for sharing your ideas. |
9 | 16 |
|
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)] |
11 | 54 |
|
12 | 55 | ^:kindly/hide-code |
13 | 56 | (defn card-link [href icon text] |
|
18 | 61 |
|
19 | 62 | ^:kindly/hide-code |
20 | 63 | (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")]]) |
32 | 70 |
|
33 | 71 | ^:kindly/hide-code |
34 | 72 | (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"))))) |
0 commit comments