mirror of
https://github.com/readest/readest.git
synced 2026-12-01 22:09:19 +00:00
5 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
045beb4d1a
|
feat(crosspoint): sync CrossPoint 2.0 clippings with Readest highlights (#7317)
* feat(crosspoint): sync CrossPoint 2.0 clippings with Readest highlights
CrossPoint 2.0's Sync Clippings first probes
{KOSync server}/api/v1/clippings/{document} for sync_version 2, and stops
the whole sync, progress included, when the probe fails. Readest's KOSync
endpoint had no such route, so a reader signed in with the Readest plugin
showed "Could Not Sync Clippings" and stopped syncing progress once the
setting was on.
- /api/crosspoint/api/v1/clippings/{document} serves the clippings API
(sync_version 2, cursor paging, tombstones). A clipping is a book_notes
highlight whose new `crosspoint` column holds the reader's anchor (spine
plus a code-point range), the way xpointer0/xpointer1 hold KOReader's.
Only items the firmware can decode are sent, up to the 256 an X3/X4
holds per book. A rewritten copy (Optimize EPUB) syncs as the library
book it is linked to, and its first clippings move to that book when
its progress upload links it.
- Readest apps turn a clipping into a CFI when they open the book, and
give each EPUB highlight a CrossPoint anchor when they push it (tried
once a session). Moving a highlight's range drops the old anchors.
- Migration 033 adds book_notes.crosspoint (nullable jsonb). Apply it
before the web deploy.
- Plugin README: CrossPoint 2.0 names and requirements, and highlights.
Fails without the change: useNotesSync-crosspoint (4 of 5, e.g. "turns a
clipping a reader synced into a highlight at its CFI"), transform "carries
the anchor in the crosspoint column, both ways", useAnnotationEditor "a
moved range drops the KOReader and CrossPoint anchors of the old one"
(expected the old xpointer to be undefined), and the route test "moves a
rewritten copy's clippings to the library book it gets linked to". The
clippings route tests can't run without the route.
Verified on a real X4 (CrossPoint 2.0.0) with Sync Clippings on: the
probe and uploads answer 200, a reader clipping shows in Readest on its
words, a Readest highlight shows on the X4, and deletions go both ways.
Reported by itsthisjustin (CrossPoint).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(crosspoint): sync a document a reader names by its file name
A reader set to match documents by file name (CrossPoint's default, and
the alternate lookup of its Smart Sync) sends md5 of the book's file
name, as KOReader does. Since #7237 Readest keeps the name a book was
imported under (books.original_filename), and #7253 digests it the same
way in Readest's own KOSync client.
Progress, clippings and reading sessions now resolve such a document to
the library book imported under that name, link it on first sight like a
rewritten copy, and move clippings saved under the name's id to the book.
When two books were imported under one name, the most recently read one
wins. A document that is a book's own id is never looked up by name, and
an NFD spelling of the name does not match.
Fails without the change: 5 of the 6 tests in "a document named by its
file name", e.g. "syncs it as the library book imported under that name,
linked on first sight" (the link write and the library book's queries
never happen). The sixth, a name no book has, passed before too.
Not run on a device: the books in the test library were imported before
#7237 and have no original_filename.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(crosspoint): page the file-name lookup, and retry a failed clipping move
From CodeRabbit's review of this PR:
- The lookup of the book imported under a file name read the user's books
in one request, and PostgREST answers at most 1000 rows (db-max-rows),
so a match past them was never found. It now pages through them by
book_hash.
- A copy was linked before its clippings moved to the library book, and a
failed move only logged a warning. Every later request followed the
link, so those clippings stayed under the copy's id for good. They now
move first, and a failed move fails that sync, leaving the copy
unlinked so the next sync tries again.
Fails without the change: "finds the book past the first 1000 imported
under a name" (no link written: expected [ …(20) ] to deeply equal
ArrayContaining{…}), and "links a copy only once its clippings have
moved, so a failed move is tried again" (expected 200 to be 500).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
2401d3e230
|
fix(crosspoint): link an optimized copy to the book being read when duplicates tie (#6614)
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (rust) (push) Waiting to run
Publish Docker image / build (linux/amd64, ubuntu-latest) (push) Waiting to run
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Publish Docker image / merge (push) Blocked by required conditions
Build with Nix / tests (push) Waiting to run
PR checks / nix_flake_check (push) Waiting to run
PR checks / koplugin_rust_lint (push) Waiting to run
PR checks / rust_lint (push) Waiting to run
PR checks / build_web_app (push) Waiting to run
PR checks / test_web_app (1) (push) Waiting to run
PR checks / test_web_app (2) (push) Waiting to run
PR checks / test_extensions (push) Waiting to run
PR checks / build_tauri_app (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Deploy to vercel on merge / build_and_deploy (push) Waiting to run
* fix(crosspoint): link an optimized copy to the book being read when duplicates tie A library often holds the same book twice, from an older import or as another edition. A copy rewritten by Optimize EPUB then matched both by title and author, so it was never linked and its progress never synced: the reader stayed on its own position. Among books sharing the copy's title and first author, the most recently read one now wins. When titles collide and the reader sent no author, the copy is still left unlinked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(crosspoint): match a copy's first author whole when titles collide The author check matched any substring, so a copy by "Ann" also matched a book by "Anna". Now that the most recently read of the matching books wins, that could link the copy to the wrong book. The copy's first author must now equal the book's first author. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
9703d46113
|
feat(crosspoint): plugin updates, version display, and sync for optimized EPUBs (#6592)
* feat(crosspoint): check for plugin updates from the web settings card The Readest card on CrossPoint's web Settings page shows the installed plugin version and a Check for update button. Like the KOReader plugin, it reads latest.json from download.readest.com through the device relay. Update streams the release zip to the SD card, unpacks it with the JSZip the device already serves, and writes each file into the plugin's folder, manifest.json last, so an update cut short is offered again. CrossPoint never shows a plugin's version on the reader, so the release job now stamps it at the start of device.json's description, which the reader's plugin list shows under Readest. The committed manifest version becomes 0.0.1, so a copy made from the repo is offered the release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(crosspoint): keep syncing books rewritten by Optimize EPUB CrossPoint's File Manager can optimize an EPUB on upload. That rewrites the file, so its KOReader partial MD5 no longer matches the Readest book, and progress sync and reading statistics lost track of it. Sign-in now turns on KOReader Sync's Send metadata, so progress uploads carry the book's title and authors. An upload under an unknown document id links it to the one library EPUB with that title (the first author breaks ties), stored in the new crosspoint_documents table (migration 025), without moving Readest's position back on that first upload. Progress reads, progress uploads and reading sessions then follow the link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(crosspoint): fail instead of syncing a copy under its own id on a database error A failed link lookup, library query or link write counted as "not linked", so a linked copy's reading session was recorded under the copy's own hash, a progress read answered 404, and a progress upload was saved under the copy's hash and acknowledged. The link helpers now report the error like a query, and the routes answer 500 so the reader retries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(crosspoint): compare every library book with a copy's title The title lookup stopped at 20 rows in no particular order, so with more books sharing a title it could miss Readest's own file or a second book that fits, and link a copy it should have left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
81403bc33d
|
feat(crosspoint): web-only sign-in, in-app linking, and recently read books first (#6561)
* fix(crosspoint): sign in only from the web card, and fix its sign-out Signing in on the reader's own Plugins -> Readest screen set up the library and reading statistics but never KOReader Sync: the firmware refuses plugin writes to its KOReader Sync settings, so progress sync stayed off with no hint. device.json drops its auth block, so the reader now shows CrossPoint's own "Not signed in. Open the web Settings page..." message, and every sign-in goes through the web card, which sets up progress sync. Revoking a key answered 204 No Content. CrossPoint's HTTP client reads a reply with neither Content-Length nor chunking until the connection closes, so a relayed 204 timed out after about 30 seconds and the card reported the revoke as failed, though the server had revoked the key. The route now answers 200 with a JSON body, and the card counts 200 as revoked. The card shows Sign in, with the progress sync choice it applies, while signed out, and only Sign out while signed in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(crosspoint): list recently read books first on the reader The reader's Readest catalog listed books newest-added first, so the book the user wanted next was often pages deep and only reachable by searching on the reader. It now follows Readest's own recently-read order: opening a book in Readest, or syncing progress from the reader, moves it to the top. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(crosspoint): approve a reader's sign-in code in the app A reader's sign-in link opens the /link page in a phone browser that is usually not signed in to Readest, and on iOS a Google or Apple sign-in started there finishes in the app (/auth/* is a Universal Link), so the browser never got to approve the code. The link now opens in the app, which is already signed in: /link joins the iOS Universal Links, and the app routes https://web.readest.com/link and readest://link to its own /link page, including when the link launches it. In the app the page has a header whose back button returns to the previous page. A signed-out browser gets an "Open in app" button. Android already handed every web.readest.com link to the app, where the article clipper saved the /link page as a book. The clipper now skips reader sign-in links, as it does share links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(crosspoint): follow new sign-in links on /link, and sign-out buttons The app could still be on /link, where nothing listened for links, when the next reader's sign-in link arrived, so the link was dropped and the page kept the old code. /link now listens for links too and shows the code of the link that opened it. The card switches to Sign in as soon as sign-out clears the account file, so a failure in the cleanup after it no longer leaves Sign in hidden on a card that a reload shows as signed out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(crosspoint): ignore an approval for a code /link no longer shows When another reader's sign-in link arrived while approving a code was still in flight, the page switched to the new code and the earlier request then marked it linked, hiding its form though that reader was never approved. Each approval and each new code now bumps a counter, and only the latest approval updates the page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
54c089f362
|
feat(crosspoint): Readest plugin for CrossPoint e-readers (#6547)
* feat: Readest plugin for CrossPoint e-readers Adds an SD-card plugin for CrossPoint firmware (Xteink X3/X4) that signs in to Readest from the reader's web settings page, lets the reader browse, search and download the EPUBs in the user's Readest cloud library, and adds each on-device reading session to Readest reading statistics. The device pages its catalog by number, so a new GET /api/library/books lists the caller's uploaded EPUBs a page at a time. It returns one lookahead row past per_page: CrossPoint requests page_size + 1 rows and drops the last one, so stepping pages by the requested row count would skip a book per page. Each item links to the existing /api/storage/download route. The firmware renews tokens with a password grant, so the password is stored on the SD card, JSON-escaped for the firmware's raw template substitution and kept in dotfiles the reader's web server refuses to serve. Reading sessions post statPages only, keyed by the partial MD5 the firmware already computes, which is the book_hash Readest uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(crosspoint): sync reading progress through CrossPoint's KOReader Sync Readest now acts as the KOSync server for the CrossPoint plugin, so reading progress syncs between CrossPoint and Readest without configuring a sync server. Signing in on the plugin's card mints a per-device key and points the reader's built-in KOReader Sync at /api/crosspoint with binary document matching, so books match by the partial MD5 Readest uses as book_hash. The KOSync-compatible routes read and write the same book_configs row the apps already sync: a push stores the XPointer, scaled progress and a fresh updated_at, and keeps the library row's progress current like /api/sync; a pull returns the XPointer Readest last synced. Readest apps apply it when they open the book. Device keys live in a new table (migration 024), stored as sha256 of the md5 KOSync clients send, readable only by the service role. The reader's web API never returns the KOSync password, so the plugin keeps the key's random id in its non-secret account file and revokes by id at sign-out. Sign-out only clears KOReader Sync settings that still point at Readest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(crosspoint): ask before replacing a KOReader Sync server, email username The plugin card gains a "Sync reading progress" checkbox. It starts on when KOReader Sync isn't set up on the reader or already points at Readest, so the default stays zero-config, and off when the user set up another server, naming that server. Signing in with it off leaves KOReader Sync alone (and revokes this reader's key if it had one); sign-out shares the same logic. The KOSync username is now the account email, a label for the reader's settings: the server authenticates a device by its key alone, so the setting stays readable and survives an email change. key_hash becomes unique. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(crosspoint): sign readers in with a device code and a per-device key The plugin stored the account password on the SD card, and anyone on the reader's network could rewrite device.json through the device's unauthenticated plugin-fs endpoint to send that password elsewhere. Readers now sign in with a code their owner approves on the new /link page and get their own revocable key, never a password. The key authenticates the catalog, downloads, reading sessions and KOReader Sync, under /api/crosspoint. - Device sign-in: /device/code, /device/token and /device/approve, an OAuth device grant. The reader shows the code and a QR of the link; the plugin's web card runs the same flow and also points KOReader Sync at Readest. - Reading sessions are spread over the pages they covered in the book's Readest page count, or in 1% steps until a Readest app paginates the book. Reading-speed estimates leave out events longer than a page visit. Unrecordable sessions are acknowledged rather than refused, since the reader's event queue stops at the first failed delivery. - Progress pushes keep the percentage for unpaginated books, never overwrite a newer config, and never pull back a position the reader has not seen. Key lookup failures are server errors, not 401s. - The plugin records keys before handing them out, retries revocations that failed, revokes before clearing the card at sign-out, and serializes sign-in and sign-out. - Catalog: stable order by date added, literal search, clamped paging, and titles that can be saved as file names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(crosspoint): keep an approved sign-in when minting its key fails, list untitled books - device/token claimed the approved code before inserting the key, so a failed insert threw the approval away and the owner had to start over. The claimed row now goes back on failure. - books.title is nullable; an untitled book made the whole catalog page fail. It is listed under its hash instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(release): attach the CrossPoint plugin zip to releases Like the calibre and KOReader plugins: stamp the release version into manifest.json and upload Readest-<version>.crosspoint-plugin.zip, which holds the readest/ folder to copy to the SD card, with the install guide inside it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |