Open Graph link previews for shared articles#639
Merged
Conversation
Mirrors the audio-lesson previews (#637/#638) for articles shared as zeeguu.org/read/article?id=N. New public, no-auth endpoints in article.py: - GET /shared_article_preview/<id> → server-rendered OG/Twitter HTML - GET /shared_article_image/<id>.png → a 1200x630 card The card features the article's own photo full-bleed under a scrim, with the title, source, reading time (word_count/200), and CEFR level — falling back to the branded cream card when an article has no image (rendered by og_image.render_article_card). A transient image-fetch failure serves the fallback without caching it, so the photo card appears once the fetch succeeds. nginx routing for /read/article is staged separately in the ops repo. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Extends the shared-lesson link previews (#637/#638) to articles shared as
zeeguu.org/read/article?id=N. Two new public, no-auth endpoints inarticle.py:GET /shared_article_preview/<id>— server-rendered OG/Twitter HTML (title, description, image, canonical → the app page, meta-refresh fallback).GET /shared_article_image/<id>.png— a 1200×630 card.The card
Unlike audio lessons (no inherent image → branded card), articles reliably have a hero image, so the card features the article's own photo full-bleed under a bottom scrim, with white title + a
<Language> Articlepill +CEFR · N min read · Source. When an article has no image, it falls back to the branded cream card (the article sibling of the audio card).og_image.render_article_carddoes both.Data comes from
article.article_info()(title, language,img_url,word_count→min read,cefr_level) +article.feed.titlefor the source. CEFR is shown here (a single level is a key "is this for me?" filter for articles — distinct from the misleading level-transitions we avoid elsewhere).Robustness: a transient image-fetch failure serves the fallback without caching it (short TTL), so the photo card appears once the fetch succeeds; otherwise cards are rendered once and cached on disk per article id.
Out of scope / deploy
/read/articleis staged separately in the ops repo (location = /read/article→ crawler UAs proxied to/shared_article_preview/$arg_id).og-images/shared-articles/).Verified by rendering the photo card and the no-photo fallback via the real
render_article_card; endpoints compile;.pngroute +requestsconfirmed. Not run end-to-end locally (DB drift) — smoke-test on deploy.🤖 Generated with Claude Code