Replace 13 per-accessor static std::string blank locals with a single file-scope kBlank (~384 bytes DRAM saved). Add Epub::getMetadata() returning the full BookMetadata struct. Refactor buildLayout from 14 individual parameters to a single BookMetadata const ref + fileSize. Made-with: Cursor
3.1 KiB
3.1 KiB
Parse and Display All Available EPUB Metadata Fields + Cleanup Refactor
Task
- Extend the OPF parser, metadata cache, Epub accessors, i18n, and BookInfo screen to parse and display all standard Dublin Core metadata fields plus Calibre rating.
- Refactor for code quality: consolidate duplicate static blank strings, add
getMetadata()accessor, and simplifybuildLayoutto acceptBookMetadatastruct.
Changes Made
1. ContentOpfParser (lib/Epub/Epub/parsers/ContentOpfParser.h/.cpp)
- Added 6 new
ParserStateentries:IN_BOOK_PUBLISHER,IN_BOOK_DATE,IN_BOOK_SUBJECT,IN_BOOK_RIGHTS,IN_BOOK_CONTRIBUTOR,IN_BOOK_IDENTIFIER - Added 7 new public string members:
publisher,date,subjects,rights,contributor,identifier,rating - Added
identifierIsIsbnflag for preferring ISBN identifiers over generic ones startElement: handlesdc:publisher,dc:date,dc:subject(multi-tag, comma-separated),dc:rights,dc:contributor(multi-tag, comma-separated),dc:identifier(prefersopf:scheme="ISBN"), andcalibre:ratingmeta tagcharacterData: appends text for all new statesendElement: transitions back toIN_METADATAfor all newdc:*elements
2. BookMetadataCache (lib/Epub/Epub/BookMetadataCache.h/.cpp)
- Added 7 new fields to
BookMetadatastruct - Bumped
BOOK_CACHE_VERSIONfrom 6 to 7 - Updated
metadataSizecalculation (8 → 15 string fields) - Added
writeString/readStringcalls for all new fields in serialization/deserialization
3. Epub Accessors (lib/Epub/Epub.h/.cpp)
- Added 7 new accessor methods:
getPublisher(),getDate(),getSubjects(),getRights(),getContributor(),getIdentifier(),getRating() - Added
getMetadata()returning fullBookMetadataCache::BookMetadataconst ref - Consolidated 13 duplicate
static std::string blanklocals into single file-scopekBlank(saves ~384 bytes DRAM) - Propagated new fields from
opfParsertobookMetadatainparseContentOpf()
4. I18n (lib/I18n/translations/english.yaml, lib/I18n/I18nKeys.h)
- Added 7 new translation keys:
STR_PUBLISHER,STR_DATE,STR_SUBJECTS,STR_RATING,STR_ISBN,STR_RIGHTS,STR_CONTRIBUTOR - Regenerated I18n headers
5. BookInfoActivity (src/activities/home/BookInfoActivity.h/.cpp)
- Refactored
buildLayout()from 14 individual parameters to singleBookMetadataCache::BookMetadatastruct +fileSize onEnter()EPUB path usesepub.getMetadata()directly; XTC path builds a localBookMetadata- Display order: Title, Author, Series, Publisher, Date, Subjects, Rating (N/5), Language, ISBN, Contributor, File Size, Rights, Description
- Rating displayed as
N / 5(Calibre stores 0-10, divided by 2)
Commits
8025e6f—feat: parse and display all available EPUB metadata fields- (pending) —
refactor: consolidate Epub blank strings, simplify BookInfo buildLayout
Follow-up
- Existing book caches will auto-invalidate (version 6 → 7) and regenerate on next load
- Users must delete
.crosspoint/or let it regenerate to see new metadata for previously cached books - Hardware testing needed to verify rendering of all new fields in all orientations