This commit is contained in:
mark committed 2026-09-08 08:02:21 -04:00
1 parent f041daeda3
commit 9407c26d2d
6 files changed
+301 -33

No files matched your search

+1
View File
@@ -105,6 +105,7 @@
{% block content %}{% endblock %}
</div>
</div>
{% include "version.njk" %}
</main>
{# Chrome, so it is written once here instead of built in JavaScript on every
+10 -2
View File
@@ -44,12 +44,20 @@
settled is what stops the load trigger looping: the answer to it is a
picker already standing in the right place, and it says so by leaving the
trigger out of the copy it sends back. #}
trigger out of the copy it sends back.
!!location.hash, and not location.hash, because htmx keeps an event only
when the filter returns boolean true exactly -- it tests the result with
!== true -- and a hash is a string. Written without the coercion the
trigger is dead: every link carrying an anchor lands with the picker still
reading 1:1, which is where the worker rendered it, because a browser
keeps the fragment to itself and the request that would correct it is
never sent. #}
<div class="reference navbar-text {% if reference %}d-flex{% else %}d-none{% endif %} align-items-center gap-1 ms-3"
id="reference"
{%- if oob %} hx-swap-oob="true"{% endif %}
hx-get="api/reference"
hx-trigger="{% if reference and not settled %}load[location.hash], {% endif %}worker-ready from:body, htmx:historyRestore from:body"
hx-trigger="{% if reference and not settled %}load[!!location.hash], {% endif %}worker-ready from:body, htmx:historyRestore from:body"
hx-target="this" hx-swap="outerHTML">
{%- if reference %}
<span class="reference-book text-light fw-semibold"
+39
View File
@@ -0,0 +1,39 @@
{# The footer under the book list: what this device is running, and the one
button that makes it forget.
Both digests are stamped into sw.js by server.py from the files on disk:
shell covers assets/, the hand-written chrome, and library covers bible/,
the generated pages. They are the same two values the worker names its
caches after, so a device showing a digest is a device serving that cache.
It says what the worker that composed this document was, not what is
controlling right now. An update installs, claims and starts answering
without this document being rebuilt, so the value only becomes current on
the next full load -- which is the reload you would do to check it anyway.
version is null in one case: boot.html composed this page, so there was no
worker to ask. The line is then absent, which is the honest answer -- no
worker means no version, and the bookmark slot in the navbar is empty for
the same reason. The button stays, because a device with no worker and a
full cache is exactly the state worth clearing.
Rendered on every page and shown under the book list alone. Populating it
only for the index would look like the smaller change and would not work:
the shell is composed once per full navigation, and a boosted link to the
book list swaps #content without rebuilding anything around it. So the page
decides, not the composer -- app.js looks for the index in #content after
every swap. The body class this was rendered with cannot be asked, for the
same reason: it goes stale the moment a link is clicked.
The button is a plain <button> outside any form, which is the whole of why
hx-boost on <body> leaves it alone: htmx boosts links, forms, and submits
belonging to one. resetApp() in js/app.js is what it runs. #}
<div class="app-version d-none text-center mt-5 mb-2" id="app-version">
{%- if version %}
<p class="app-version-digests form-text mt-0 mb-2">
shell {{ version.shell }} &middot; library {{ version.library }}
</p>
{%- endif %}
<button type="button" class="app-reset btn btn-outline-secondary btn-sm"
id="app-reset">Reset app</button>
</div>