English
Config, Data & Client Contracts
site.config.yaml serves as the single source of truth (SSOT), validated by @gallery/platform to drive data manifests, SQLite generation, Astro static builds, and hosting configuration outputs.
1. site.config.yaml Schema Summary
| Top-Level Key | Key Fields | Defaults & Constraints | Role |
|---|---|---|---|
site | title, domain, lang, tagline, logo | domain defaults to gallery.example.org (blocked in prod release) | Title, HTML lang, canonical & sitemap base domain |
appearance | theme, accent, font, show_search, show_library | theme: paper | ocean | plum; font: sans | serif | Bounded semantic CSS variables without arbitrary CSS injection |
images | hosts, prefix | 1–2 CDN hostnames; safe ASCII prefix (img/) | WebP & DB CDN origins and path prefix |
db | page_size, chunk_size, prefix, whole_download_max_bytes | 4096, 65536, db/, 31457280 (30 MiB) | SQLite alignment, chunk manifest size, and download safety cap |
search | request_chunk_size, min_match_length, api_path | 4096, 3, /api/search | FTS5 starts at three normalized characters. Two use LIKE. The function path is reserved. |
features | range_search, search_function, platform_config, text_layer, comimi_reader | false, false, true, true, false | Optional Range search, reserved function search, host files, dialogue overlay and enhanced pagination |
budgets | max_files, max_file_bytes | 18000 files, 20971520 B (20 MiB) | Static build file count and single-file guards |
headers / redirects | Header rules & redirect map | Sources validated within output root via redirectOutputPaths | Emits platform headers/redirects plus escaped metaRefresh HTML |
seo | indexnow_key | null or 8–128 [A-Za-z0-9-]+ | Writes dist/<key>.txt and enables push:search |
deploy | cloudflare, edgeone, github, workers, esa | Project identifiers & custom domains | Synced into packages/platform/generated/ |
Generated Artifact Separation (@gallery/platform)
GENERATED_FILES(copied todist/whenfeatures.platform_config: true):_headers,_redirects,edgeone.json.DEPLOY_CONFIG_FILES(written topackages/platform/generated/only, never copied todist/):wrangler.jsonc,esa.jsonc.
2. Catalog & Transcript Data Contracts (@gallery/core)
text
data/
├── meta/
│ ├── <series>/series.yaml # SeriesSchema (title, sort, authors, tags, cover key)
│ └── <series>/<issue>.yaml # IssueSchema (number, chapters[], page dimensions & webp keys)
├── text/
│ └── <series>/<issue>/<chapter>.json # ChapterTextSchema (boxes[]: normalized [0,1] x,y,w,h + text)
└── raw/
├── labelplus/<series>/<issue>/<chapter>.txt # LabelPlus 1,0 script
└── ocr/<series>/<issue>/<chapter>.json # Reviewed OCR sourceKey invariants enforced in packages/core/src/schema.js & object-path.js:
- Slugs (
series,issue,chapter) match safe ASCII IDs for deterministic URLs/<series>/<issue>/<chapter>/; - Text box coordinates
(x, y, w, h)stay normalized within[0, 1]; - Object keys (
img/<series>/cover-<hash12>.webp,img/<series>/<issue>/<n>-<hash12>.webp) satisfyisSafeObjectKey.
3. Transcript Ingestion Contracts
LabelPlus (pnpm run ingest:labelplus)
Parses data/raw/labelplus/.../*.txt with strict delimiter matching (>>>>>>>>[filename]<<<<<<<< and ----------------[n]----------------[x,y,group]) so narrative dashes (————, >>>) remain intact, emits 1-based line warnings for malformed separator prefixes, and supports --dry-run, CHAPTERS=..., and LABELPLUS_PAGES=auto|number|sequence.
Re-import preserves existing box IDs only for unique exact text-and-geometry matches. New, changed, or ambiguous boxes get new IDs; removed pages retain their allocation cursor. Retired links fall back to the page. Do not delete the accepted transcript or reset nextBoxId. Reordering or replacing the actual comic pages is outside this automatic guarantee.
OCR Gate (pnpm run ingest:ocr)
Uses a two-step human-review gate:
- Default run requires
CHAPTERS=...and outputs draft JSON + side-by-side HTML toOUT_DIRonly (never touchesdata/text/). - After manual review in
data/raw/ocr/...,CHAPTERS=... pnpm run ingest:ocr -- --accept-reviewedpromotes validated text intodata/text/.
4. Client DOM, Deep-Link & Storage Contracts
- Search Page DOM IDs (
/search/):#search-config,#search-form,#search-input,#search-series,#search-coverage,#search-status,#search-results,#search-more, plus catalog filter#meta-form/#meta-q/#meta-resultsreading/index/series.json. - Deep Links:
/<series>/<issue>/<chapter>/#p<n>focuses pagen;/<series>/<issue>/<chapter>/#p<n>b<i>highlights dialogue box with permanent IDion pagen(retired IDs fall back to the page). - Reading backup includes shelf status (
gallery:library:*), progress (gallery:progress:*), bookmarks (gallery:favorites:*), and notes (gallery:bookmark-note:*, up to 200 characters each). Backups with positions within long images use v2. Page-only backups use v1. Reading mode and theme preferences are local to each device.