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:
@@ -1,4 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* Start of an ASCII-video player: sizes a monospace <pre> to the available box and
|
||||
* fills it with blank rows. No frame data or playback is wired up yet.
|
||||
* STATUS: not imported anywhere.
|
||||
*/
|
||||
import { useTemplateRef, ref, onMounted, onUnmounted } from "vue";
|
||||
|
||||
const display = useTemplateRef("display");
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Bookmarks sidebar widget on /stp. Groups homeData.bookmarks by category into
|
||||
* [category, items] pairs, one collapsible <LinkTable> each.
|
||||
*/
|
||||
import { computed, ref, defineAsyncComponent } from "vue";
|
||||
import LinkTable from "@/components/util/LinkTable.vue";
|
||||
import Modal from "@/components/util/Modal.vue";
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "鸟" widget on /stp — a two-tab cell: a <Slideshow> and, once signed in, the
|
||||
* Places list.
|
||||
*
|
||||
* The Places tab is added to `tabs` only when logged in, and the watcher forces
|
||||
* the view back to the collage on logout so a signed-out user is never left
|
||||
* staring at an empty private tab.
|
||||
*/
|
||||
import { ref, computed, watch } from "vue";
|
||||
import Slideshow from "@/components/util/Slideshow.vue";
|
||||
import Modal from "@/components/util/Modal.vue";
|
||||
@@ -19,6 +27,8 @@ const tabs = computed(() => [
|
||||
const activeTab = ref("collage");
|
||||
const showAdd = ref(false);
|
||||
|
||||
// On logout the Places tab disappears from `tabs`; without this the component
|
||||
// would be left pointing at a tab that no longer exists and render nothing.
|
||||
watch(loggedIn, (isIn) => {
|
||||
if (!isIn && activeTab.value === "places") activeTab.value = "collage";
|
||||
});
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "Consumption" widget on /stp (books/films/games logged as activities). Same
|
||||
* shape as Favorites.vue: AutoScroll list + admin-only lazy create form.
|
||||
*/
|
||||
import AutoScroll from "@/components/util/AutoScroll.vue";
|
||||
import Modal from "@/components/util/Modal.vue";
|
||||
import LinkTable from "@/components/util/LinkTable.vue";
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "Favorites" widget on /stp: a self-scrolling <AutoScroll> list, plus an
|
||||
* admin-only create form in a <Modal> (lazily imported).
|
||||
*/
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import CreateToggle from "@/components/input/CreateToggle.vue";
|
||||
import LinkTable from "@/components/util/LinkTable.vue";
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Blog-post widget on /stp. Shows one post at a time with prev/next paging
|
||||
* (`idx`), rendered through <Markdown>. Delete is offered only when the signed-in
|
||||
* user is the post's author; the admin create form is lazily imported.
|
||||
*/
|
||||
import Button from "@/components/input/Button.vue";
|
||||
import Markdown from "@/components/util/Markdown.vue";
|
||||
import Modal from "@/components/util/Modal.vue";
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* First version of the /stp gym widget: a static list of exercises.
|
||||
* STATUS: superseded by Gym2.vue; not imported anywhere.
|
||||
*/
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import LinkTable from "@/components/util/LinkTable.vue";
|
||||
const gym = [
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
<script setup>
|
||||
/**
|
||||
* The live "Rowing" widget on /stp: a hand-drawn SVG line chart of rowing
|
||||
* sessions, with a metric selector and a hover tooltip.
|
||||
*
|
||||
* No chart library — points are projected by hand into a fixed 290x120 viewBox
|
||||
* (W/H) inset by the PL/PT/PR/PB padding constants. The y axis is normalised to
|
||||
* the visible min..max of the selected metric, so `range || 1` guards the
|
||||
* divide-by-zero when every session has the same value, and a single data point
|
||||
* is centred rather than pinned to x=0.
|
||||
*
|
||||
* Rows are reversed (oldest first) for the chart; `slice()` first so the store's
|
||||
* array is not mutated.
|
||||
*
|
||||
* The admin create form is a defineAsyncComponent so CreateRowing.vue is only
|
||||
* downloaded when an admin actually opens it.
|
||||
*/
|
||||
import { ref, computed, defineAsyncComponent } from "vue";
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import Modal from "@/components/util/Modal.vue";
|
||||
@@ -14,6 +30,7 @@ const store = useHomeDataStore();
|
||||
const { loaded, error, rowingSessions } = storeToRefs(store);
|
||||
const showCreate = ref(false);
|
||||
|
||||
// slice() first: reverse() mutates in place and would reorder the store's array.
|
||||
const rows = computed(() => rowingSessions.value.slice().reverse());
|
||||
const loading = computed(() => !loaded.value);
|
||||
|
||||
@@ -51,6 +68,9 @@ const chartData = computed(() =>
|
||||
const minVal = computed(() => Math.min(...chartData.value.map((d) => d.value)));
|
||||
const maxVal = computed(() => Math.max(...chartData.value.map((d) => d.value)));
|
||||
|
||||
// Project each session into SVG coordinates inside the PL/PT/PR/PB padded plot
|
||||
// area. `range || 1` avoids a divide-by-zero when every value is identical, and
|
||||
// a single point is centred horizontally rather than pinned to the left edge.
|
||||
const points = computed(() => {
|
||||
const data = chartData.value;
|
||||
const n = data.length;
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/stp` — the personal home page: an A4-shaped widget grid flanked by two
|
||||
* sidebars.
|
||||
*
|
||||
* Layout is entirely CSS `grid-template-areas`: each child gets a `grid-area`
|
||||
* class and the three breakpoints below (desktop / <=1360px tablet / <=700px
|
||||
* phone) re-draw the whole area map rather than moving elements around.
|
||||
*
|
||||
* The widgets do not fetch individually — they all read stores/homeData.js, which
|
||||
* issues one GraphQL query for the whole page.
|
||||
*
|
||||
* Note which variants are wired up: Intro2 and Gym2, not Intro/Gym.
|
||||
*/
|
||||
import Timer from "@/components/util/Timer.vue";
|
||||
import Time from "@/components/util/Time.vue";
|
||||
import Radio from "@/components/util/Radio.vue";
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<script setup>
|
||||
/**
|
||||
* First version of the /stp intro widget. Nearly all of its content is commented
|
||||
* out and Home.vue imports Intro2 instead.
|
||||
* STATUS: superseded by Intro2.vue; not imported anywhere.
|
||||
*/
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import Paragraph from "@/components/text/Paragraph.vue";
|
||||
</script>
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* The live intro widget on /stp: DVD-logo-style bouncing phrases.
|
||||
*
|
||||
* The animation deliberately keeps its state in the plain `animState` array, not
|
||||
* in the reactive `items` ref — mutating a ref 30 times a second would trigger a
|
||||
* Vue re-render per frame. `items` exists only to render the initial DOM; after
|
||||
* that, positions are written straight onto the elements. Element and container
|
||||
* sizes are cached and re-measured on resize rather than read each frame, since
|
||||
* reading offsetWidth in a rAF callback forces a synchronous layout.
|
||||
*
|
||||
* Frames are throttled to ~30fps via FRAME_INTERVAL because the motion is slow
|
||||
* and this is a background decoration.
|
||||
*/
|
||||
import { rand } from "@vueuse/core";
|
||||
import { ref, onMounted, onUnmounted, nextTick } from "vue";
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "Links" widget on /stp: internal routes via <RouterTable>, external profiles
|
||||
* via <LinkTable>.
|
||||
*/
|
||||
import RouterTable from "@/components/util/RouterTable.vue";
|
||||
import LinkTable from "@/components/util/LinkTable.vue";
|
||||
import Header from "@/components/text/Header.vue";
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "Listening" widget on /stp: rotates through recent Spotify plays.
|
||||
*
|
||||
* Two timers: a 5s rotation (self-rearming setTimeout, so a manual change would
|
||||
* reset the full interval) and a 2-minute re-poll of Spotify. Both are cleared on
|
||||
* unmount.
|
||||
*/
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import { ref, computed, onMounted, onUnmounted } from "vue";
|
||||
import { useSongsStore } from "@/stores/songs";
|
||||
@@ -10,6 +17,8 @@ const song = computed(() => songsStore.songs[idx.value]);
|
||||
let nextId = null;
|
||||
let refreshId = null;
|
||||
|
||||
// Self-rearming timeout rather than setInterval, so the full 5s is restarted
|
||||
// whenever the song changes rather than leaving a short remainder.
|
||||
function nextSong() {
|
||||
clearTimeout(nextId);
|
||||
nextId = setTimeout(nextSong, 5000);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Decorative Miku GIF slideshow in the /stp right sidebar.
|
||||
*/
|
||||
import Slideshow from "@/components/util/Slideshow.vue";
|
||||
|
||||
const images = [
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<script setup>
|
||||
/**
|
||||
* The Places-to-go table inside the Collage widget. Sign-in only.
|
||||
*
|
||||
* Fetches lazily and at most once: onMounted covers an already-signed-in visitor,
|
||||
* the `loggedIn` watcher covers someone who signs in while the page is open, and
|
||||
* both check `!loaded && !loading` so the two paths can't fire two requests.
|
||||
*/
|
||||
import { computed, onMounted, watch } from "vue";
|
||||
import { usePlacesStore } from "@/stores/places";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
@@ -7,6 +14,9 @@ const places = usePlacesStore();
|
||||
const auth = useAuthStore();
|
||||
const loggedIn = computed(() => auth.loggedIn);
|
||||
|
||||
// Two entry points, one fetch: onMounted covers an already-signed-in visitor,
|
||||
// the watcher covers signing in with the page already open. The
|
||||
// !loaded && !loading test is what stops them both firing a request.
|
||||
onMounted(() => {
|
||||
if (loggedIn.value && !places.loaded && !places.loading) places.fetch();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
<script setup>
|
||||
/**
|
||||
* 88x31 webring "stamps" widget on /stp, inside a drag-scrollable <Touchscreen>.
|
||||
*
|
||||
* The order is shuffled on module load so the wall looks different each visit.
|
||||
* The rAF loop then drifts the scroll position diagonally and bounces off each
|
||||
* edge — it drives the DOM's scrollLeft/scrollTop directly rather than any
|
||||
* reactive state, and reads scrollWidth/clientWidth each frame because images
|
||||
* load in progressively and change the bounds.
|
||||
*/
|
||||
import { ref, onMounted, onUnmounted } from "vue";
|
||||
|
||||
import Touchscreen from "@/components/util/Touchscreen.vue";
|
||||
@@ -21,6 +30,8 @@ let srcs = [
|
||||
"/img/stamps/demo.gif",
|
||||
"/img/stamps/demo.gif",
|
||||
];
|
||||
// Shuffled once at module evaluation, so the wall is ordered differently each
|
||||
// page load but stable while the widget is mounted. Mutates in place.
|
||||
shuffleArray(srcs);
|
||||
|
||||
const touchscreen = ref(null);
|
||||
@@ -30,6 +41,13 @@ let posY = 0;
|
||||
let dx = 0.2;
|
||||
let dy = 0.12;
|
||||
|
||||
/**
|
||||
* rAF loop drifting the scroll position diagonally and bouncing off the edges.
|
||||
*
|
||||
* Writes scrollLeft/scrollTop on the DOM node directly (no reactive state, so
|
||||
* no re-render per frame), and re-reads scrollWidth/clientWidth every frame
|
||||
* because the stamp images load in progressively and keep changing the bounds.
|
||||
*/
|
||||
function bounce() {
|
||||
const el = touchscreen.value?.$el;
|
||||
if (!el) return;
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Steam widget on /stp: online status plus a rotation through recent games
|
||||
* (5s rotation, 5-minute re-poll). `loaded` comes from homeData so the widget can
|
||||
* tell "not fetched yet" from "fetched, nothing to show".
|
||||
*/
|
||||
import { ref, computed, onMounted, onUnmounted } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useSteamStore } from "@/stores/steam";
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/shrines/demoman` — a wall of TF2 Demoman clips via <VideoTable>.
|
||||
*/
|
||||
import VideoTable from "@/components/util/VideoTable.vue";
|
||||
import Link from "@/components/text/Link.vue";
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/shrines/evangelion` — placeholder, renders <Wip>.
|
||||
*/
|
||||
import Wip from "@/components/util/Wip.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/shrines/gto` — placeholder, renders <Wip>.
|
||||
*/
|
||||
import Wip from "@/components/util/Wip.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/shrines` — index of the shrine pages.
|
||||
*/
|
||||
import RouterTable from "@/components/util/RouterTable.vue";
|
||||
const shrine_links = [
|
||||
{ name: "Demoman", link: "/shrines/demoman" },
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/shrines/skipskipbenben` — placeholder, renders <Wip>.
|
||||
*/
|
||||
import Wip from "@/components/util/Wip.vue";
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user