Custom background picture for the dot matrix headers

Settings → Appearance: upload an image and every page header draws it as
the dot matrix instead of The Creation of Adam, with a clickable focus
point and a switch back to the built-in painting. The browser turns the
image into a brightness grid; only that grid is saved as a setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-11-02 20:13:48 +01:00
1 parent 422e46bf65
commit 02756ddf90
11 files changed
+309 -18

No files matched your search

+17
View File
@@ -2,6 +2,7 @@ import "server-only";
import { eq } from "drizzle-orm";
import { db } from "@/lib/db/client";
import { settings, workerState } from "@/lib/db/schema";
import { type Backdrop, BACKDROP_KEY, parseBackdrop } from "@/lib/backdrop";
import { isLabelColor } from "@/lib/colors";
import { FILE_ROLE_ORDER, FILE_ROLES, type FileRole, type FileRoleStyles } from "@/lib/file-roles";
import { MIN_SPEED_LIMIT, parseSpeedLimit, SPEED_LIMIT_KEY } from "@/lib/download-limit";
@@ -140,3 +141,19 @@ export async function getScanStatus(): Promise<ScanStatus> {
nextScanAt: next?.getTime() ?? null,
};
}
/** The custom picture behind the page headers (Settings → Appearance), or null for the built-in painting. */
export async function getBackdrop(): Promise<Backdrop | null> {
return parseBackdrop(await read<unknown>(BACKDROP_KEY));
}
export async function saveBackdrop(input: unknown): Promise<Backdrop | null> {
if (input == null) {
await db().delete(settings).where(eq(settings.key, BACKDROP_KEY));
return null;
}
const backdrop = parseBackdrop(input);
if (!backdrop) throw new SettingsError("That picture couldn't be read. Try another image.");
await write(BACKDROP_KEY, backdrop);
return backdrop;
}