feat: allow pages to be supplied as separate JSON files#362
Conversation
…ages optional in CODEC
There was a problem hiding this comment.
Code Review
This pull request implements the "Pages as Separate Files" feature, allowing book pages to be stored as individual JSON files. A significant refactoring was performed to rename the anchor field to id across BookPage classes, data generation models, and link handling logic. BookDataManager now includes functionality to load these external page files and merge them into entries, either by replacing inline pages or appending new ones. Review feedback highlights that the path parsing for external page files is currently fragile and should be made more robust to handle nested categories, and suggests using the internal page ID for merge checks to ensure consistency.
a3cb5b7 to
5460a52
Compare
…entryJsons The categorizeContent method was sending all files under entries/ to entryJsons, including page files in entries/<category>/<entry>/pages/ subdirectories. This caused page files (with type modonomicon:text) to be loaded as entries and fail with 'Unknown entry type modonomicon:text'. Also fixed the entry ID computation in mergePageJsons: the entry ID must include the category prefix (e.g. modonomicon:features/custom_icon) to match the entry's actual ID.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements the ability to store book entry pages as separate JSON files in a pages/ subfolder alongside inline pages, with file-based pages taking precedence by matching page ID. It renames the page anchor field to id across all page models, codecs, and client-side link handlers, and introduces loader merge logic in BookDataManager. The review comments identify critical issues, including broken category and entry ID resolution for nested categories, potential UnsupportedOperationException crashes from immutable lists in BookEntryModel and BookContentEntry, non-deterministic page merging due to unsorted map iteration, silent data loss for pages with empty IDs, and unsafe JSON parsing of sort_number.
…ion on immutable lists
…tePagesAsFiles is enabled
…es-as-files # Conflicts: # common/src/main/java/com/klikli_dev/modonomicon/book/BookLink.java # neo/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8
Problem
Pages are currently only stored inline within entry JSONs. This makes it hard to manage large entries with many pages and prevents reusing page content across entries.
Solution
Allow pages to be supplied via one JSON file per page in a subfolder named like the entry: entries///pages/.json
Key Changes