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

+1 -2
View File
@@ -2,12 +2,11 @@ import { cardLines, parseCallNumber } from '../../shared/callnumber.ts';
export const APPROX_TIP = 'Number borrowed from another edition';
export const SIMILAR_TIP = 'Number borrowed from similar books';
export const CARD_TIP = 'Number read from its card, marked approximate there';
/** A call number in two monospaced lines, the way it is printed on the card. `~` marks an approximate one. */
export function CallNo({ value, approximate, source, large }: { value: string | null; approximate?: boolean; source?: string | null; large?: boolean }) {
const similar = source === 'similar';
const tip = similar ? SIMILAR_TIP : source === 'card' ? CARD_TIP : APPROX_TIP;
const tip = similar ? SIMILAR_TIP : APPROX_TIP;
const cls = 'callno' + (large ? ' callno-large' : '');
if (!value) return <span class={cls + ' callno-none'} aria-label="No call number yet">–</span>;
const cn = parseCallNumber(value);
+17
View File
@@ -11,6 +11,7 @@ import { Panel } from './Panel.tsx';
import { moveActive, ResultList } from './Results.tsx';
import { Spinner } from './StateMark.tsx';
import { composeNumber, findNeighbours } from '../shelve.ts';
import { displayLevels } from '../../shared/hierarchy.ts';
/** `new` may carry what was typed in the entry box. */
export type EditorTarget = { kind: 'edit'; id: number } | { kind: 'new'; title?: string; authors?: string };
@@ -48,6 +49,15 @@ function EditorForm({ book, fixing, initial, onClose }: {
const [busy, setBusy] = useState(false);
const [confirming, setConfirming] = useState(false);
// Where the call number sits in the classification, in words (from the server, which holds the outline).
const [levels, setLevels] = useState<string[]>([]);
useEffect(() => {
if (!book) return;
let current = true;
api.hierarchy(book.id).then(h => { if (current) setLevels(displayLevels(h)); }, () => {});
return () => { current = false; };
}, [book?.id, book?.callNumber, book?.hierarchyTail]);
async function run(fn: () => Promise<void>) {
setBusy(true); setError('');
try { await fn(); } catch (e) { setError((e as Error).message); }
@@ -123,6 +133,13 @@ function EditorForm({ book, fixing, initial, onClose }: {
<input class="mono" value={callNumber} onInput={e => setCallNumber(e.currentTarget.value)} />
<span class="help">{book ? 'Changing this locks the number' : 'Optional. Leave it empty to have it looked up.'}</span>
</label>
{book && levels.length ? (
<p class="crumbs" aria-label="Where this number sits in the classification">
{levels.map((l, i) => i === levels.length - 1
? <span key={i} class="crumb-last">{l}</span>
: <span key={i}>{l} <span aria-hidden="true">›</span> </span>)}
</p>
) : null}
<ShelveWith exclude={book?.id} compose={neighbour => composeNumber(neighbour, splitAuthors(authors), title, yearValue(year))}
onChoose={setCallNumber} />
{error ? <p class="error" role="alert">{error}</p> : null}