Skip to content

Commit 77eb329

Browse files
authored
Update the architecture page (#25)
After gitgitgadget/gitgitgadget#609 has been addressed, the architecture is noticeably different. Here is an attempt to visualize the new lay of the land: ![gitgitgadget-architecture](https://github.com/user-attachments/assets/aaee971f-f7fd-43fe-be0d-eedd8c8c5311)
2 parents d525c49 + 9325a7c commit 77eb329

File tree

12 files changed

+367
-126
lines changed

12 files changed

+367
-126
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
HUGO_ENVIRONMENT: production
4242
HUGO_RELATIVEURLS: false
4343
run: hugo config && hugo --minify --baseURL '${{ steps.pages.outputs.base_url }}/'
44+
- uses: actions/setup-node@v5
45+
- name: pre-render the Graphviz diagrams
46+
run: npm ci && node ./script/graphviz-ssr.js
4447
- uses: actions/upload-pages-artifact@v3
4548
with:
4649
path: ./public

.github/workflows/pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
sudo dpkg -i /tmp/hugo.deb
1818
- name: run Hugo to build the pages
1919
run: hugo
20+
- uses: actions/setup-node@v5
21+
- run: npm ci && node ./script/graphviz-ssr.js
2022
- name: build tar archive
2123
run: cd public && tar czvf ../pages.tar.gz *
2224
- name: Upload build artifact

content/architecture.md

Lines changed: 111 additions & 125 deletions
Large diffs are not rendered by default.

content/diagram-list.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
outputs:
3+
- json
4+
---

hugo.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ markup:
99
goldmark:
1010
renderer:
1111
unsafe: true
12+
mediaTypes:
13+
application/json:
14+
suffixes:
15+
- json
1216
module:
1317
mounts:
1418
- source: content
1519
target: content
1620
params:
17-
hugo_version: 0.145.0
21+
hugo_version: 0.149.1

layouts/_default/baseof.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,33 @@
1212
{{ .Content }}
1313
{{ end }}
1414
</body>
15+
{{- if .Store.Get "hasGraphviz" }}
16+
<script src="{{ relURL "js/viz-global.js" }}"> </script>
17+
<script type="text/javascript">
18+
let vizInstance
19+
window.addEventListener("DOMContentLoaded", async () => {
20+
[...document.querySelectorAll("pre[class=graphviz]")].forEach(async (x) => {
21+
if (!vizInstance) vizInstance = await Viz.instance()
22+
if (x.style.display === 'none') return
23+
const options = {
24+
format: "svg",
25+
graphAttributes: {
26+
bgcolor: "transparent",
27+
},
28+
engine: x.getAttribute("engine") || "dot",
29+
}
30+
const svg = vizInstance.renderString(x.innerText, options)
31+
const img = document.createElement('img')
32+
img.setAttribute(
33+
'src',
34+
`data:image/svg+xml;utf8,${encodeURIComponent(svg.substring(svg.indexOf('<svg')))}`
35+
)
36+
const alt = x.getAttribute("alt")
37+
if (alt) img.setAttribute("alt", alt)
38+
x.parentNode.insertBefore(img, x);
39+
x.style.display = 'none'
40+
})
41+
})
42+
</script>
43+
{{- end }}
1544
</html>

layouts/_default/single.json.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{- $diagram_list := where .Site.Pages "RawContent" "like" "```graphviz" -}}
2+
{{- $diagram_list | jsonify -}}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<pre class="graphviz"
2+
{{- if (and (isset "engine" .Attributes) (ne "" .Attributes.engine)) }} engine="{{ .Attributes.engine }}"{{ end -}}
3+
{{- if (and (isset "alt" .Attributes) (ne "" .Attributes.alt)) }} alt="{{ .Attributes.alt }}"{{ end -}}
4+
>
5+
{{- .Inner | htmlEscape | safeHTML -}}
6+
</pre>
7+
{{- .Page.Store.Set "hasGraphviz" true }}

package-lock.json

Lines changed: 145 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"node-html-parser": "^7.0.1"
4+
}
5+
}

0 commit comments

Comments
 (0)