vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Load the Prism worker from the static route
9a9e708c1def7250086e612cdee88e1ea12298ab · Keenan Nemetz · 21d ago · parent 7c02af12
Load the Prism worker from the static route The highlighting script asked for /static/prism-worker.js, but every browser asset is served under /-/static/. The request fell through to the HTML 404 page, so the browser refused the worker for its MIME type and every blob stayed plain. HTMX also compiles an hx-trigger filter with Function(), which script-src 'self' blocks. The two polling triggers used a visibility filter for that; drop the filter, pause the request in app.js while the tab is hidden, and turn eval off in the HTMX config so a future filter is caught instead of failing in production. Tests hold the worker to its route and the templates to trigger forms that do not need eval.
server/web/static/app.js +17−1
| @@ -172,7 +172,7 @@ const fitTextarea = (area) => { | |||
| 172 | 172 | if (worker) return worker; | |
| 173 | 173 | if (typeof Worker === 'undefined') return null; | |
| 174 | 174 | try { | |
| 175 | worker = new Worker('/static/prism-worker.js'); | ||
| 175 | worker = new Worker('/-/static/prism-worker.js'); | ||
| 176 | 176 | } catch (err) { | |
| 177 | 177 | return null; | |
| 178 | 178 | } | |
| @@ -760,6 +760,22 @@ const fitTextarea = (area) => { | |||
| 760 | 760 | }); | |
| 761 | 761 | })(); | |
| 762 | 762 | ||
| 763 | // HTMX compiles an hx-trigger filter with Function(), which the CSP forbids | ||
| 764 | // (script-src 'self'). The polling elements therefore say a plain "every Ns" and | ||
| 765 | // this guard skips a tick while the tab is hidden, which is the one thing their | ||
| 766 | // old [document.visibilityState === 'visible'] filters did. A later filter would | ||
| 767 | // be the CSP error again, so pages keep their triggers filter-free. | ||
| 768 | (() => { | ||
| 769 | const polls = (elt) => { | ||
| 770 | const trigger = elt && elt.getAttribute && elt.getAttribute('hx-trigger'); | ||
| 771 | return trigger != null && /(^|,)\s*every\s/.test(trigger); | ||
| 772 | }; | ||
| 773 | document.body.addEventListener('htmx:beforeRequest', (event) => { | ||
| 774 | if (document.visibilityState === 'visible') return; | ||
| 775 | if (polls(event.detail.elt)) event.preventDefault(); | ||
| 776 | }); | ||
| 777 | })(); | ||
| 778 | |||
| 763 | 779 | // The repository tabs poll their open counts, and a number changing while the | |
| 764 | 780 | // reader is looking somewhere else is easy to miss. A badge that moved keeps one | |
| 765 | 781 | // short ring; the page's first counts are the baseline, so only a later poll that | |