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 -15
View File
@@ -1,5 +1,5 @@
import { prepareZXingModule } from 'zxing-wasm/reader';
import { acceptCard, acceptRead, markCardEmitted, markEmitted, newReadState } from './readstate.ts';
import { acceptRead, markEmitted, newReadState } from './readstate.ts';
import { cropRect } from './frame.ts';
import { decodeLive, decodeThorough, newLiveState, sharpness, wantsFull } from './decode.ts';
import type { DecodeOutcome, Pixels } from './decode.ts';
@@ -62,8 +62,6 @@ function nextFrame(video: HTMLVideoElement, fallbackMs: number): Promise<void> {
export interface ScannerHandlers {
/** A valid ISBN-13 was read (at most once per 5 seconds per book). */
onIsbn(isbn13: string): void;
/** A Booksorter card's QR code was read (at most once per 5 seconds per card). */
onCard(text: string): void;
/** A barcode was read that is not a book ISBN. */
onOther(code: string): void;
/** The camera stopped by itself (unplugged, taken by another program). */
@@ -150,11 +148,6 @@ export async function startScanner(
const r = await decodeLive(grab(video, c.x, c.y, c.w, c.h), live);
live = r.state;
if (stopped || burst) { /* a burst took over: drop this result */ } else {
if (r.out.card) {
const a = acceptCard(state, r.out.card, Date.now());
state = a.state;
if (a.emit) handlers.onCard(a.emit);
}
for (const code of [r.out.isbn, r.out.other]) {
if (!code) continue;
const a = acceptRead(state, code, Date.now());
@@ -187,17 +180,13 @@ export async function startScanner(
if (!best || score > best.score) best = { full, score };
const out = await decodeThorough(crop, full);
other ??= out.other;
if (out.card) {
state = markCardEmitted(state, out.card, Date.now());
return { isbn: null, other, card: out.card, saved: null };
}
if (out.isbn) {
state = markEmitted(state, out.isbn, Date.now());
return { isbn: out.isbn, other, card: null, saved: null };
return { isbn: out.isbn, other, saved: null };
}
}
if (other) return { isbn: null, other, card: null, saved: null };
return { isbn: null, other: null, card: null, saved: best ? await saveFailed(best.full) : null };
if (other) return { isbn: null, other, saved: null };
return { isbn: null, other: null, saved: best ? await saveFailed(best.full) : null };
} finally {
burst = false;
}