Commit Graph

27 Commits

Author SHA1 Message Date
john-okeefe 138347c821 fix(progress): use page index for fixed-layout pull sync
The pull path (_doGetProgress + syncToProgress) still used the
reflowable-oriented nav_target selection that prefers xpointer/cfi
over page. For has_pages documents, if the server returned an epubcfi
(e.g., a fake CFI from the web reader's comic renderer), nav_target
became a CFI string, tonumber() returned nil, and GotoPage(nil)
crashed koreader when the user confirmed the sync prompt. After the
crash the old position was retained because GotoPage never completed.

This makes the pull path symmetric with the push path (ef129fd, which
omits epubcfi for paging documents):

- _doGetProgress: for has_pages, select nav_target from progress.page
  and show the actual page number in the sync prompt instead of
  computing it from server_percentage × total_pages (which could
  display the wrong page due to rounding differences between foliate
  and koreader page math).
- syncToProgress: add a nil guard so a missing page number skips
  gracefully instead of crashing.
2026-06-07 00:27:16 -04:00
john-okeefe ef129fdc48 fix(progress): omit epubcfi for paging documents (cbz/pdf/djvu)
collectBookData put getLastProgress() directly into the epubcfi field
for every document. For paging documents (has_pages == true: PDF, CBZ,
CBR, CB7, CBT, DjVu) that value is the current page as a *number*, so
the payload carried "epubcfi": 5 (a JSON number). The server types
KOReaderBookProgress.Epubcfi as *string, and the strict JSON binder
rejected it with a 400 ("cannot unmarshal number into ... epububcfi of
type string"), which the plugin surfaced as the misleading
"Failed to push progress. Check your network connection." Reflowable
EPUBs were unaffected because CREngine returns an xpointer string.

Only set epubcfi for rolling (reflowable) documents. Paging documents
carry their position in the numeric page/total_pages fields, which the
server already treats as the canonical locator for fixed-layout/comic
formats. The pull path already falls back to progress.page, so restore
keeps working.
2026-06-07 00:04:28 -04:00
john-okeefe 85c7783dcf Rename auto sync to 'Automatically push progress' 2026-06-02 19:40:41 -04:00
john-okeefe 366137e49a Guard push against no document open 2026-06-02 19:27:47 -04:00
john-okeefe b96edc6c8f Push/Pull first in menu, fix menu order ID to bookhoard_sync 2026-06-01 21:45:34 -04:00
john-okeefe aaf4741f7e Reorder menu: push/pull at top, remove Sync now, auto-position in tools menu 2026-06-01 21:34:19 -04:00
john-okeefe 192a29211a Show page number in sync prompt instead of percentage 2026-06-01 21:11:22 -04:00
john-okeefe dc68e620af Use koreader_xpointer for GotoXPointer, fallback to percentage 2026-06-01 20:08:44 -04:00
john-okeefe 86b83ff0bc Save book UUID from sync response to doc_settings 2026-05-31 21:09:46 -04:00
john-okeefe ec64e1f5d7 Fix context_text extraction to start from XPointer offset 2026-05-31 20:55:27 -04:00
john-okeefe 109dedc10f Add context_text extraction for text-search-based CFI conversion 2026-05-31 11:55:17 -04:00
john-okeefe 1621f1eaa2 Fix crash: device_updated is boolean not table 2026-05-30 10:33:26 -04:00
john-okeefe 1cef347e9c Fix: require json.util with dot notation not slash 2026-05-30 10:31:12 -04:00
john-okeefe 618793a075 Fix JSON encoding: force empty tables to encode as arrays
Lua's json.encode produces {} for empty tables instead of [].
Use json.util.InitArray to mark tables as arrays so they encode
correctly as [] for authors, bookmarks, highlights, notes, and books.
2026-05-30 10:24:56 -04:00
john-okeefe ac84585e50 Fix progress sync: match server schema for authors and chapter
- authors: changed from string to array (server expects []string)
- chapter: removed (server expects *int, not a title string)
2026-05-30 10:16:46 -04:00
john-okeefe edc4d5b3b5 Fix crash: use string.sub instead of non-existent startswith 2026-05-29 22:57:00 -04:00
john-okeefe 0c215ea00f Fix crash: use util.startswith instead of string method 2026-05-29 22:55:19 -04:00
john-okeefe 98eb57e3f7 Fix OPDS: add auth token to URL and hot-update in-memory servers
- Append ?token= auth param to OPDS catalog URL
- Replace any existing stale Bookhoard entry (with or without token)
- Hot-update OPDS plugin's in-memory servers table so catalog
  appears immediately without restarting KOReader
2026-05-29 22:51:50 -04:00
john-okeefe 89bdcc50f3 Auto-add OPDS catalog to KOReader after device registration
Writes directly to KOReader's opds.lua settings so the user
doesn't have to type the long URL. Also updates the manual
menu item to auto-configure instead of showing the URL.
2026-05-29 22:42:26 -04:00
john-okeefe 517a8d3473 Fix crash: use UIManager:close() instead of non-existent closeAllDialogs 2026-05-29 22:36:08 -04:00
john-okeefe b2aff262e8 Close waiting dialog before showing registration success 2026-05-29 22:32:09 -04:00
john-okeefe 265d6cb689 Fix crash when toggling auto-sync without a document open
Guard nil doc_settings in getBookhoardUUID and skip getProgress
call in toggleAutoSync when no document is loaded.
2026-05-29 22:16:47 -04:00
john-okeefe 4c9c9e98cf Direct users to /devices page for approval 2026-05-29 22:08:54 -04:00
john-okeefe e714aadab3 Simplify registration: direct users to Bookhoard web UI
Instead of showing a long auth URL that's impractical to type on
e-ink, tell users to open their Bookhoard web UI and approve from
Device Management. Uses persistent InfoMessage (no timeout) so
the message stays visible while they switch devices.
2026-05-29 21:55:57 -04:00
john-okeefe 9bea1342db Add sorting_hint to place menu item in Tools section 2026-05-29 21:32:01 -04:00
john-okeefe 1fcc1d9d6b Allow plugin on home screen for OPDS setup and registration 2026-05-29 21:16:27 -04:00
john-okeefe 9d2310d87e Initial KOReader plugin: progress sync, annotations, device registration
Full feature set:
- In-plugin device registration with approval polling
- Reading progress sync (push on page update/close/suspend, pull on open/resume)
- Bookmark, highlight, and note sync via batch annotation collection
- Configurable sync behavior (silent/prompt/disable for forward/backward)
- OPDS catalog setup helper
- SHA-256 book hashing with doc_settings cache
- Debounced API calls with periodic push scheduling
2026-05-29 20:27:50 -04:00