mirror of
https://github.com/Theodor-Springmann-Stiftung/lenz-web.git
synced 2025-10-29 09:15:33 +00:00
BUGFIX: race condition in engine; index page controller
This commit is contained in:
@@ -10,13 +10,13 @@
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span>{{- .site.title }} – ein Projekt der</span>
|
||||
<span>{{- .title }} – ein Projekt der</span>
|
||||
<a href="https://theodor-springmann-stiftung.de">Theodor Springmann Stiftung</a>
|
||||
<span>·</span>
|
||||
<a href="/datenschutz/">Impressum & Datenschutz</a>
|
||||
<span>·</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>
|
||||
|
||||
52
views/layouts/components/_globalscripts.gohtml
Normal file
52
views/layouts/components/_globalscripts.gohtml
Normal 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 }}
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user