Skip to content

feat: allow pages to be supplied as separate JSON files#362

Merged
klikli-dev merged 17 commits into
version/26.1.2from
feature/pages-as-files
May 25, 2026
Merged

feat: allow pages to be supplied as separate JSON files#362
klikli-dev merged 17 commits into
version/26.1.2from
feature/pages-as-files

Conversation

@klikli-dev
Copy link
Copy Markdown
Owner

@klikli-dev klikli-dev commented May 25, 2026

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

  • Rename �nchor to id on BookPage — pages now have a proper string id field (previously only had �nchor for cross-entry navigation)
  • Pages optional in entry CODEC — entries no longer require inline pages array
  • File pages replace inline pages — if a page file exists with the same id as an inline page, the file takes precedence
  • New pages inserted via sort_number — pages without a matching inline page use optional sort_number field (default -1 = append at end)
  • Mix and match — inline pages and file pages can coexist in the same entry

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread common/src/main/java/com/klikli_dev/modonomicon/data/BookDataManager.java Outdated
Comment thread common/src/main/java/com/klikli_dev/modonomicon/data/BookDataManager.java Outdated
@klikli-dev klikli-dev force-pushed the feature/pages-as-files branch from a3cb5b7 to 5460a52 Compare May 25, 2026 10:11
…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.
@klikli-dev
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread common/src/main/java/com/klikli_dev/modonomicon/data/BookDataManager.java Outdated
Comment thread common/src/main/java/com/klikli_dev/modonomicon/data/BookDataManager.java Outdated
Comment thread common/src/main/java/com/klikli_dev/modonomicon/data/BookDataManager.java Outdated
…es-as-files

# Conflicts:
#	common/src/main/java/com/klikli_dev/modonomicon/book/BookLink.java
#	neo/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8
@klikli-dev klikli-dev merged commit 96a6bd6 into version/26.1.2 May 25, 2026
@klikli-dev klikli-dev deleted the feature/pages-as-files branch May 25, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant