Trim comments to the non-obvious why
Test and deploy / test (push) Successful in 28s
Test and deploy / deploy (push) Successful in 31s

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:
2026-11-24 20:49:03 +00:00
co-authored by Claude Opus 5.5
parent effddd2794
commit 4530cb8dc4
222 changed files with 1173 additions and 5423 deletions
+1 -6
View File
@@ -1,10 +1,5 @@
<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.
*/
/** Decorative waybar-style footer; only the clock is real. */
import { ref, onMounted, onUnmounted } from "vue";
const clock = ref("");
+1 -10
View File
@@ -1,14 +1,5 @@
<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.
*/
/** Top bar: an UP button to the parent path (hidden at the root) and a marquee. */
import Headline from "@/components/text/Headline.vue";
import { computed } from "vue";
import { useRoute } from "vue-router";
+1 -5
View File
@@ -1,9 +1,5 @@
<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.
*/
/** Explicit modelValue/emit rather than defineModel, so ToggleHeader can intercept. */
import { ref } from "vue";
const props = defineProps({
+4 -12
View File
@@ -1,14 +1,8 @@
<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.
* Infinite marquee: the slot rendered twice and wrapped by one copy's width.
* Plain `let` and direct style writes avoid a re-render per frame; width comes
* from a ResizeObserver to avoid forced layouts.
*/
import { onMounted, useTemplateRef, onUnmounted } from "vue";
@@ -51,9 +45,7 @@ function animate() {
let resizeObserver;
onMounted(() => {
// A visitor who asked the OS for less motion gets the text standing still.
// The CSS reduced-motion override in styles.css can't reach this: the
// movement is a transform written every frame, not a transition.
// styles.css's reduced-motion rule can't reach a per-frame transform.
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
measureWidth();
+1 -5
View File
@@ -1,9 +1,5 @@
<script setup>
/**
* Link styled to sit inside running prose (bold italic, no underline). Same
* `to` vs `href` and auto-`rel` behaviour as Link.vue, shared through
* useLinkAttrs.js.
*/
/** Link.vue styled for running prose. */
import { linkProps, useComputedRel } from "@/components/text/useLinkAttrs";
const props = defineProps({ ...linkProps });
+1 -6
View File
@@ -1,10 +1,5 @@
<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
* (shared with InlineLink.vue via useLinkAttrs.js).
*/
/** <RouterLink> for `to`, <a> for `href`; `bare` drops the styling. */
import { linkProps, useComputedRel } from "@/components/text/useLinkAttrs";
const props = defineProps({
+2 -6
View File
@@ -1,11 +1,7 @@
<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.
* The whole bar toggles; the inner button is pointer-events-none so a click
* can't fire twice.
*/
import { ref } from "vue";
import ToggleButton from "@/components/input/ToggleButton.vue";
+1 -8
View File
@@ -1,6 +1,3 @@
// Shared link behaviour for components/text/Link.vue and InlineLink.vue, which
// render the same thing (a <RouterLink> for `to`, an <a> for `href`) and differ
// only in styling.
import { computed } from "vue";
@@ -12,11 +9,7 @@ export const linkProps = {
rel: { type: String, default: undefined },
};
/**
* `rel` for the rendered <a>: an explicit `rel` prop wins, otherwise
* target="_blank" links get noopener/noreferrer so the opened page cannot
* reach back through window.opener.
*/
/** target="_blank" gets noopener/noreferrer unless `rel` is given. */
export function useComputedRel(props) {
return computed(() => {
if (props.rel !== undefined) return props.rel;
+3 -11
View File
@@ -11,14 +11,8 @@
<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.
* Drifts its content up and down, pausing at each end. Clamped to
* 0.001..0.999 so the end test doesn't re-fire the pause.
*/
import { useTemplateRef, onMounted, onBeforeUnmount } from "vue";
@@ -36,9 +30,7 @@ let cachedScrollHeight = 0;
function measureScrollHeight() {
const el = container.value;
// Scrollable range, not full content height: scrollTop saturates at
// scrollHeight - clientHeight, so using scrollHeight would stop the drift
// one viewport short of the end while pos still climbed to 1.
// scrollTop saturates here, not at scrollHeight.
if (el) cachedScrollHeight = Math.max(0, el.scrollHeight - el.clientHeight);
}
+1 -5
View File
@@ -1,9 +1,5 @@
<script setup>
/**
* The public chat widget. All of it is ChatPanel.vue; the admins-only channel
* is the separate PrivateChat.vue widget. This file keeps the name the canvas
* stores ("Chat" in widgetRegistry.js) pointing at the public channel.
*/
/** Public chat; the name "Chat" is what canvas boxes store (widgetRegistry.js). */
import ChatPanel from "./ChatPanel.vue";
</script>
+7 -29
View File
@@ -1,17 +1,7 @@
<script setup>
/**
* One chat channel: message list, composer, file attach and admin delete.
* Drives stores/messages.js. Not a widget itself — Chat.vue shows the public
* channel and PrivateChat.vue the admins-only one.
*
* The socket carries both channels in one stream (the server only sends
* private messages to admin connections), so `isPrivate` picks which half of
* `messages` to show and also marks what you send — you cannot post to a
* channel you are not looking at.
*
* Holds the socket while mounted — connect() on mount, disconnect() on
* unmount; the store counts them, so two panels share one socket and it
* exists only while a chat is on screen.
* One chat channel over stores/messages.js. `isPrivate` picks which messages
* to show and marks what you send. Holds a socket reference while mounted.
*/
import { ref, computed, watch, nextTick, onMounted, onUnmounted } from "vue";
import Button from "@/components/input/Button.vue";
@@ -34,14 +24,11 @@ const props = defineProps({
isPrivate: { type: Boolean, default: false },
});
// The private panel is the only place private messages are shown, so the
// public one stays public even for an admin.
const messages = computed(() =>
messagesStore.messages.filter((m) => !!m.private === props.isPrivate),
);
// 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.
// Don't yank a reader scrolled up into history.
const isNearBottom = ref(true);
const SCROLL_THRESHOLD = 100;
let resizeObserver = null;
@@ -94,23 +81,16 @@ async function onFileSelected(e) {
const file = e.target.files[0];
if (!file) return;
isNearBottom.value = true;
// The private flag both routes the upload to /uploads/private/ and marks the
// message itself private; the two must agree.
await messagesStore.uploadAndSendFile(file, props.isPrivate);
fileInput.value.value = "";
}
// Attachments are rendered only if isUploadUrl() accepts them: the fileUrl
// arrives over the socket and is otherwise attacker-controlled.
// fileUrl is attacker-controlled; render only if isUploadUrl() accepts it.
// 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.
// A /g regex keeps lastIndex; safe only because the loop runs exec() to null.
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. */
/** Text/link parts, so URLs render as anchors without v-html. */
function parseMessageParts(text) {
const parts = [];
let lastIndex = 0;
@@ -140,9 +120,7 @@ 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.
// Media loads after insert and changes the height.
if (messagesInner.value) {
resizeObserver = new ResizeObserver(scrollToBottomIfNear);
resizeObserver.observe(messagesInner.value);
+1 -7
View File
@@ -1,11 +1,5 @@
<script setup>
/**
* Sidebar widget showing the most recent Gitea action, read straight from
* homeData.gitFeed (the backend proxies and caches the Gitea API).
*
* The loading state keys off `settled` rather than `loaded` so a failed home
* query ends in "No activity found." instead of loading forever.
*/
/** Latest Gitea action. Keys off `settled` so a failure doesn't spin forever. */
import { useHomeDataStore } from "@/stores/homeData";
import { storeToRefs } from "pinia";
import Header from "@/components/text/Header.vue";
+1 -9
View File
@@ -1,13 +1,5 @@
<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> (and a
* .h-fit.w-full div); without a title the items are rendered bare. The items
* themselves live in LinkTableItems.vue so both branches share one copy.
* Used by the Bookmarks, Favorites, Consumption and Links widgets.
*/
/** {name, link, type} items as a list or table, collapsible when given `title`. */
import { ref } from "vue";
import LinkTableItems from "@/components/util/LinkTableItems.vue";
import ToggleHeader from "@/components/text/ToggleHeader.vue";
+1 -8
View File
@@ -1,12 +1,5 @@
<script setup>
/**
* The body of LinkTable.vue: the items rendered either as stacked link buttons
* (variant="list") or as a two-column table (variant="table").
*
* Split out only so LinkTable can render the same markup inside and outside its
* collapsible <ToggleHeader> wrapper without duplicating it. A component adds no
* DOM of its own, so the rendered output is unchanged.
*/
/** LinkTable's body, shared by its collapsible and bare branches. */
import Link from "@/components/text/Link.vue";
defineProps({
+1 -7
View File
@@ -1,11 +1,5 @@
<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.
*/
/** Markdown with KaTeX. v-html is safe only because DOMPurify runs first. */
import MarkdownIt from "markdown-it";
import { katex } from "@mdit/plugin-katex";
import DOMPurify from "dompurify";
+1 -4
View File
@@ -1,8 +1,5 @@
<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.
*/
/** STATUS: not imported anywhere. Columns are the union of every row's keys. */
import { computed } from "vue";
const props = defineProps({
+2 -5
View File
@@ -1,10 +1,7 @@
<script setup>
/**
* The admins-only chat widget: ChatPanel.vue on the private channel.
*
* The panel is mounted for admins only, so a non-admin never holds the socket
* on its account. The box itself is not hidden: a canvas box shows to everyone
* unless it is marked admin-only, and an empty box would look broken.
* Admins-only chat. The panel mounts only for admins; the box itself stays
* visible, or it would look broken.
*/
import { computed } from "vue";
import ChatPanel from "./ChatPanel.vue";
+2 -6
View File
@@ -16,12 +16,8 @@
<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.
* Icecast widget: probes the stream every 2 minutes and mounts <audio> only
* once it answers (hence nextTick before load()). Volume starts low.
*/
import Button from "@/components/input/Button.vue";
import Header from "@/components/text/Header.vue";
-4
View File
@@ -1,8 +1,4 @@
<script setup>
/**
* 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,
+2 -7
View File
@@ -1,12 +1,7 @@
<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.
* Crossfading image rotator. A re-armed timeout, not setInterval, so a click
* restarts the full delay.
*/
import { ref, computed, onMounted, onUnmounted } from "vue";
import Header from "@/components/text/Header.vue";
-5
View File
@@ -1,9 +1,4 @@
<script setup>
/**
* Clock and date widget. updateDateTime() runs once immediately and then every
* minute, with the interval owned by the component lifecycle so it is cleared
* on unmount.
*/
import Header from "@/components/text/Header.vue";
import { ref, onMounted, onUnmounted } from "vue";
+1 -8
View File
@@ -1,12 +1,5 @@
<script setup>
/**
* Countdown widget with minute/second sliders and a sound on completion.
*
* `state` is an explicit state machine — "idle" (sliders), "running",
* "paused" and "finished" — one screen per state. Completion is decided by
* comparing total elapsed seconds with the total target, so it does not depend
* on the minute and second fields crossing their targets independently.
*/
/** Countdown. Completion compares total seconds, not minutes and seconds apart. */
import Button from "@/components/input/Button.vue";
import Header from "@/components/text/Header.vue";
+1 -7
View File
@@ -13,13 +13,7 @@
</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.
*/
/** Drag-to-scroll. preventDefault stops a text selection mid-drag. */
import { ref } from "vue";
const container = ref(null);
+2 -8
View File
@@ -1,14 +1,8 @@
<script setup>
/**
* Choose a file that is already uploaded, instead of uploading it again: a
* modal grid of every public upload (listUploads in @/uploads), newest first.
* Admin only, because the listing is. Used by the canvas's Background panel,
* Box editor and "+ From uploads" button.
*
* Pick an existing upload (admin only).
* <UploadPicker v-if="picking" v-model="picking" :kinds="['image']" @pick="use" />
*
* `kinds` filters by kindOf(url). The bucket holds hundreds of megabytes, so
* thumbnails load lazily and videos fetch only their metadata.
* Thumbnails load lazily and videos fetch metadata only.
*/
import { computed, ref } from "vue";
import { kindOf, listUploads } from "@/uploads";
+1 -5
View File
@@ -1,9 +1,5 @@
<script setup>
/**
* 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.
*/
/** preload="none" so the page doesn't download every clip. */
defineProps({
sourceArr: {
type: Array,