Document codebase: comments, per-area READMEs, deployment guide

Readability pass across all four areas of the stack. Comments explain why
rather than what, concentrated at the points where behaviour is non-obvious:
concurrency, caching, auth, scraping and nginx templating.

Backend: doc comments on every exported declaration across handlers,
services, models and resolvers. Resolver commentary lives inside function
bodies so gqlgen does not strip it on regeneration; schema files use #
comments rather than description blocks so introspection output is
unchanged. Extracted the duplicated auth-cookie blocks into helpers.

Frontend: header comments on every component, store and view, including
STATUS: notes marking which of the parallel/legacy views are still live.
Documented the non-reactive animation-state pattern, the homeData hub and
the WebSocket stale-socket guard. Removed a few dead imports and named the
reconnect-backoff and poll-interval constants.

Python: module and function docstrings covering the Travelodge scraping
contract, the deadline threading, the two-executor concurrency and the
NDJSON streaming protocol.

Infra: header blocks on every compose file, nginx template, Dockerfile and
entrypoint, covering the config selection, envsubst allow-lists, rate-limit
semantics and volume persistence. Hoisted the duplicated envsubst variable
list in nginx/entrypoint.sh.

New: backend/README.md, python/README.md, DEPLOYMENT.md, .env.example,
backend/graph/doc.go. Refreshed vue/README.md. Corrected CLAUDE.md, which
stated a 24h access token where main.go sets 7 days.

No behaviour change. go build/vet, vite build, py_compile and docker
compose config all pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
2026-09-16 15:57:48 +01:00
co-authored by Claude Opus 5
parent a1102b4aa1
commit 64df70e5d2
183 changed files with 4691 additions and 204 deletions
+6
View File
@@ -1,4 +1,10 @@
<script setup>
/**
* Fake waybar status bar (a nod to the author's Linux setup) for DefaultLayout.
*
* Everything except the clock is hard-coded decoration — CPU/MEM/DISK/NET/BAT are
* not real readings. `.hide-sm` drops them on narrow screens.
*/
import { ref, onMounted, onUnmounted } from "vue";
const clock = ref("");
+10
View File
@@ -1,4 +1,14 @@
<script setup>
/**
* Top bar for DefaultLayout: an "UP" breadcrumb button and a scrolling marquee.
*
* `parentPath` strips the last path segment, so /shrines/gto -> /shrines and any
* one-segment route -> "/". It is null only at the root, which is what hides the
* button on the landing page.
*
* The kaomoji are joined into one long string and handed to <Headline>, which
* duplicates and scrolls it — see Headline.vue for why one string and not a list.
*/
import Headline from "@/components/text/Headline.vue";
import { computed } from "vue";
import { useRoute } from "vue-router";
@@ -1,3 +1,9 @@
<!--
Decorative frame: four counter-rotating flowers around the slotted content.
Each corner sets its own `--start` angle so the four are permanently offset by
90 degrees while sharing one keyframe animation.
STATUS: not imported anywhere.
-->
<template>
<div class="container">
<img src="/img/borders/utena.png" class="flower tl antirotate" />
+8
View File
@@ -1,4 +1,12 @@
<script setup>
/**
* Decorative animated colour bars. STATUS: not imported anywhere.
*
* Two known problems if it is ever revived: the call
* `generateOffsets((150, 15, 10))` uses the comma operator, so it passes a single
* argument 10 as `width` and the other two defaults apply; and animate() logs to
* the console on every frame.
*/
import { ref, onMounted, useTemplateRef, onUnmounted } from "vue";
import { getRandomColor } from "@/js/utils";
+4
View File
@@ -1,3 +1,7 @@
<!--
The site's standard button. Wraps a native <button>, so all attributes and
listeners (including @click) fall through to it via Vue's attribute inheritance.
-->
<script setup></script>
<template>
@@ -1,4 +1,9 @@
<script setup>
/**
* Sliding on/off switch. v-model via the explicit modelValue prop +
* update:modelValue emit pair (rather than defineModel) because ToggleHeader
* needs to pass the value down and intercept the event.
*/
import { ref } from "vue";
const props = defineProps({
+13
View File
@@ -1,4 +1,15 @@
<script setup>
/**
* Infinite horizontal marquee. Renders its slot twice side by side and
* translates the pair left; when the offset passes one copy's width it wraps by
* adding that width back, so the seam is never visible.
*
* The offset is a plain `let`, not a ref, and the transform is written straight
* to element.style — a reactive ref here would queue a Vue re-render on every one
* of the 60 frames per second. The width is measured once and re-measured by a
* ResizeObserver rather than read each frame, because reading offsetWidth in the
* rAF callback forces a layout on every frame.
*/
import { onMounted, useTemplateRef, onUnmounted } from "vue";
const container = useTemplateRef("container");
@@ -54,6 +65,8 @@ onUnmounted(() => {
</script>
<template>
<!-- The slot is rendered twice: the second copy fills the gap the first
leaves as it scrolls off, which is what makes the loop seamless. -->
<div class="root">
<div class="container" ref="container">
<div ref="item1">
+4
View File
@@ -1,4 +1,8 @@
<script setup>
/**
* Link styled to sit inside running prose (bold italic, no underline). Same
* `to` vs `href` and auto-`rel` behaviour as Link.vue.
*/
import { computed } from "vue";
const props = defineProps({
+5
View File
@@ -1,4 +1,9 @@
<script setup>
/**
* Standard link. Renders a <RouterLink> when given `to`, a plain <a> when given
* `href`. `bare` drops the styling (used where the parent styles the anchor).
* External `target="_blank"` links get rel="noopener noreferrer" automatically.
*/
import { computed } from "vue";
const props = defineProps({
+3
View File
@@ -1,3 +1,6 @@
<!--
Padded <p>. Exists purely so prose spacing is defined in one place.
-->
<template>
<p class="p-1">
<slot />
+8
View File
@@ -1,4 +1,12 @@
<script setup>
/**
* Section header with a show/hide switch, used by LinkTable's collapsible mode.
*
* The whole bar is clickable: the click handler forwards to the inner
* <ToggleButton>'s DOM node via its $el. The button itself is
* `pointer-events-none` with `@click.stop`, so a direct click on it cannot fire
* the handler twice.
*/
import { ref } from "vue";
import ToggleButton from "@/components/input/ToggleButton.vue";
+10
View File
@@ -10,6 +10,16 @@
</template>
<script setup>
/**
* Scroll container that drifts its own content up and down forever, pausing at
* each end. Used by the Favorites and Consumption widgets.
*
* Position is kept as a 0..1 fraction so it survives content resizing. On the
* edges it is clamped to 0.999 / 0.001 rather than exactly 1 / 0 so the next
* tick's `reachedBottom` / `reachedTop` test doesn't immediately fire again and
* re-trigger the pause. scrollHeight is measured by a ResizeObserver instead of
* being read every frame, which would force a layout 60 times a second.
*/
import { useTemplateRef, onMounted, onBeforeUnmount } from "vue";
const container = useTemplateRef("container");
+22
View File
@@ -1,4 +1,12 @@
<script setup>
/**
* The chat widget: message list, composer, file attach, admin delete and an
* admins-only "private" mode. Drives stores/messages.js and is mounted in the
* right-hand sidebar of views/home/Home.vue.
*
* Owns the socket lifecycle — connect() on mount, disconnect() on unmount — so
* the socket exists only while the widget is on screen.
*/
import { ref, computed, watch, nextTick, onMounted, onUnmounted } from "vue";
import Button from "@/components/input/Button.vue";
import ToggleButton from "@/components/input/ToggleButton.vue";
@@ -17,6 +25,8 @@ const fileInput = ref(null);
const isAdmin = computed(() => !!authStore.user.admin);
const sendPrivate = ref(false);
// Autoscroll only when the reader is already at the bottom: scrolling up to
// read history must not be yanked back down by an incoming message.
const isNearBottom = ref(true);
const SCROLL_THRESHOLD = 100;
let resizeObserver = null;
@@ -45,6 +55,7 @@ function goToBottom() {
scrollToBottom();
}
// nextTick: scrollHeight is only correct once Vue has patched the new row in.
watch(
() => messages.value.length,
() => {
@@ -91,12 +102,20 @@ function isVideoUrl(url) {
return /\.(mp4|webm|ogg|mov)$/i.test(url);
}
/** Only render attachments the backend served from its own upload directory —
* the fileUrl arrives over the socket and is otherwise attacker-controlled. */
function isSafeFileUrl(url) {
return typeof url === "string" && url.startsWith("/uploads/");
}
// NOTE: a module-level /g regex carries `lastIndex` between calls. It is safe
// here only because parseMessageParts() below always runs exec() to completion
// (exec returns null, resetting lastIndex) before returning. An early return
// from that loop would make the next message parse from the wrong offset.
const urlRegex = /(https?:\/\/[^\s<]+)/g;
/** Split message text into alternating {type:'text'|'link', value} parts so
* URLs can be rendered as anchors without using v-html. */
function parseMessageParts(text) {
const parts = [];
let lastIndex = 0;
@@ -126,6 +145,9 @@ onMounted(() => {
});
}
// Images and videos load after their row is inserted and change its height,
// which the length watcher above has already missed. Observing the inner
// wrapper catches those late reflows.
if (messagesInner.value) {
resizeObserver = new ResizeObserver(scrollToBottomIfNear);
resizeObserver.observe(messagesInner.value);
@@ -1,4 +1,8 @@
<script setup>
/**
* Sidebar widget showing the most recent Gitea action, read straight from
* homeData.gitFeed (the backend proxies and caches the Gitea API).
*/
import { useHomeDataStore } from "@/stores/homeData";
import { storeToRefs } from "pinia";
import Header from "@/components/text/Header.vue";
+7
View File
@@ -1,4 +1,11 @@
<script setup>
/**
* Renders a list of {name, link, type} either as stacked link buttons
* (variant="list") or as a two-column table (variant="table").
*
* Passing `title` wraps the whole thing in a collapsible <ToggleHeader>.
* Used by the Bookmarks, Favorites, Consumption and Links widgets.
*/
import { ref } from "vue";
import Link from "@/components/text/Link.vue";
import ToggleHeader from "@/components/text/ToggleHeader.vue";
+7
View File
@@ -1,4 +1,11 @@
<script setup>
/**
* Renders a markdown string, with KaTeX maths support, into sanitised HTML.
*
* The v-html is safe only because DOMPurify strips scripts and event handlers
* from markdown-it's output first — post content is admin-authored but still
* untrusted input. Used by the Feed widget.
*/
import MarkdownIt from "markdown-it";
import { katex } from "@mdit/plugin-katex";
import DOMPurify from "dompurify";
+5
View File
@@ -14,6 +14,9 @@ function onKeydown(e) {
if (e.key === "Escape") open.value = false;
}
// The Escape listener is attached only while open, so several modals on one
// page can't all react to a single keypress. `immediate` covers a modal that
// mounts already open.
watch(
open,
(isOpen) => {
@@ -30,6 +33,8 @@ onUnmounted(() => window.removeEventListener("keydown", onKeydown));
</script>
<template>
<!-- Teleported to <body> so the backdrop escapes any ancestor with
overflow/transform/z-index that would otherwise clip or trap it. -->
<Teleport to="body">
<div v-if="open" class="modal-backdrop" @click.self="open = false">
<div class="modal bdr-1" :style="{ maxWidth: props.maxWidth }">
+4
View File
@@ -1,4 +1,8 @@
<script setup>
/**
* Unfinished layout sketch for a custom audio player — the <audio> element has no
* source and none of the controls are wired up. STATUS: not imported anywhere.
*/
import Button from "@/components/input/Button.vue";
</script>
+6
View File
@@ -1,4 +1,8 @@
<script setup>
/**
* Generic table that derives its columns from the union of keys across all rows,
* so heterogeneous objects still line up. STATUS: not imported anywhere.
*/
import { computed } from "vue";
const props = defineProps({
@@ -8,6 +12,8 @@ const props = defineProps({
},
});
// Union of keys across every row, in first-seen order, so rows with different
// shapes still line up under one header.
const resolvedColumns = computed(() => {
const keys = new Set();
+15 -2
View File
@@ -15,15 +15,28 @@
</template>
<script setup>
/**
* Icecast radio widget. Probes /radio/stream with a HEAD request on mount and
* every 2 minutes, and only mounts the <audio> element once the stream answers.
*
* The nextTick() before load() matters: the <audio> only exists after `streamLive`
* flips and Vue has re-rendered, so calling load() any earlier would hit null.
* Volume is knocked down to 20% because the stream is loud.
*/
import Button from "@/components/input/Button.vue";
import Header from "@/components/text/Header.vue";
import { ref, useTemplateRef, onMounted, nextTick } from "vue";
import axios from "axios";
const POLL_INTERVAL_MS = 120000; // re-probe the stream every 2 minutes
const INITIAL_VOLUME = 0.2; // the stream is loud
const streamUrl = ref("");
const streamLive = ref(false);
const audio = useTemplateRef("audio");
/** HEAD the stream; on the first success mount and prime the <audio>.
* A rejected request just means the station is off air. */
async function checkStream() {
try {
await axios.head("/radio/stream");
@@ -33,7 +46,7 @@ async function checkStream() {
await nextTick();
if (audio.value) {
audio.value.load();
audio.value.volume = 0.2;
audio.value.volume = INITIAL_VOLUME;
}
}
} catch (err) {
@@ -43,7 +56,7 @@ async function checkStream() {
onMounted(() => {
checkStream();
setInterval(checkStream, 120000);
setInterval(checkStream, POLL_INTERVAL_MS);
});
</script>
+5 -5
View File
@@ -1,14 +1,14 @@
<script setup>
import { computed } from "vue";
const props = defineProps({
/**
* A column of in-app <RouterLink> buttons from a list of {name, link}. Used by
* the Links widget and the shrines index.
*/
defineProps({
linkArr: {
type: Array,
required: true,
},
});
const keys = ["name", "link"];
</script>
<template>
+9
View File
@@ -1,4 +1,13 @@
<script setup>
/**
* Crossfading image rotator. Clicking advances immediately.
*
* Each advance clears and re-arms its own timeout rather than using setInterval,
* so a manual click restarts the full interval instead of leaving a short
* remainder. The fade works because `:key="currentIndex"` makes Vue treat each
* image as a new element for the global `fade` transition, and the wrapper is
* `position: relative` so the outgoing copy can be absolutely positioned over it.
*/
import { ref, computed, onMounted, onUnmounted } from "vue";
import Header from "@/components/text/Header.vue";
+5
View File
@@ -1,4 +1,9 @@
<script setup>
/**
* Clock and date widget. updateDateTime() runs once immediately and then every
* minute. Note the interval is module-level and never cleared — harmless because
* the widget lives for the life of the home page, but it would leak if reused.
*/
import Header from "@/components/text/Header.vue";
import { ref } from "vue";
+6
View File
@@ -1,4 +1,10 @@
<script setup>
/**
* Countdown widget with minute/second sliders and a sound on completion.
*
* The four mutually exclusive v-if blocks are a state machine over
* (finished, paused): set/idle, finished, paused, running.
*/
import Button from "@/components/input/Button.vue";
import Header from "@/components/text/Header.vue";
+10 -1
View File
@@ -13,6 +13,13 @@
</template>
<script setup>
/**
* Click-and-drag-to-scroll container ("grab" cursor), for content wider than its
* box. Used by the Stamps widget, which also scrolls it programmatically.
*
* preventDefault on mousedown/mousemove is what stops the browser starting a text
* selection mid-drag.
*/
import { ref } from "vue";
const container = ref(null);
@@ -40,7 +47,9 @@ const handleMouseMove = (e) => {
const x = e.pageX - container.value.offsetLeft;
const y = e.pageY - container.value.offsetTop;
const walkX = (x - startX.value) * 1; // Multiply by scroll speed factor
// The `* 1` is a scroll-speed factor left at 1:1 (content follows the cursor
// exactly). Raise it to make dragging move the content further than the mouse.
const walkX = (x - startX.value) * 1;
const walkY = (y - startY.value) * 1;
container.value.scrollLeft = scrollLeft.value - walkX;
+7 -5
View File
@@ -1,18 +1,20 @@
<script setup>
import { computed } from "vue";
const props = defineProps({
/**
* Grid of <video> players from a list of {link}. The MIME type is guessed from
* the file extension. `preload="none"` keeps the page from downloading every clip
* on load. Used by the Demoman shrine.
*/
defineProps({
sourceArr: {
type: Array,
required: true,
},
});
/** Guess a <source> MIME type from the file extension, e.g. "a.webm" -> "video/webm". */
function sourceType(link) {
return "video/" + link.split(".").pop();
}
const keys = ["name", "link"];
</script>
<template>
+4
View File
@@ -1,3 +1,7 @@
<!--
"Work in progress" placeholder page. Used as the whole body of the GTO,
Evangelion and Skipskipbenben shrines.
-->
<template>
<div class="page-a4 bdr-1 flex flex-col relative overflow-scroll">
<RouterLink to="/" class="bdr-2">
@@ -5,6 +5,16 @@
</template>
<script setup>
/**
* Rust/wasm port of components/util/AutoScroll.vue — the whole rAF loop lives in
* the AutoScroller struct from src/wasm/.
*
* Note the two-step teardown: destroy() detaches the loop and listeners, free()
* releases the Rust-side memory. Skipping free() leaks the wasm allocation, which
* JS garbage collection cannot reclaim.
*
* STATUS: not imported anywhere; the JS AutoScroll is what the widgets use.
*/
import { useTemplateRef, onMounted, onBeforeUnmount } from "vue";
import { AutoScroller } from "@/wasm/stp_wasm.js";