Initial commit

Photo-based book cataloger with AI identification.
Room → Cabinet → Shelf → Book hierarchy; FastAPI + SQLite backend;
vanilla JS SPA; OpenAI-compatible plugin system for boundary
detection, text recognition, and archive search.
This commit is contained in:
night
2026-03-09 14:11:11 +03:00
commit f29678ebf1
64 changed files with 8605 additions and 0 deletions

9
static/css/base.css Normal file
View File

@@ -0,0 +1,9 @@
/*
* base.css
* Global CSS reset, body defaults, and single utility class used throughout
* the app. Must load before all other stylesheets.
*/
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;background:#f1f5f9;color:#1e293b;min-height:100vh}
.hidden{display:none!important}

44
static/css/forms.css Normal file
View File

@@ -0,0 +1,44 @@
/*
* forms.css
* Generic button variants, the book detail right panel, image/canvas wrapper,
* crop selection overlay, book image display boxes, and the identification form
* (card, labels, inputs, textarea, danger zone).
*/
/* ── Buttons ── */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;padding:7px 13px;border-radius:7px;border:none;cursor:pointer;font-size:.83rem;font-weight:500}
.btn:active{opacity:.82}
.btn:disabled{opacity:.4;cursor:default}
.btn-p{background:#2563eb;color:white}
.btn-s{background:#e2e8f0;color:#475569}
.btn-g{background:#16a34a;color:white}
.btn-r{background:#ef4444;color:white}
.btn-w{width:100%;margin-bottom:7px}
.btn-row{display:flex;gap:7px;flex-wrap:wrap;margin-bottom:10px;align-items:center}
/* ── Right panel ── */
.det-empty{display:flex;align-items:center;justify-content:center;height:100%;color:#94a3b8;font-size:.95rem}
/* ── Image + canvas overlay ── */
.img-wrap{position:relative;display:inline-block;max-width:100%;line-height:0;border-radius:7px;overflow:hidden;box-shadow:0 2px 8px rgba(0,0,0,.15)}
.img-wrap img{display:block;max-width:100%;max-height:calc(100vh - 200px);object-fit:contain}
.img-wrap canvas{position:absolute;inset:0;width:100%;height:100%}
/* ── Crop overlay ── */
.crop-sel{position:absolute;border:2px solid #38bdf8;background:rgba(56,189,248,.12);pointer-events:none}
/* ── Book detail panel ── */
.book-panel{display:flex;flex-direction:column;gap:14px}
.book-img-box{border-radius:7px;overflow:hidden;background:#0f172a;line-height:0;box-shadow:0 1px 4px rgba(0,0,0,.2);margin-bottom:8px}
.book-img-box img{max-width:100%;max-height:260px;object-fit:contain;display:block;margin:0 auto}
.book-img-label{font-size:.7rem;color:#64748b;margin-bottom:4px;font-weight:600;text-transform:uppercase;letter-spacing:.04em}
/* ── Form ── */
.card{background:white;border-radius:10px;padding:13px;margin-bottom:10px;box-shadow:0 1px 3px rgba(0,0,0,.07)}
.flabel{display:block;font-size:.7rem;font-weight:700;color:#64748b;text-transform:uppercase;letter-spacing:.04em;margin-bottom:3px}
.finput{width:100%;padding:8px 10px;border:1.5px solid #e2e8f0;border-radius:6px;font-size:.88rem;color:#1e293b;background:white;-webkit-appearance:none}
.finput:focus{outline:none;border-color:#2563eb}
textarea.finput{height:64px;resize:vertical}
.fgroup{margin-bottom:9px}
.dz{border:1.5px solid #fecaca;border-radius:8px;padding:11px;margin-top:12px}
.dz-h{color:#dc2626;font-size:.7rem;font-weight:700;text-transform:uppercase;letter-spacing:.04em;margin-bottom:7px}

36
static/css/layout.css Normal file
View File

@@ -0,0 +1,36 @@
/*
* layout.css
* Top-level layout: sticky header bar, two-column desktop layout
* (300px sidebar + flex main panel), mobile single-column default,
* and the contenteditable header span used for inline entity renaming.
*
* Breakpoint: ≥768px = desktop two-column; <768px = mobile accordion.
*/
/* ── Header ── */
.hdr{background:#1e3a5f;color:white;padding:10px 14px;display:flex;align-items:center;gap:8px;position:sticky;top:0;z-index:100;box-shadow:0 2px 6px rgba(0,0,0,.3);flex-shrink:0}
.hdr h1{flex:1;font-size:.96rem;font-weight:600}
.hbtn{background:none;border:none;color:white;min-width:34px;min-height:34px;border-radius:50%;cursor:pointer;font-size:1rem;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.hbtn:active{background:rgba(255,255,255,.2)}
/* ── Mobile layout (default) ── */
.layout{display:flex;flex-direction:column;min-height:100vh}
.sidebar{flex:1}
.main-panel{display:none}
/* ── Desktop layout ── */
@media(min-width:768px){
body{overflow:hidden}
.layout{flex-direction:row;height:100vh;overflow:hidden}
.sidebar{width:300px;display:flex;flex-direction:column;border-right:1px solid #cbd5e1;overflow:hidden;flex-shrink:0}
.sidebar .hdr{padding:9px 12px}
.sidebar-body{flex:1;overflow-y:auto;padding:8px 10px 16px}
.main-panel{flex:1;display:flex;flex-direction:column;overflow:hidden;background:#e8eef5}
.main-hdr{background:#1e3a5f;color:white;padding:9px 14px;display:flex;align-items:center;gap:8px;flex-shrink:0}
.main-hdr h2{flex:1;font-size:.9rem;font-weight:500;opacity:.9;min-width:0}
.main-body{flex:1;overflow:auto;padding:14px}
}
/* ── Detail header editable name ── */
.hdr-edit{display:block;outline:none;cursor:text;border-radius:3px;padding:1px 4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.hdr-edit:focus{background:rgba(255,255,255,.15);white-space:normal;overflow:visible}

31
static/css/overlays.css Normal file
View File

@@ -0,0 +1,31 @@
/*
* overlays.css
* Fixed-position overlays that appear above all other content:
* - Toast notification (bottom-center slide-in)
* - Loading spinner and empty-state placeholder
* - Photo Queue overlay: full-screen mobile flow for photographing
* unidentified books in sequence (spine preview + camera button)
*/
/* ── Toast / loading ── */
.toast{position:fixed;bottom:16px;left:50%;transform:translateX(-50%) translateY(120px);background:#1e293b;color:white;padding:7px 15px;border-radius:6px;font-size:.82rem;transition:transform .25s;z-index:9999;pointer-events:none;white-space:nowrap}
.toast.on{transform:translateX(-50%) translateY(0)}
.loading{display:flex;align-items:center;justify-content:center;padding:30px;gap:8px;color:#64748b;font-size:.88rem}
.spinner{width:20px;height:20px;border:3px solid #e2e8f0;border-top-color:#2563eb;border-radius:50%;animation:spin .8s linear infinite;flex-shrink:0}
@keyframes spin{to{transform:rotate(360deg)}}
.empty{text-align:center;padding:36px 12px;color:#94a3b8}
.empty .ei{font-size:2.4rem;margin-bottom:7px}
/* ── Photo Queue Overlay ── */
#photo-queue-overlay{position:fixed;inset:0;background:#0f172a;z-index:200;flex-direction:column;color:white}
.pq-hdr{display:flex;align-items:center;gap:8px;padding:12px 14px;background:#1e3a5f;flex-shrink:0;box-shadow:0 2px 6px rgba(0,0,0,.3)}
.pq-hdr-title{flex:1;font-size:.9rem;font-weight:600;text-align:center}
.pq-spine-wrap{flex:1;display:flex;align-items:center;justify-content:center;padding:16px;min-height:0;flex-direction:column;gap:12px;overflow:hidden}
.pq-spine-img{max-width:100%;max-height:52vh;object-fit:contain;border-radius:8px;box-shadow:0 4px 20px rgba(0,0,0,.6)}
.pq-book-name{font-size:.85rem;color:#94a3b8;text-align:center;max-width:90%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pq-actions{display:flex;align-items:center;justify-content:center;gap:24px;padding:20px 16px;flex-shrink:0;background:#1e293b;border-top:1px solid rgba(255,255,255,.1)}
.pq-camera-btn{background:#2563eb;color:white;border:none;border-radius:50%;width:76px;height:76px;font-size:2rem;display:flex;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0;box-shadow:0 4px 16px rgba(37,99,235,.4)}
.pq-camera-btn:active{background:#1d4ed8;transform:scale(.94)}
.pq-skip-btn{background:rgba(255,255,255,.1);color:#cbd5e1;border:none;border-radius:8px;padding:12px 18px;font-size:.85rem;cursor:pointer;min-width:70px}
.pq-skip-btn:active{background:rgba(255,255,255,.2)}
.pq-processing{position:absolute;inset:0;background:rgba(15,23,42,.88);display:flex;align-items:center;justify-content:center;flex-direction:column;gap:10px;font-size:.9rem}

70
static/css/tree.css Normal file
View File

@@ -0,0 +1,70 @@
/*
* tree.css
* Styles for the sidebar tree: room/cabinet/shelf/book node rows,
* selection highlight, segment-hover highlight (synced with boundary canvas),
* drag handle, expand toggle, inline name spans, per-level action icon buttons,
* book thumbnail + metadata layout, status badges, AI suggestion rows,
* source badges (per archive/plugin), and the "+ Add Room" dashed button.
*/
/* ── Tree nodes ── */
.node{margin-bottom:2px}
.nrow{display:flex;align-items:center;gap:4px;padding:10px 8px;border-radius:7px;user-select:none}
.nrow-room {background:#1e3a5f;color:white;cursor:pointer}
.nrow-cabinet{background:#234e85;color:white;cursor:pointer}
@media(min-width:768px){
.nrow{padding:6px 7px}
}
.nrow-shelf {background:#f8fafc;border:1px solid #e2e8f0;cursor:pointer}
.nrow-book {background:white;cursor:pointer}
.nrow.sel {outline:2px solid #38bdf8;outline-offset:-2px}
.nrow.seg-hover{background:#fef9c3!important}
.nrow-room.seg-hover{background:#2d5b9e!important}
.nrow-cabinet.seg-hover{background:#2d5b9e!important}
.nchildren{padding-left:16px;margin-top:2px}
/* ── Drag handle ── */
.drag-h{color:#94a3b8;cursor:grab;font-size:.9rem;flex-shrink:0;padding:1px 2px;user-select:none;touch-action:none}
.nrow-room .drag-h,.nrow-cabinet .drag-h{color:rgba(255,255,255,.4)}
.drag-ghost{opacity:.4}
/* ── Toggle ── */
.tbtn{background:none;border:none;cursor:pointer;font-size:.75rem;padding:2px;flex-shrink:0;color:inherit;transition:transform .15s;line-height:1}
.tbtn.col{transform:rotate(-90deg)}
/* ── Name (editable) ── */
.nname{flex:1;min-width:0;font-size:.84rem;font-weight:500;outline:none;cursor:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;border-radius:3px;padding:1px 3px}
.nname:focus{background:rgba(255,255,255,.18);white-space:normal;overflow:visible}
.nrow-shelf .nname,.nrow-book .nname{color:#334155;font-weight:400}
/* ── Action buttons ── */
.nacts{display:flex;align-items:center;gap:1px;flex-shrink:0}
.ibtn{background:none;border:none;cursor:pointer;font-size:1.1rem;padding:4px 6px;border-radius:4px;color:inherit;opacity:.8;line-height:1;flex-shrink:0;min-width:48px;min-height:48px;display:flex;align-items:center;justify-content:center}
.ibtn:active{background:rgba(0,0,0,.12)}
.ibtn:disabled{opacity:.3;cursor:default}
@media(min-width:768px){
.ibtn{min-width:24px;min-height:24px;font-size:.82rem;padding:2px 4px}
}
/* ── Book row (sidebar) ── */
.bthumb{width:22px;height:30px;object-fit:cover;border-radius:2px;flex-shrink:0}
.bthumb-ph{width:22px;height:30px;background:#e2e8f0;border-radius:2px;display:flex;align-items:center;justify-content:center;font-size:.65rem;color:#94a3b8;flex-shrink:0}
.binfo{flex:1;min-width:0}
.bttl{font-size:.8rem;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bsub{font-size:.7rem;color:#64748b;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sbadge{display:inline-block;font-size:.6rem;font-weight:700;padding:1px 5px;border-radius:3px;flex-shrink:0;text-transform:uppercase;letter-spacing:.03em}
.s-unid{background:#e2e8f0;color:#64748b}.s-aiid{background:#fef3c7;color:#b45309}.s-appr{background:#dcfce7;color:#15803d}
.ai-sug{display:flex;align-items:center;gap:5px;background:#eff6ff;border:1px solid #bfdbfe;border-radius:5px;padding:3px 8px;margin-bottom:4px;font-size:.8rem}
.ai-sug em{flex:1;color:#1e40af;font-style:normal;min-width:0;overflow:hidden;text-overflow:ellipsis}
.src-badge{display:inline-block;font-size:.58rem;font-weight:700;padding:1px 4px;border-radius:3px;text-transform:uppercase;letter-spacing:.03em;white-space:nowrap;flex-shrink:0}
.src-vlm,.src-vlm_spine,.src-vlm_shelves,.src-vlm_books{background:#ede9fe;color:#7c3aed}
.src-ai,.src-ai_search{background:#fef3c7;color:#b45309}
.src-openlibrary{background:#dbeafe;color:#1d4ed8}
.src-rsl{background:#dcfce7;color:#15803d}
.src-rusneb{background:#fce7f3;color:#be185d}
.src-alib,.src-alib_web,.src-alib_telegram{background:#fff7ed;color:#c2410c}
.src-nlr{background:#f1f5f9;color:#475569}.src-shpl{background:#f1f5f9;color:#475569}
/* ── Add-root button ── */
.add-root{display:block;width:100%;padding:9px;background:#f1f5f9;border:2px dashed #94a3b8;border-radius:7px;color:#64748b;font-size:.84rem;cursor:pointer;margin-top:8px;text-align:center}
.add-root:active{background:#e2e8f0}