4.0 KiB
Booksorter
A small local web app for labelling a personal library with Library of Congress call numbers. Hold a book's barcode up to a laptop webcam (or type the ISBN), and Booksorter looks up the call number from the Library of Congress and Open Library, builds a spine label, and prints cards on Avery 5388 sheets (three 3 x 5 inch cards per sheet). Everything runs on your own machine; the only outside traffic is the book lookups made by the server.
Install and run
npm install
npm start
npm start builds the web app into dist/web and serves it at http://localhost:4321 (only reachable from this computer). Set PORT to use another port. If the port is taken, the server says so and exits.
Requires a recent Node (the server runs TypeScript directly).
Scanning
Use the Scan tab. Every way of adding a book ends up in the same session list, where a row goes from "Looking up" to "Ready" (a call number was found) or "Needs attention".
- Camera: click Start camera, allow access, and hold the barcode (the one with 978 or 979 under it, usually on the back cover) steady in view. A beep means it was read. Reading the same book twice is recognised and not added again.
- Typed ISBN: the ISBN box is always focused. Type or paste 10 or 13 digits and press Enter. A USB barcode scanner works the same way, since it types the digits and presses Enter.
- Search by title and author: for books with no barcode. Pick the matching result.
- Enter LCCN: if the book's copyright page prints a Library of Congress Control Number.
- Enter by hand: title, authors, and optionally a call number you already know.
Books marked Needs attention appear on the Print queue tab, where you can retry the lookup, edit the details (including typing a call number), or delete them. Call numbers marked approximate were derived from a Dewey number rather than found in the Library of Congress catalog; check those.
Printing on Avery 5388
On the Print queue tab, choose which of the three positions on the sheet the first card should use (handy for a partly used sheet) and click Make PDF. Cards are printed in shelf order.
- Open the PDF in your PDF viewer and print at Actual size / 100% (never "Fit to page").
- Print single-sided, loading the sheet through the manual feed slot.
- When the cards came out correctly, click Yes, clear these from the queue so they are not printed twice.
If the text sits off-centre on the cards, print the calibration page (Printer alignment, then Print calibration page) on plain paper, hold it against a real sheet up to the light, and enter the X and Y offsets in millimetres (limit 10) that bring it into line. Offsets are saved and applied to every later PDF.
Where the data lives
In data/booksorter.db (SQLite) in this folder, created on first run. Back it up by copying the file while the server is stopped. Set BOOKSORTER_DB to use a different file.
Tests
npm test # unit and server tests
npm run typecheck
The browser check drives Firefox through the real app. It needs a running server, and it adds, removes and re-adds the test book (ISBN 9781593278281 unless ISBN is set), so point the server at a scratch database (BOOKSORTER_DB=/tmp/scratch.db npm start) rather than your real one. The first run looks the book up live, which can take a minute:
npx playwright install firefox # once
npm start # in another terminal
npm run browser-check # or: node scripts/browser-check.ts [url]
Set SHOTS=/some/dir to save screenshots, and ISBN=<isbn13> to use a different already-resolved book. It checks that the page loads cleanly and calls only localhost, the tabs render, a typed ISBN is resolved, a generated EAN-13 barcode is decoded by the same wasm detector the camera uses, Firefox's fake camera starts and stops, and the print queue produces a PDF. It uses a fake camera, so it cannot prove that your own webcam reads real barcodes well.