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,3 +1,6 @@
|
||||
<!--
|
||||
Catch-all route for unmatched paths under `/`.
|
||||
-->
|
||||
<template>
|
||||
<main class="flex flex-col items-center">
|
||||
<div
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/cv` — the CV shell: a template picker, a Print button and a link to the
|
||||
* job tracker. Rendered inside CVLayout, which supplies the light print theme.
|
||||
*
|
||||
* The selected template is held in a shallowRef: the value is a component
|
||||
* definition, and a deep `ref` would try to make the whole component object
|
||||
* reactive. Most templates are commented out of `templates` — uncomment a pair of
|
||||
* lines (the import and the entry) to bring one back.
|
||||
*
|
||||
* Printing is just window.print(); the `no-print` class (assets/styles.css) hides
|
||||
* the chrome, and cv-shared.css sizes the pages.
|
||||
*/
|
||||
import { ref, shallowRef } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
// import CVGeneral from "./CVGeneral.vue";
|
||||
@@ -26,6 +38,9 @@ const templates = [
|
||||
];
|
||||
|
||||
const selected = ref(0);
|
||||
// shallowRef, not ref: the value is a component definition. A deep ref would
|
||||
// walk the whole component object making it reactive — wasteful and a known
|
||||
// source of warnings.
|
||||
const currentComponent = shallowRef(templates[0].component);
|
||||
|
||||
function select(index) {
|
||||
@@ -33,6 +48,8 @@ function select(index) {
|
||||
currentComponent.value = templates[index].component;
|
||||
}
|
||||
|
||||
/** Browser print dialog. The `no-print` class (assets/styles.css) hides the
|
||||
* selector bar; cv-shared.css handles page sizing and breaks. */
|
||||
function print() {
|
||||
window.print();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Alternative CV template, tailored for analyst roles.
|
||||
* STATUS: commented out of CV.vue's template list; not currently reachable.
|
||||
*/
|
||||
import Project from "./Project.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Alternative CV template, tailored for backend roles.
|
||||
* STATUS: commented out of CV.vue's template list; not currently reachable.
|
||||
*/
|
||||
import Project from "./Project.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Alternative CV template, tailored for electrical engineering roles.
|
||||
* STATUS: commented out of CV.vue's template list; not currently reachable.
|
||||
*/
|
||||
import Project from "./Project.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Alternative CV template, tailored for frontend roles.
|
||||
* STATUS: commented out of CV.vue's template list; not currently reachable.
|
||||
*/
|
||||
import Project from "./Project.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Alternative CV template, tailored for general applications.
|
||||
* STATUS: commented out of CV.vue's template list; not currently reachable.
|
||||
*/
|
||||
import Project from "./Project.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Alternative CV template, tailored for hospitality roles.
|
||||
* STATUS: commented out of CV.vue's template list; not currently reachable.
|
||||
*/
|
||||
import Project from "./Project.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* The live CV template — the only one currently listed in CV.vue.
|
||||
*/
|
||||
import Project from "./Project.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Alternative CV template, tailored for security roles.
|
||||
* STATUS: commented out of CV.vue's template list; not currently reachable.
|
||||
*/
|
||||
import Project from "./Project.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Scratch copy of a CV template, kept for cannibalising wording.
|
||||
* STATUS: commented out of CV.vue's template list; not currently reachable.
|
||||
*/
|
||||
import Project from "./Project.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/cv/jobs` (guarded by `meta.requiresAdmin`) — a private tracker for job
|
||||
* applications and for the reusable reference snippets that feed the CV copy.
|
||||
* Two independent CRUD tables over GraphQL; editing is inline via an `editingId`
|
||||
* plus a scratch copy of the row.
|
||||
*/
|
||||
import { ref, onMounted } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
import { gql } from "@/graphql";
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
<!--
|
||||
Layout wrapper used inside every CV template: a left gutter (#left slot, e.g.
|
||||
dates), a heading row (#top slot) and the default slot for the body.
|
||||
-->
|
||||
<script setup></script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/admin` (guarded by `meta.requiresAdmin`) — a tab strip over every
|
||||
* create/manage form. Each entry in `sections` maps a tab id to a component
|
||||
* rendered by <component :is>. Unlike the home widgets these are eagerly
|
||||
* imported, since reaching this page means you want them.
|
||||
*/
|
||||
import { ref, computed } from "vue";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import Button from "@/components/input/Button.vue";
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Admin form: log a consumed book/film/game. Emits "done"/"cancel".
|
||||
*/
|
||||
import Button from "@/components/input/Button.vue";
|
||||
|
||||
import { ref } from "vue";
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Admin form: create a categorised bookmark. Emits "done"/"cancel".
|
||||
*/
|
||||
import Button from "@/components/input/Button.vue";
|
||||
import { ref } from "vue";
|
||||
import { gql } from "@/graphql";
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Admin form: create a favourite. Emits "done"/"cancel" (see CreatePost.vue).
|
||||
*/
|
||||
import Button from "@/components/input/Button.vue";
|
||||
|
||||
import { ref } from "vue";
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Admin form: create a place / thing to do. Goes through stores/places.js rather
|
||||
* than gql() directly, so the new row appears in the Places table immediately.
|
||||
*/
|
||||
import Button from "@/components/input/Button.vue";
|
||||
import { ref } from "vue";
|
||||
import { usePlacesStore } from "@/stores/places";
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Admin form: create a blog post. Emits "done" on success and "cancel" when
|
||||
* dismissed, so the host (the Feed widget's modal, or Admin.vue) decides what to
|
||||
* close or refresh.
|
||||
*/
|
||||
import Button from "@/components/input/Button.vue";
|
||||
import { ref } from "vue";
|
||||
import { gql } from "@/graphql";
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Admin form: upload photos of an erg monitor. The Go backend OCRs each image and
|
||||
* returns the parsed session, so this posts multipart/form-data to /api/rowing
|
||||
* rather than using GraphQL. Uploads run in parallel and each file's row reports
|
||||
* its own outcome.
|
||||
*
|
||||
* The returned Time is a Go duration in nanoseconds, hence the /1e9 before
|
||||
* splitting into minutes and seconds.
|
||||
*/
|
||||
import Button from "@/components/input/Button.vue";
|
||||
import { ref } from "vue";
|
||||
import axios from "axios";
|
||||
@@ -28,6 +37,7 @@ async function submit() {
|
||||
const res = await axios.post("/api/rowing", formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
// Time comes back as a Go time.Duration, i.e. nanoseconds.
|
||||
const mins = Math.floor(res.data.Time / 1e9 / 60);
|
||||
const secs = String(Math.floor((res.data.Time / 1e9) % 60)).padStart(
|
||||
2,
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Admin form: create an account. Reports success or failure inline.
|
||||
*/
|
||||
import Button from "@/components/input/Button.vue";
|
||||
import { ref } from "vue";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/admin/login`. On success redirects to `?redirect=` (set by the router
|
||||
* guard when it bounced you here) or to /admin.
|
||||
*
|
||||
* auth.logIn() never throws — it swallows the error — so success is detected by
|
||||
* re-reading `auth.loggedIn` afterwards rather than by a try/catch.
|
||||
*/
|
||||
import { ref } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
@@ -18,6 +25,8 @@ async function handleLogin() {
|
||||
submitting.value = true;
|
||||
errorMsg.value = "";
|
||||
try {
|
||||
// logIn() swallows its error, so success is detected by re-reading
|
||||
// `loggedIn` rather than by catching.
|
||||
await auth.logIn(username.value, password.value);
|
||||
if (auth.loggedIn) {
|
||||
const dest = route.query.redirect || "/admin";
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Admin panel: list and upload tracks for the Icecast radio. REST
|
||||
* (multipart/form-data) rather than GraphQL because it moves files.
|
||||
*/
|
||||
import Button from "@/components/input/Button.vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
import axios from "axios";
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Admin panel: list users and toggle their admin flag. Mutates the local `user`
|
||||
* object in place from the mutation's response, so the row updates without a
|
||||
* refetch.
|
||||
*/
|
||||
import Button from "@/components/input/Button.vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/automata` — an interactive Turing machine / mobile automaton
|
||||
* simulator, rendered to a <canvas>.
|
||||
*
|
||||
* A machine is described by a transition table: each `delta` line is
|
||||
* "<read>,<write>,<L|R>" over single characters, so the whole configuration is
|
||||
* editable as plain text and shareable. Configuration is kept in localStorage
|
||||
* under STORAGE_KEY.
|
||||
*
|
||||
* The canvas draws colours literally rather than via CSS variables — this is
|
||||
* the one place in the codebase exempt from the "always use a design token"
|
||||
* rule, because canvas has no access to CSS custom properties.
|
||||
*/
|
||||
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
|
||||
import InlineLink from "@/components/text/InlineLink.vue";
|
||||
import Header from "@/components/text/Header.vue";
|
||||
@@ -144,6 +157,8 @@ const terminated = ref(false);
|
||||
const accepted = ref(false);
|
||||
const speed = ref(55); // slider 0..100, log scale
|
||||
|
||||
// The slider is 0..100 but useful speeds span 1 to ~2000 steps/sec, so map it
|
||||
// logarithmically: 10^(slider*3.3/100) gives 1 at 0 and ~10^3.3 (~2000) at 100.
|
||||
const stepsPerSecond = computed(() =>
|
||||
Math.max(1, Math.round(10 ** ((speed.value * 3.3) / 100))),
|
||||
);
|
||||
@@ -187,6 +202,8 @@ function parseDelta(str) {
|
||||
return { delta, n };
|
||||
}
|
||||
|
||||
/** Every word of length n over the alphabet `gamma` (|gamma|^n of them) —
|
||||
* used to list the inputs that have NO transition, i.e. the halting words. */
|
||||
function allWords(gamma, n) {
|
||||
let words = [""];
|
||||
for (let i = 0; i < n; i++) {
|
||||
@@ -245,6 +262,8 @@ function loadMachine() {
|
||||
derivedN.value = n;
|
||||
derivedSigma.value = [...sigma].join(",");
|
||||
derivedGamma.value = machine.gamma.join(",");
|
||||
// |gamma|^n halting words: only enumerate when the count is small,
|
||||
// otherwise a wide alphabet would hang the page building the list.
|
||||
if (machine.gamma.length ** n <= 4096) {
|
||||
derivedF.value = allWords(machine.gamma, n)
|
||||
.filter((w) => !delta.has(w))
|
||||
@@ -279,11 +298,16 @@ function loadMachine() {
|
||||
}
|
||||
}
|
||||
|
||||
// The tape is conceptually infinite in both directions but stored as a finite
|
||||
// array. `origin` is the absolute cell index of tape[0], so absolute index i
|
||||
// lives at tape[i - origin]; anything outside the array reads as blank.
|
||||
function cellAt(i) {
|
||||
const j = i - origin;
|
||||
return j >= 0 && j < tape.length ? tape[j] : machine.blank;
|
||||
}
|
||||
|
||||
/** Write to absolute cell `i`, growing the tape (and shifting `origin` when
|
||||
* growing leftwards) so the array always covers every written cell. */
|
||||
function setCell(i, v) {
|
||||
let j = i - origin;
|
||||
while (j < 0) {
|
||||
@@ -295,6 +319,17 @@ function setCell(i, v) {
|
||||
tape[j] = v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply one transition: read the n-cell window starting at the head, look it up
|
||||
* in delta, write the output back and move the head one cell.
|
||||
*
|
||||
* No matching transition means the machine halts. Whether that counts as
|
||||
* accepting is decided by the word under the head, not by a separate state —
|
||||
* this is the mobile-automaton formulation, where state is encoded in the tape
|
||||
* symbols themselves (see the Busy Beaver preset above).
|
||||
*
|
||||
* @returns {boolean} true if a step was taken, false if the machine halted.
|
||||
*/
|
||||
function stepMachine() {
|
||||
if (!machine || terminated.value) return false;
|
||||
let word = "";
|
||||
@@ -335,6 +370,9 @@ const HEAD_COLOR = "#ffffff";
|
||||
|
||||
let colorOf = {};
|
||||
|
||||
// One palette colour per non-blank symbol, assigned in alphabet order and
|
||||
// wrapping round. Blank stays background-coloured so the history plot shows
|
||||
// only the written cells.
|
||||
function assignColors() {
|
||||
colorOf = {};
|
||||
let k = 0;
|
||||
@@ -353,6 +391,14 @@ let viewLeft = 0;
|
||||
let hctx = null;
|
||||
let tctx = null;
|
||||
|
||||
/**
|
||||
* Size both canvases to the wrapper and clear them.
|
||||
*
|
||||
* Canvas bitmaps are sized in device pixels (cssWidth * devicePixelRatio) so
|
||||
* the drawing is sharp on HiDPI screens; CSS sizes the elements back down.
|
||||
* Every constant below (cell size, 420px history, 56px tape strip) is therefore
|
||||
* multiplied by `dpr`.
|
||||
*/
|
||||
function resetCanvases() {
|
||||
const hc = historyCanvas.value;
|
||||
const tc = tapeCanvas.value;
|
||||
@@ -378,6 +424,15 @@ function resetCanvases() {
|
||||
drawTapeStrip();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw one row of the space-time diagram: the tape at this instant, one pixel
|
||||
* block per cell, appended below the previous row.
|
||||
*
|
||||
* History is never re-rendered from scratch — old rows are scrolled by blitting
|
||||
* the canvas onto itself (drawImage(canvas, dx, dy)) and repainting only the
|
||||
* strip that scrolled in. That keeps the cost per step constant no matter how
|
||||
* long the machine has been running.
|
||||
*/
|
||||
function drawHistoryRow() {
|
||||
if (!hctx || !machine) return;
|
||||
const hc = historyCanvas.value;
|
||||
@@ -418,6 +473,9 @@ function drawHistoryRow() {
|
||||
rowY += cell;
|
||||
}
|
||||
|
||||
/** Redraw the close-up tape strip, centred on the head, with the n cells the
|
||||
* next transition will read highlighted. Fully repainted each time — it is
|
||||
* only ~40 cells wide. */
|
||||
function drawTapeStrip() {
|
||||
if (!tctx || !machine) return;
|
||||
const tc = tapeCanvas.value;
|
||||
@@ -458,6 +516,15 @@ let rafId = 0;
|
||||
let lastTime = 0;
|
||||
let stepDebt = 0;
|
||||
|
||||
/**
|
||||
* Animation loop. Steps are decoupled from frames: `stepDebt` accumulates
|
||||
* elapsed-time * stepsPerSecond and whole steps are drained each frame, so the
|
||||
* simulation runs at the requested rate regardless of display refresh rate.
|
||||
*
|
||||
* dt is clamped to 0.25s so a backgrounded tab does not come back and try to
|
||||
* run thousands of steps at once, and `budget` is capped at 64 steps per frame
|
||||
* so a fast setting cannot freeze the page.
|
||||
*/
|
||||
function frame(now) {
|
||||
rafId = requestAnimationFrame(frame);
|
||||
if (!running.value || !machine) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
<!--
|
||||
Route `/stp2` — a static CSS mock of an osu!-style game menu (coloured blocks
|
||||
over a screenshot). No data, no interaction; mounted outside DefaultLayout so
|
||||
it gets no navbar or footer.
|
||||
STATUS: reachable but experimental; not linked from anywhere in the UI.
|
||||
-->
|
||||
<template>
|
||||
<div class="menu">
|
||||
<div class="header">
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/hotels` — Travelodge price scanner, front end for the FastAPI service
|
||||
* under /py/hotels.
|
||||
*
|
||||
* Two panels behind a tab strip. The form state is created here and passed down
|
||||
* as a prop, so shared fields (origin, guests, travel budget) survive tab
|
||||
* switches; the chosen tab itself is remembered in localStorage.
|
||||
*/
|
||||
import { ref, computed, onMounted } from "vue";
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import Paragraph from "@/components/text/Paragraph.vue";
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "Cheapest night" tab of /hotels: scans a date range (capped at MAX_SPAN_DAYS,
|
||||
* optionally filtered to particular weekdays) and reports the best hotel per
|
||||
* night. Same streaming/abort/ticker mechanics as SingleStayPanel.vue.
|
||||
*/
|
||||
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
|
||||
import SharedFields from "./SharedFields.vue";
|
||||
import HotelRows from "./HotelRows.vue";
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<script setup>
|
||||
/**
|
||||
* The form fields common to both hotel panels (location, guests, railcards,
|
||||
* origin, departure time, travel/distance limits). Mutates the shared `form`
|
||||
* object from useHotelForm() directly — it is a prop by reference on purpose.
|
||||
*/
|
||||
import { CUSTOM_ORIGIN } from "./useHotelForm.js";
|
||||
|
||||
defineProps({
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "Single stay" tab of /hotels: cheapest hotels for one specific check-in date.
|
||||
*
|
||||
* Results stream in: the backend sends a `hotels` event with room prices first,
|
||||
* then a `transport` event per hotel as each route is priced, then `done`. Rows
|
||||
* are patched in place by hotel `code` so the table fills in rather than
|
||||
* reloading, and PENDING_ROUTE marks the not-yet-priced ones.
|
||||
*
|
||||
* An AbortController cancels an in-flight stream; a 1s ticker drives the elapsed
|
||||
* counter. Both are torn down in the `finally` and on unmount.
|
||||
*/
|
||||
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
|
||||
import SharedFields from "./SharedFields.vue";
|
||||
import HotelRows from "./HotelRows.vue";
|
||||
@@ -157,6 +168,15 @@ function buildRequest() {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply one NDJSON event from the search stream.
|
||||
*
|
||||
* Order is `hotels` (room prices for all candidates) -> many `transport`
|
||||
* (one per hotel as its route is priced) -> `done`. Transport events patch the
|
||||
* existing row in place, matched on hotel `code`, so the table fills in
|
||||
* column-by-column instead of being rebuilt — that is what keeps scroll
|
||||
* position and sort order stable while results arrive.
|
||||
*/
|
||||
function applyEvent(ev) {
|
||||
switch (ev.event) {
|
||||
case "hotels":
|
||||
@@ -194,6 +214,8 @@ async function onSearch() {
|
||||
searching.value = true;
|
||||
elapsed.value = 0;
|
||||
saveConfig();
|
||||
// 1s elapsed counter plus an AbortController to cancel the stream; both
|
||||
// are torn down in the finally below and on unmount.
|
||||
ticker = setInterval(() => elapsed.value++, 1000);
|
||||
aborter = new AbortController();
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Route `/` — the professional front door. Deliberately plain: a short bio and a
|
||||
* row of links out to the CV, the personal home page (/stp) and social profiles.
|
||||
* Statically imported by the router (it is the first paint).
|
||||
*/
|
||||
import Link from "@/components/text/Link.vue";
|
||||
import InlineLink from "@/components/text/InlineLink.vue";
|
||||
import Header from "@/components/text/Header.vue";
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Editable cover-letter template (contenteditable paragraphs, print to PDF).
|
||||
* Despite living in views/unused/, this IS live: CV.vue imports it as the
|
||||
* "Cover Letter" tab on /cv.
|
||||
*/
|
||||
import { ref } from "vue";
|
||||
|
||||
const name = ref("Adam French");
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Renders a markdown note fetched from /api/notes/<path> as a blob.
|
||||
* STATUS: no route points here — the /notes link in the Links widget goes to a
|
||||
* separately served path, not this component. Not imported anywhere.
|
||||
*/
|
||||
import Markdown from "@/components/util/Markdown.vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
import axios from "axios";
|
||||
|
||||
Reference in New Issue
Block a user