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:
1 parent
833440f254
commit
7c43dbd6e2
3 files changed
+5
-3
No files matched your search
@@ -17,7 +17,7 @@ Kestrel's Builds is a static site of craft build write-ups. Builds vary (foam an
|
||||
- Everything in `greenman/` is generated by `greenman-src/`: run `uv run build.py` there and it rewrites `greenman/index.html`, `img/`, `dl/` and `og-image.jpg`. Never hand-edit `greenman/`; change the source and rebuild. The back links, favicon line, description, canonical and Open Graph tags are all written by `greenman-src/build_web.py`.
|
||||
- `deploy` must never upload a generator. Any new source folder must be named `<build>-src/` so the existing exclude covers it; check with `./deploy -n`.
|
||||
- Keep the apostrophe in the index's `<meta name="description">` written as `'`. It is deliberate: the opengraph.xyz preview checker cut the description off at a plain apostrophe.
|
||||
- Visits are counted by GoatCounter, the same site code as the blog (`kestrelsnest`). Every page carries the two-line snippet in its head; the first line prefixes the path with the host, so `/` here is recorded as `builds.kestrelsnest.social/` and does not merge with the blog's `/`. In `greenman/` it is written by `ANALYTICS` in `greenman-src/build_web.py`.
|
||||
- Visits are counted by GoatCounter, the same site code as the blog (`kestrelsnest`). Every page carries the two-line snippet in its head; the first line prefixes the path with the host, so `/` here is recorded as `builds.kestrelsnest.social/` and does not merge with the blog's `/`. In `greenman/` it is written by `ANALYTICS` in `greenman-src/build_web.py`. GoatCounter only sees page views, so each download button also carries `data-goatcounter-click`, which records a click as an event named after the file's full path (`builds.kestrelsnest.social/greenman/dl/<file>`). Give a new build's download links the same attribute.
|
||||
- Share previews: `og.png` at the root is a 1200x630 screenshot of the top of the index, so retake it when the index's first card changes. Each build has its own `og-image.jpg` (1200x630) in its folder and its own description and Open Graph tags.
|
||||
|
||||
## Adding a build
|
||||
|
||||
@@ -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:]
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ table.dense { font-size: 0.8rem; min-width: 760px; }
|
||||
<p>(Don’t wear glasses? No worries, I’ve made <a href="#no-glasses">a variation for you</a> too!)</p>
|
||||
<dl class="facts"><div><dt>Hands-on time</dt><dd>about 8 hours over 3 evenings</dd></div><div><dt>Printing</dt><dd>16 small parts, printed unattended</dd></div>
|
||||
<div><dt>Foam</dt><dd>1 base, 27 leaves</dd></div><div><dt>Skills</dt><dd>craft knife, heat gun, contact cement</dd></div></dl></div>
|
||||
<figure class="photo cover-photo"><img src="img/finished.jpg" alt="The finished mask, worn with a knitted hood." loading="lazy"><figcaption>The finished mask, worn with a knitted hood.</figcaption></figure></header><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><section id="downloads"><h2>Downloads</h2><div class="dl"><a class="dlbtn" href="dl/GreenMan_mask_kit.zip" download><b>Whole kit</b><span>Templates, both guides, and the 8 print files in one zip</span></a><a class="dlbtn" href="dl/GreenMan_templates.pdf" download><b>Templates</b><span>4 pages, 1:1, US Letter or A4</span></a><a class="dlbtn" href="dl/GreenMan_build_guide.pdf" download><b>Build guide</b><span>Printable, for the workbench</span></a><a class="dlbtn" href="dl/GreenMan_painting_guide.pdf" download><b>Painting guide</b><span>Printable</span></a><a class="dlbtn" href="dl/GreenMan_print_files.zip" download><b>Print files</b><span>8 STL files, no supports needed</span></a></div></section><div id="build"></div><section><h2>Tested in use</h2>
|
||||
<figure class="photo cover-photo"><img src="img/finished.jpg" alt="The finished mask, worn with a knitted hood." loading="lazy"><figcaption>The finished mask, worn with a knitted hood.</figcaption></figure></header><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><section id="downloads"><h2>Downloads</h2><div class="dl"><a class="dlbtn" href="dl/GreenMan_mask_kit.zip" download data-goatcounter-click="builds.kestrelsnest.social/greenman/dl/GreenMan_mask_kit.zip" data-goatcounter-title="Green Man download: Whole kit"><b>Whole kit</b><span>Templates, both guides, and the 8 print files in one zip</span></a><a class="dlbtn" href="dl/GreenMan_templates.pdf" download data-goatcounter-click="builds.kestrelsnest.social/greenman/dl/GreenMan_templates.pdf" data-goatcounter-title="Green Man download: Templates"><b>Templates</b><span>4 pages, 1:1, US Letter or A4</span></a><a class="dlbtn" href="dl/GreenMan_build_guide.pdf" download data-goatcounter-click="builds.kestrelsnest.social/greenman/dl/GreenMan_build_guide.pdf" data-goatcounter-title="Green Man download: Build guide"><b>Build guide</b><span>Printable, for the workbench</span></a><a class="dlbtn" href="dl/GreenMan_painting_guide.pdf" download data-goatcounter-click="builds.kestrelsnest.social/greenman/dl/GreenMan_painting_guide.pdf" data-goatcounter-title="Green Man download: Painting guide"><b>Painting guide</b><span>Printable</span></a><a class="dlbtn" href="dl/GreenMan_print_files.zip" download data-goatcounter-click="builds.kestrelsnest.social/greenman/dl/GreenMan_print_files.zip" data-goatcounter-title="Green Man download: Print files"><b>Print files</b><span>8 STL files, no supports needed</span></a></div></section><div id="build"></div><section><h2>Tested in use</h2>
|
||||
<p>This mask was built and then worn for a full day at a renaissance faire, glasses and all. It stayed comfortable, nothing came loose, and it needed no repairs. The photos throughout this guide are from that build.</p>
|
||||
<p>The templates and print files have been refined a little since then, so dry-fit the parts against your own base before gluing, as the guide suggests.</p></section><section><h2>How it goes together</h2><div class="cols"><div>
|
||||
<p>The base is a band of 6 mm foam across the forehead with a strip down the nose and a tab on each cheek. It is worn <b>behind</b> your glasses, so the frame rests on the foam and nothing surrounds the lenses.</p>
|
||||
|
||||
Reference in new issue
Block a user