Skip to content

Commit db58156

Browse files
move db to civitas root
1 parent 8a4f055 commit db58156

8 files changed

Lines changed: 49 additions & 47 deletions

File tree

clay.edn

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
{:base-target-path "temp"
2-
:base-source-path "src"
3-
:subdirs-to-sync ["src"]
4-
:keep-sync-root false
5-
:flatten-targets false
6-
:remote-repo {:git-url "https://github.com/ClojureCivitas/clojurecivitas.github.io"
7-
:branch "main"}
8-
:hide-info-line true
9-
:hide-ui-header true
1+
{:base-target-path "temp"
2+
:base-source-path "src"
3+
:subdirs-to-sync ["src"]
4+
:keep-sync-root false
5+
:flatten-targets false
6+
:remote-repo {:git-url "https://github.com/ClojureCivitas/clojurecivitas.github.io"
7+
:branch "main"}
8+
:hide-info-line true
9+
:hide-ui-header true
10+
:config/transform civitas.db/expand-authors
1011

1112
;; aliases
1213
:markdown
@@ -15,10 +16,4 @@
1516
:format [:quarto :html]
1617
:run-quarto false
1718
:hide-info-line false
18-
:quarto ^:replace {}
19-
:quarto/expand (-> (slurp "site/db.edn")
20-
(clojure.edn/read-string)
21-
(mapcat [:author :affiliation])
22-
(->> (group-by :id))
23-
(update-vals first)
24-
(update-vals (fn [x] (dissoc x :id))))}}
19+
:quarto ^:replace {}}}

deps.edn

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
clj-fuzzy/clj-fuzzy {:mvn/version "0.4.1"}
1313
clj-thamil/clj-thamil {:mvn/version "0.2.0"}
1414
org.scicloj/clay {:git/url "https://github.com/scicloj/clay"
15-
:git/sha "38f98c645072503a4d0099552aee0f55d48e06ef"}
15+
:git/sha "ab441fe6b82826e55bf277338f5676eb7b785bcc"}
1616
org.eclipse.elk/org.eclipse.elk.core {:mvn/version "0.10.0"}
1717
org.eclipse.elk/org.eclipse.elk.graph {:mvn/version "0.10.0"}
1818
org.eclipse.elk/org.eclipse.elk.graph.json {:mvn/version "0.10.0"}
1919
org.eclipse.elk/org.eclipse.elk.alg.common {:mvn/version "0.10.0"}
20-
org.eclipse.elk/org.eclipse.elk.alg.layered {:mvn/version "0.10.0"}
21-
org.slf4j/slf4j-simple {:mvn/version "2.0.17"}}
20+
org.eclipse.elk/org.eclipse.elk.alg.layered {:mvn/version "0.10.0"}}
2221

2322
:aliases
2423
{;; Build the site with `clojure -M:clay -a [:markdown]`

site/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.quarto/

src/civitas/authors.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
^{:clay {:title "Authors"
33
:quarto {:type :page}}}
44
(ns civitas.authors
5-
(:require [civitas.explorer.db :as db]
5+
(:require [civitas.db :as db]
66
[scicloj.kindly.v4.kind :as kind]))
77

88
;; You belong here!
Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
^{:clay {:quarto {:draft true}}}
2-
(ns civitas.explorer.db
2+
(ns civitas.db
33
(:require [clojure.edn :as edn]
44
[clojure.pprint :as pprint]
55
[clojure.walk :as walk]
66
[tablecloth.api :as tc]
77
[clj-yaml.core :as yaml]))
88

9-
(walk/postwalk
10-
(fn [x]
11-
(cond (map? x) (into {} x)
12-
(seq? x) (into [] x)
13-
:else x))
14-
(yaml/parse-string (slurp "site/_quarto.yml")))
15-
16-
;; TODO: it might be more convenient to use Quarto to gather the metadata
17-
;; ```
18-
;; quarto list --to json
19-
;; ```
9+
(defn quarto []
10+
(walk/postwalk
11+
(fn [x]
12+
(cond (map? x) (into {} x)
13+
(seq? x) (into [] x)
14+
:else x))
15+
(yaml/parse-string (slurp "site/_quarto.yml"))))
2016

2117
(def db-file "site/db.edn")
2218

@@ -28,13 +24,6 @@
2824

2925
(def db (atom (slurp-edn db-file)))
3026

31-
;; TODO: what if the front matter doesn't match existing?
32-
33-
(defn set-notebooks [notebooks]
34-
(->> {:notebook notebooks}
35-
(reset! db)
36-
(spit-edn db-file)))
37-
3827
(defn index-by
3928
"Return a map where a key is (f item) and a value is item."
4029
[f coll]
@@ -44,18 +33,31 @@
4433
(assoc! ret (f x) x))
4534
(transient {}) coll)))
4635

36+
(defn author-replacements
37+
"Creates a map of author and affiliation keys to their full definition"
38+
[]
39+
(-> (mapcat @db [:author :affiliation])
40+
(->> (index-by :id))
41+
(update-vals #(dissoc % :id))))
42+
43+
(defn expand-authors
44+
"Hook for Clay to update ns metadata configuration"
45+
[config]
46+
(update config :quarto #(walk/prewalk-replace (author-replacements) %)))
47+
48+
;; TODO: what if the front matter doesn't match existing?
49+
50+
(defn set-notebooks [notebooks]
51+
(->> {:notebook notebooks}
52+
(reset! db)
53+
(spit-edn db-file)))
54+
4755
(defn notebooks-ds []
4856
(tc/dataset (:notebook @db)))
4957

5058
(defn notebooks []
5159
(:notebook @db))
5260

53-
(defn authors []
54-
(tc/dataset (:author @db)))
55-
56-
(defn topic-ds []
57-
(tc/dataset (:topic @db)))
58-
5961
(defn topics []
6062
(:topic @db))
6163

src/civitas/explorer.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:format {:html {:page-layout :full}}}}}
55
(ns civitas.explorer
66
(:require [scicloj.kindly.v4.kind :as kind]
7-
[civitas.explorer.db :as db]
7+
[civitas.db :as db]
88
[civitas.explorer.geometry :as geom]
99
[civitas.explorer.svg :as svg]))
1010

src/civitas/explorer/layout.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(ns civitas.explorer.layout
33
(:require [hiccup.core :as hiccup]
44
[scicloj.kindly.v4.kind :as kind]
5-
[civitas.explorer.db :as db]
5+
[civitas.db :as db]
66
[civitas.explorer.geometry :as geom]
77
[civitas.explorer.svg :as svg]))
88

src/civitas/explorer/metadata.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@
8787
(println "Front-matter warning:" md-file)
8888
(run! println ws)))
8989

90+
;; TODO: it might be more convenient to use Quarto to gather the metadata
91+
;; ```
92+
;; quarto list --to json
93+
;; ```
94+
9095
(defn find-mds [site-dir]
9196
(map str (fs/glob site-dir "**.qmd")))
9297

0 commit comments

Comments
 (0)