Skip to content

feat(mobile): share a link to send its article to the Kindle - #5

Merged
listlessbird merged 3 commits into
mainfrom
feat/article-urls
Nov 22, 2026
Merged

listlessbird merged 3 commits into
mainfrom
feat/article-urls

Conversation

@listlessbird

@listlessbird listlessbird commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Sharing a web page from Chrome (text/plain with a link) showed "Kindle Drop sends EPUB, AZW3, PDF, and TXT files." There was no way to read an article on the Kindle.

How

The pipeline lives in kindle-core. A new convert_article(url, out_dir) fetches the page, extracts the readable part, and builds the AZW3 through the same build() that EPUBs use:

  1. Fetch with ureq (rustls with bundled roots; no new secrets and no third-party service).
  2. Extract with dom_smoothie, a Rust port of Mozilla's Readability, for the title, byline, site, language and content.
  3. Download images, decode them with image (WebP, PNG, GIF…), scale them to the Paperwhite's 1072 px, and re-encode them as JPEG. kindling embeds images as-is, and the Kindle can't show WebP. An image that won't load is dropped from the book rather than failing it.
  4. Use the page's og:image as the cover, or else the article's first large image, then write an unpacked EPUB (content.opf, article.xhtml, images/) and hand it to kindling.

Why not the other options:

  • JS on the phone (Readability with linkedom, a JS zip writer, then convertEpub) would run the parse on the JS thread, so the share sheet would freeze. It also can't turn WebP into something the Kindle reads.
  • Fetching on the Worker needs a deploy, and it puts every article through Cloudflare.

The Kotlin change for EXTRA_TEXT makes this a native change regardless, so the new Rust code adds no extra cost.

No cover means PDOC. An EBOK without a thumbnail gets Amazon's "No image available" placeholder, so a book without a cover is now built as a PDOC with no thumbnail, and Converted.thumbnail was already optional. This also fixes EPUBs that have no cover; before this change they failed to convert at the thumbnail step.

App model. Source is now a file or an article (url plus the shared title). An article starts as Converting and is fetched in the convert step, not at share time. A failed fetch becomes ConvertFailed { reason: "unreachable" }, and refresh retries it once the mailbox answers, the same way it retries an offline upload. A page that isn't an article, or answers with an error, is invalid and is not retried. Rows stored before reason existed decode as invalid. The share sheet still offers Send to Kindle when the fetch failed offline. Shared text with no link gets "This text has no link to an article. Share the page from your browser."

Native Change: ShareActivity passes text and subject (ignoring a browser's preview clipData), and kindle-core gains convert_article and its dependencies.

Verification

  • Tests written first. Model: offline failures stay sendable, articleUrlOf, the storage round trip, and old rows. Sender: an article converts and uploads (thumbnail first), an offline fetch retries on refresh, an offline article sent from its sheet survives the sheet closing and sends once online, a page with no article is not fetched again, and a book without a cover is sent alone. check:changed passes.

  • Rust tests run against a local HTTP server: images become 1072 px JPEGs, a 404 image and the page chrome are dropped, og:image becomes the cover, a page without images builds as a PDOC with no thumbnail, an unreachable host is Fetch, and a 404 page is Article.

  • Real pages on the host, about 1.5 s each:

    Page Title Author Cover
    Simon Willison, "Things we learned about LLMs in 2024" Things we learned about LLMs in 2024 Simon Willison yes, with 5 inline images
    Paul Graham, "How to Do Great Work" How to Do Great Work paulgraham.com none (PDOC)
    Wikipedia, "Readability" Readability Contributors to Wikimedia projects none (PDOC)

    ebook-meta reads back the same title and author, and calibre's text dump shows clean article text without navigation.

  • On emulator-5554, against a local alchemy dev Worker, I shared three pages from Chrome. Each reached Waiting for Kindle with the right title and author. Simon Willison's arrived with its cover thumbnail, and the other two as PDOCs. ebook-meta on the AZW3s pulled from the mailbox read back the same titles and authors, and I then cancelled all three.

  • That pass found a bug, fixed in the last commit. Chrome attaches its link-preview thumbnail as clipData, and ShareActivity was falling back to it as the shared file, so the sheet showed a PNG named "TXT". clipData is now ignored when the share carries text.

Before (shared link) Chrome bug, now fixed After: share sheet After: Library
"Kindle Drop sends EPUB, AZW3, PDF, and TXT files."

@github-actions github-actions Bot added the Native Change Changes the native fingerprint; OTAs stop reaching users until a new build ships. label Nov 21, 2026
Readability extraction (dom_smoothie), images re-encoded as JPEG, and the page's preview image as the cover. A book without a cover is built as a PDOC with no thumbnail instead of failing.
Shared text with a link becomes an article book that converts from its page. A fetch that fails offline retries once the phone is back online, and the sheet can still send it.
@listlessbird
listlessbird merged commit c41141d into main Nov 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Native Change Changes the native fingerprint; OTAs stop reaching users until a new build ships.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant