Print the subject hierarchy as a tree on cards, remove the QR code

Each card now shows, under the call number, the Library of Congress
outline levels for its class (from the published outline, down to the
narrowest range) followed by the place or topic from the catalogue
record's subject heading, one level per line. Existing books get the
subject part filled in by a background job at startup that changes
nothing else about them.

The QR code and everything that read it are removed; the subjects line
on the card is replaced by the tree.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-19 14:06:50 -07:00
1 parent c9b2c2e8c9
commit 7ae1bcef0a
46 files changed
+8591 -545

No files matched your search

+4 -14
View File
@@ -37,7 +37,7 @@ const CameraIcon = () => (
* The live camera with its controls on a bar along the bottom edge. `onIsbn` gets every ISBN it reads.
* `captureRef.current` is set to a function that takes one careful picture (it returns false when the camera is off).
*/
export function Camera({ onIsbn, onCard, captureRef }: { onIsbn: (isbn: string) => void; onCard: (text: string) => void; captureRef: { current: (() => boolean) | null } }) {
export function Camera({ onIsbn, captureRef }: { onIsbn: (isbn: string) => void; captureRef: { current: (() => boolean) | null } }) {
const cam = useCamera();
const video = useRef<HTMLVideoElement>(null);
const scanner = useRef<Scanner | null>(null);
@@ -65,18 +65,9 @@ export function Camera({ onIsbn, onCard, captureRef }: { onIsbn: (isbn: string)
say(`Read ${isbn}`, 'ok');
onIsbn(isbn);
};
const gotCard = (text: string) => {
beepAccept();
setFlash(true);
clearTimeout(flashTimer.current);
flashTimer.current = setTimeout(() => setFlash(false), 600);
say('Read a card', 'ok');
onCard(text);
};
const handlers = useRef({ onIsbn: gotIsbn, onCard: gotCard, onOther: () => {}, onEnded: () => {} });
const handlers = useRef({ onIsbn: gotIsbn, onOther: () => {}, onEnded: () => {} });
handlers.current = {
onIsbn: gotIsbn,
onCard: gotCard,
onOther: () => { beepLow(); say('That barcode is not an ISBN', 'warn'); },
onEnded: () => {
scanner.current = null; setState('off'); setStatus(null); updateCamera({ resolution: '' });
@@ -100,7 +91,7 @@ export function Camera({ onIsbn, onCard, captureRef }: { onIsbn: (isbn: string)
setState('starting'); setProblem('');
try {
const sc = await startScanner(video.current, getCamera().deviceId || undefined, {
onIsbn: i => handlers.current.onIsbn(i), onCard: t => handlers.current.onCard(t), onOther: c => handlers.current.onOther(), onEnded: () => handlers.current.onEnded(),
onIsbn: i => handlers.current.onIsbn(i), onOther: c => handlers.current.onOther(), onEnded: () => handlers.current.onEnded(),
}, ac.signal);
if (!sc) return; // turned off or left the screen while the permission prompt was open
if (ac.signal.aborted) { sc.stop(); return; }
@@ -130,8 +121,7 @@ export function Camera({ onIsbn, onCard, captureRef }: { onIsbn: (isbn: string)
try {
const r = await sc.capture(n => say(`Trying… ${n} frames`, 'info', true));
if (scanner.current !== sc) return;
if (r.card) gotCard(r.card);
else if (r.isbn) gotIsbn(r.isbn);
if (r.isbn) gotIsbn(r.isbn);
else if (r.other) { beepLow(); say('That barcode is not an ISBN', 'warn', true); }
else { beepLow(); say(r.saved ? NOT_FOUND_SAVED : NOT_FOUND, 'warn', true); }
} catch {
+2 -3
View File
@@ -1,5 +1,5 @@
import { useEffect, useRef } from 'preact/hooks';
import { addByIsbn, addFromCard } from '../actions.ts';
import { addByIsbn } from '../actions.ts';
import { dialogOpen } from '../dialog.ts';
import { unlockAudio } from '../sound.ts';
import type { EditorTarget } from '../components/Editor.tsx';
@@ -53,8 +53,7 @@ export function Scan({ onEdit }: { onEdit: (t: EditorTarget) => void }) {
return (
<div class="scan">
<div class="scan-left">
<Camera captureRef={capture} onIsbn={isbn => { void addByIsbn(isbn); }}
onCard={text => { void addFromCard(text, id => onEdit({ kind: 'edit', id })); }} />
<Camera captureRef={capture} onIsbn={isbn => { void addByIsbn(isbn); }} />
<LastScan onFix={fix} />
<Entry inputRef={entry} onEdit={onEdit} />
</div>