BUGFIX: race condition in engine; index page controller

This commit is contained in:
Simon Martens
2025-03-24 15:30:07 +01:00
parent 66fedf4baf
commit 4bff7fb17a
39 changed files with 59138 additions and 302 deletions

View File

@@ -10,13 +10,13 @@
</div>
<div>
<span>{{- .site.title }} &ndash; ein Projekt der</span>
<span>{{- .title }} &ndash; ein Projekt der</span>
<a href="https://theodor-springmann-stiftung.de">Theodor Springmann Stiftung</a>
<span>&middot;</span>
<a href="/datenschutz/">Impressum &amp; Datenschutz</a>
<span>&middot;</span>
<i class="ri-code-line"></i>
<a href="https://github.com/Theodor-Springmann-Stiftung/musenalm">Code</a>
<a href="https://github.com/Theodor-Springmann-Stiftung/lenz-web">Code</a>
</div>
</div>
</footer>

View File

@@ -0,0 +1,52 @@
<!-- Mark selected anchor location for CSS & Assistive Technology -->
<script type="module">
const hash = window.location.hash;
if (hash) {
const stripped = hash.slice(1);
const element = document.getElementById(stripped);
if (element) {
element.setAttribute("aria-current", "location");
}
}
</script>
{{ if .isDev }}
<!-- Reload script for development -->
<script type="module">
(function () {
let relto = -1;
const scheme = location.protocol === "https:" ? "wss" : "ws";
// Hardcode port 9000 here:
const url = scheme + "://" + location.hostname + ":9000/pb/reload";
function connect() {
const socket = new WebSocket(url);
socket.addEventListener("open", function () {
console.log("Reload socket connected (port 9000).");
});
socket.addEventListener("message", function (evt) {
if (evt.data === "reload") {
console.log("Received reload signal. Reloading...");
if (relto !== -1) clearTimeout(relto);
relto = setTimeout(() => location.reload(), 0);
}
});
socket.addEventListener("close", function () {
console.log("Reload socket closed. Reconnecting in 3 seconds...");
setTimeout(connect, 3000);
});
socket.addEventListener("error", function (err) {
console.error("Reload socket error:", err);
// We'll let onclose handle reconnection.
});
}
// Initiate the first connection attempt.
connect();
})();
</script>
{{ end }}

View File

@@ -21,14 +21,8 @@
{{ end }}
<script src="/assets/js/alpine.min.js" defer></script>
<script src="/assets/js/htmx.min.js" defer></script>
<script src="/assets/js/htmx-response-targets.js" defer></script>
<script src="/assets/js/mark.min.js" defer></script>
<script type="module" src="/assets/scripts.js"></script>
<link href="/assets/css/remixicon.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="/assets/css/fonts.css" />
<link rel="stylesheet" type="text/css" href="/assets/style.css" />
<script type="module">
@@ -67,17 +61,10 @@
<!-- Default scripts... -->
{{ end }}
{{ block "_globalscripts" . }}
<!-- Default global scripts... -->
{{ end }}
<script type="module">
const hash = window.location.hash;
if (hash) {
const stripped = hash.slice(1);
const element = document.getElementById(stripped);
if (element) {
element.setAttribute("aria-current", "location");
}
}
</script>
</div>
</body>
</html>