Trim comments to the non-obvious why
Drop narration, history and restated-code comments across the repo, keep short ones for security boundaries, upstream quirks and ordering constraints, and record the convention in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
<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,8 +1,4 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "鸟" widget on /stp — a <Slideshow>. The Places list that used to share it
|
||||
* as a second tab is its own widget now, views/home/Places.vue.
|
||||
*/
|
||||
import Slideshow from "@/components/util/Slideshow.vue";
|
||||
|
||||
const images = [{ url: "/img/memes/pidgeon.gif", comment: "鸟" }];
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "Consumption" widget on /stp (books/films/games logged as activities). Same
|
||||
* shape as Favorites.vue — both are ListWidget.vue with a different store.
|
||||
*/
|
||||
import ListWidget from "@/views/home/ListWidget.vue";
|
||||
|
||||
import { defineAsyncComponent } from "vue";
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "Favorites" widget on /stp. All of the markup lives in ListWidget.vue; this
|
||||
* file only binds the favourites store and the (lazily imported) create form.
|
||||
*/
|
||||
import ListWidget from "@/views/home/ListWidget.vue";
|
||||
|
||||
import { defineAsyncComponent } from "vue";
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
<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.
|
||||
*/
|
||||
/** Blog posts one at a time; delete only for the author. */
|
||||
import Button from "@/components/input/Button.vue";
|
||||
import Markdown from "@/components/util/Markdown.vue";
|
||||
import Modal from "@/components/util/Modal.vue";
|
||||
|
||||
@@ -1,20 +1,5 @@
|
||||
<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.
|
||||
*/
|
||||
/** The "Rowing" widget on /stp: a hand-drawn SVG chart of sessions. */
|
||||
import { ref, computed, defineAsyncComponent } from "vue";
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import Modal from "@/components/util/Modal.vue";
|
||||
@@ -32,8 +17,7 @@ const showCreate = ref(false);
|
||||
|
||||
// slice() first: reverse() mutates in place and would reorder the store's array.
|
||||
const rows = computed(() => rowingSessions.value.slice().reverse());
|
||||
// `settled`, not `loaded`: a home query that fails never sets `loaded`, and the
|
||||
// error branch below would be unreachable behind a permanent spinner.
|
||||
// `settled`, not `loaded`, or a failed query spins forever.
|
||||
const loading = computed(() => !settled.value);
|
||||
|
||||
const metric = ref("distance");
|
||||
@@ -70,9 +54,7 @@ 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.
|
||||
// `range || 1` guards identical values; a single point is centred.
|
||||
const points = computed(() => {
|
||||
const data = chartData.value;
|
||||
const n = data.length;
|
||||
|
||||
@@ -1,28 +1,7 @@
|
||||
<script setup>
|
||||
/**
|
||||
* STATUS: legacy — no route points here. `/stp` is now a canvas page (see
|
||||
* views/canvas/CanvasPage.vue); views/home3/defaultLayout.js is this page's
|
||||
* arrangement redrawn as boxes, offered as the "Old /stp grid" starter.
|
||||
* Kept for reference.
|
||||
*
|
||||
* Was 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.
|
||||
*
|
||||
* Below 1360px there is no room for the sidebars, so their widgets collapse
|
||||
* into a single tabbed panel under the sheet. That is done purely in CSS — the
|
||||
* tab bar only sets `data-tab` on the wrapper and the media query hides the
|
||||
* other widgets — so every widget stays mounted exactly once at every width
|
||||
* (Chat holds a WebSocket, Steam a rotation timer) and resizing across the
|
||||
* breakpoint loses no state.
|
||||
*
|
||||
* 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: Intro3 and Gym2, not Intro/Intro2/Gym.
|
||||
* STATUS: legacy — no route points here. `/stp` is a canvas page now;
|
||||
* views/home3/defaultLayout.js is this grid redrawn as boxes. Kept for reference.
|
||||
*/
|
||||
import Timer from "@/components/util/Timer.vue";
|
||||
import Time from "@/components/util/Time.vue";
|
||||
@@ -45,8 +24,6 @@ import Bookmarks from "./Bookmarks.vue";
|
||||
|
||||
import { ref } from "vue";
|
||||
|
||||
// Small-screen tab bar. `id` matches the [data-tab] selectors in the tablet
|
||||
// media query below.
|
||||
const TABS = [
|
||||
{ id: "chat", label: "Chat" },
|
||||
{ id: "bookmarks", label: "Bookmarks" },
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
<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.
|
||||
* Bouncing phrases. Animation state is a plain array, not the reactive
|
||||
* `items`, to avoid a re-render per frame; sizes are cached until resize.
|
||||
*/
|
||||
import { rand } from "@vueuse/core";
|
||||
import { ref, onMounted, onUnmounted, nextTick } from "vue";
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* Intro tile: Bad Apple rendered as ASCII text.
|
||||
*
|
||||
* Source is `vue/public/img/badapple.mp4`, bound via a const rather than written
|
||||
* as a literal `src` because Vite would otherwise try to resolve it as a bundled
|
||||
* asset import; files under public/ are served as-is and must stay unbundled.
|
||||
*
|
||||
* The <video> stays in the DOM (hidden,
|
||||
* muted, looping) because only a playing element decodes frames — drawing a
|
||||
* detached/paused video to a canvas yields nothing.
|
||||
*
|
||||
* Per frame we downscale the video straight into a tiny canvas whose pixel grid
|
||||
* IS the character grid, so the browser's scaler does the averaging for us and
|
||||
* we read back exactly one pixel per character. Sampling is throttled to ~24fps
|
||||
* (source framerate); the grid is only re-measured on resize, since reading
|
||||
* offsetWidth every frame forces a synchronous layout.
|
||||
* Bad Apple as ASCII. The src is a const so Vite doesn't bundle a public/
|
||||
* file. The hidden <video> must keep playing to decode frames. Each frame is
|
||||
* downscaled into a canvas whose pixels are the character grid.
|
||||
*/
|
||||
import { ref, useTemplateRef, onMounted, onUnmounted } from "vue";
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
<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,13 +1,5 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Shared shape of the "favs" and "Consumption" widgets on /stp: a header with a
|
||||
* create toggle, a self-scrolling <AutoScroll> list rendered through
|
||||
* <LinkTable>, and an admin-only create form in a <Modal>.
|
||||
*
|
||||
* `createForm` is the component to show in the modal. The hosts pass a
|
||||
* defineAsyncComponent() so the admin form is still only fetched when a widget
|
||||
* is actually opened.
|
||||
*/
|
||||
/** Shared list widget; hosts pass `createForm` as an async component. */
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import CreateToggle from "@/components/input/CreateToggle.vue";
|
||||
import LinkTable from "@/components/util/LinkTable.vue";
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<script setup>
|
||||
/**
|
||||
* "Listening" widget on /stp: rotates through recent Spotify plays.
|
||||
*
|
||||
* Two timers, both owned by useRotation(): a 5s rotation and a 2-minute re-poll
|
||||
* of Spotify.
|
||||
*/
|
||||
/** Rotates recent Spotify plays (5s) and re-polls every 2 minutes. */
|
||||
import Header from "@/components/text/Header.vue";
|
||||
import { computed, onMounted } from "vue";
|
||||
import { useSongsStore } from "@/stores/songs";
|
||||
@@ -24,19 +19,13 @@ const { idx, next: nextSong } = useRotation(() => songsStore.songs, ROTATE_MS, {
|
||||
|
||||
const song = computed(() => songsStore.songs[idx.value]);
|
||||
|
||||
// Admin-only reconnect: when spotifyNeedsReauth comes back true the backend
|
||||
// has no Spotify client (OAuth never completed or the token was revoked), so
|
||||
// the widget offers the OAuth start endpoint instead of the template song.
|
||||
// Non-admins get none of this.
|
||||
// Admin-only: offers the OAuth start when the backend has no Spotify client.
|
||||
const auth = useAuthStore();
|
||||
const showReconnect = computed(
|
||||
() => auth.loggedIn && auth.user.admin && songsStore.needsReauth,
|
||||
);
|
||||
|
||||
// GET /api/spotify/auth returns { url } — the Spotify authorisation URL with
|
||||
// a one-shot state nonce. Navigating to it runs the OAuth dance; the callback
|
||||
// installs the client server-side. Errors are swallowed: the widget simply
|
||||
// stays as it was.
|
||||
// Errors are swallowed; the widget stays as it was.
|
||||
async function reconnect() {
|
||||
try {
|
||||
const { url } = await api.get("/spotify/auth");
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Places-to-go widget: the <PlacesTable> under a header whose "+" opens the
|
||||
* create form. Sign-in only, like the places mutations themselves, so a
|
||||
* signed-out visitor gets a one-line prompt instead of an empty table.
|
||||
*
|
||||
* Its own "+" rather than <CreateToggle>, because that one is admin-only and
|
||||
* Places widget. Its own "+" rather than <CreateToggle>, which is admin-only:
|
||||
* any signed-in user may add a place.
|
||||
*/
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<script setup>
|
||||
/**
|
||||
* The Places-to-go table inside the Places widget (Places.vue). 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.
|
||||
*/
|
||||
/** Sign-in only; fetched lazily, at most once. */
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { usePlacesStore } from "@/stores/places";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
@@ -17,9 +11,8 @@ const loggedIn = computed(() => auth.loggedIn);
|
||||
const removeTarget = ref(null);
|
||||
const confirmationOpen = ref(false);
|
||||
|
||||
// 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 for the already signed in, the watcher for signing in later;
|
||||
// !loaded && !loading stops both firing.
|
||||
onMounted(() => {
|
||||
if (loggedIn.value && !places.loaded && !places.loading) places.fetch();
|
||||
});
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
<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 the
|
||||
* wall is re-sized whenever the cell is.
|
||||
*
|
||||
* The wall is a fixed-track grid whose column and row counts are derived from
|
||||
* the cell's own size (see fitWall), so it always overflows on both axes. A
|
||||
* wrapping flex row only overflowed when the cell happened to be narrower than
|
||||
* the wall, which left it motionless at tablet widths.
|
||||
* 88x31 webring stamps on /stp, drifting and bouncing. The grid is sized from
|
||||
* the cell (fitWall) so it always overflows both axes.
|
||||
*/
|
||||
import { ref, computed, onMounted, onUnmounted } from "vue";
|
||||
|
||||
@@ -32,8 +22,6 @@ let srcs = [
|
||||
"/img/stamps/tf2.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);
|
||||
|
||||
// The two linked stamps stay first; the shuffled local ones follow.
|
||||
@@ -54,9 +42,7 @@ const touchscreen = ref(null);
|
||||
const cols = ref(4);
|
||||
const rows = ref(4);
|
||||
|
||||
// Every grid slot is filled, cycling through the stamps when the wall needs
|
||||
// more slots than there are stamps — a ragged last row would leave a blank
|
||||
// strip drifting into view.
|
||||
// Cycle stamps to fill every slot; a ragged row would show a blank strip.
|
||||
const cells = computed(() =>
|
||||
Array.from(
|
||||
{ length: cols.value * rows.value },
|
||||
@@ -64,11 +50,7 @@ const cells = computed(() =>
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Size the wall to between one and two stamps larger than the cell on each
|
||||
* axis, so there is always something to bounce across whatever the page size.
|
||||
* Rows are also raised, if need be, until every stamp appears at least once.
|
||||
*/
|
||||
/** One to two stamps larger than the cell per axis; enough rows to show every stamp. */
|
||||
function fitWall() {
|
||||
const el = touchscreen.value?.$el;
|
||||
if (!el) return;
|
||||
@@ -87,13 +69,7 @@ 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 fitWall changes the bounds whenever the cell is resized.
|
||||
*/
|
||||
/** Writes scroll position directly (no re-render) and re-reads bounds each frame. */
|
||||
function bounce() {
|
||||
const el = touchscreen.value?.$el;
|
||||
if (!el) return;
|
||||
@@ -129,8 +105,7 @@ function bounce() {
|
||||
|
||||
onMounted(() => {
|
||||
fitWall();
|
||||
// The cell's size follows the box it sits in, not just window resizes, so
|
||||
// observe the element.
|
||||
// The cell follows its box, not just the window.
|
||||
resizeObserver = new ResizeObserver(fitWall);
|
||||
resizeObserver.observe(touchscreen.value.$el);
|
||||
animId = requestAnimationFrame(bounce);
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<script setup>
|
||||
/**
|
||||
* Steam widget on /stp: online status plus a rotation through recent games
|
||||
* (5s rotation, 5-minute re-poll, both from useRotation()). `settled` comes from
|
||||
* homeData so the widget can tell "not fetched yet" from "fetched, nothing to
|
||||
* show" — and, unlike `loaded`, it also turns true when the fetch fails, so the
|
||||
* widget cannot sit on "Loading..." forever.
|
||||
*/
|
||||
/** Online status and recent games. Uses `settled` so a failure can't spin forever. */
|
||||
import { computed } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useSteamStore } from "@/stores/steam";
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
<script setup>
|
||||
/**
|
||||
* STATUS: no route points here — removed so /shrines/demoman can be made
|
||||
* again as a canvas page (views/canvas/CanvasPage.vue). The clips are still
|
||||
* in public/img/demoman/.
|
||||
*
|
||||
* Was route `/shrines/demoman` — a wall of TF2 Demoman clips via <VideoTable>.
|
||||
*/
|
||||
/** STATUS: unrouted; /shrines/<name> are canvas pages now. */
|
||||
import VideoTable from "@/components/util/VideoTable.vue";
|
||||
import Link from "@/components/text/Link.vue";
|
||||
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<script setup>
|
||||
/**
|
||||
* STATUS: no route points here — /shrines/<name> is a canvas page now
|
||||
* (views/canvas/CanvasPage.vue), created from the /shrines index.
|
||||
*
|
||||
* Was route `/shrines/evangelion` — placeholder, renders <Wip>.
|
||||
*/
|
||||
/** STATUS: unrouted; /shrines/<name> are canvas pages now. */
|
||||
import Wip from "@/components/util/Wip.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<script setup>
|
||||
/**
|
||||
* STATUS: no route points here — /shrines/<name> is a canvas page now
|
||||
* (views/canvas/CanvasPage.vue), created from the /shrines index.
|
||||
*
|
||||
* Was route `/shrines/gto` — placeholder, renders <Wip>.
|
||||
*/
|
||||
/** STATUS: unrouted; /shrines/<name> are canvas pages now. */
|
||||
import Wip from "@/components/util/Wip.vue";
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
<script setup>
|
||||
/**
|
||||
* STATUS: unused — unrouted. /shrines is now an admin-made canvas page whose
|
||||
* links are boxes; new shrines are made on the admin panel's Pages tab.
|
||||
*
|
||||
* Was route `/shrines` — index of the shrine pages: every canvas page
|
||||
* (views/canvas/) whose address starts with "shrines/", from the pages query.
|
||||
* Admins — and only admins; the server refuses createPage to anyone else
|
||||
* anyway — get a button that opens a form to start one from the Shrine
|
||||
* layout (since removed).
|
||||
*/
|
||||
/** STATUS: unrouted; /shrines is a canvas page now. */
|
||||
import { computed, ref } from "vue";
|
||||
import RouterTable from "@/components/util/RouterTable.vue";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<script setup>
|
||||
/**
|
||||
* STATUS: no route points here — /shrines/<name> is a canvas page now
|
||||
* (views/canvas/CanvasPage.vue), created from the /shrines index.
|
||||
*
|
||||
* Was route `/shrines/skipskipbenben` — placeholder, renders <Wip>.
|
||||
*/
|
||||
/** STATUS: unrouted; /shrines/<name> are canvas pages now. */
|
||||
import Wip from "@/components/util/Wip.vue";
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user