Count Green Man downloads as GoatCounter events

Each download button records a click as an event named after the
file's full path, so downloads sort beside the page in the dashboard.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Eric WagonerandClaude Fable 5.2 committed 2026-11-10 19:53:59 -05:00
1 parent 833440f254
commit 7c43dbd6e2
3 files changed
+5 -3

No files matched your search

+3 -1
View File
@@ -13,6 +13,8 @@ OG_ALT = 'A Green Man half-mask worn with glasses: a crown of painted oak leaves
# The same GoatCounter site as the blog. Paths are prefixed with the host so this site's pages do not merge with the blog's.
ANALYTICS = '''<script>window.goatcounter = {path: function(p) { return location.host + p }}</script>
<script data-goatcounter="https://kestrelsnest.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>'''
# A click on a download button is counted as an event named like a page path, e.g. builds.kestrelsnest.social/greenman/dl/GreenMan_templates.pdf
EVENT_PREFIX = URL.removeprefix('https://')
CSS = '''
/* Same ink, bone and gold as the builds index and Kestrel's Hall, and the same serif. Drawings stay on light paper with sans labels.
@@ -80,7 +82,7 @@ def build(out=str(OUT / 'index.html')):
body = C.construction(); paint_html = C.painting().replace('<header class="cover">', '<header class="cover guide-start" id="painting">').replace('<h1>Green Man mask</h1>', '<h1>Painting the mask</h1>')
dls = [('GreenMan_mask_kit.zip', 'Whole kit', 'Templates, both guides, and the 8 print files in one zip'), ('GreenMan_templates.pdf', 'Templates', '4 pages, 1:1, US Letter or A4'),
('GreenMan_build_guide.pdf', 'Build guide', 'Printable, for the workbench'), ('GreenMan_painting_guide.pdf', 'Painting guide', 'Printable'), ('GreenMan_print_files.zip', 'Print files', '8 STL files, no supports needed')]
downloads = ('<section id="downloads"><h2>Downloads</h2><div class="dl">' + ''.join(f'<a class="dlbtn" href="dl/{f}" download><b>{t}</b><span>{d}</span></a>' for f, t, d in dls) + '</div></section>')
downloads = ('<section id="downloads"><h2>Downloads</h2><div class="dl">' + ''.join(f'<a class="dlbtn" href="dl/{f}" download data-goatcounter-click="{EVENT_PREFIX}dl/{f}" data-goatcounter-title="Green Man download: {t}"><b>{t}</b><span>{d}</span></a>' for f, t, d in dls) + '</div></section>')
nav = '<nav class="top" aria-label="Sections"><a href="#downloads">Downloads</a><a href="#build">Build guide</a><a href="#step-strip">Assembly steps</a><a href="#painting">Painting guide</a></nav>'
i = body.index('</header>') + len('</header>')
body = body[:i] + nav + downloads + '<div id="build"></div>' + body[i:]