From bfd612eb9b0eac59dac9f0b5a28b3a7950258329 Mon Sep 17 00:00:00 2001 From: jay Date: Sun, 31 May 2026 00:39:13 +0000 Subject: [PATCH] Paywall awareness (#6) + replace-an-article (#7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - paywall.py: conservative domain-level paywall detection (New Scientist, Nature, and common hard/soft paywalls). Never fetches pages β€” an honest hint. - API: Article gains a 'paywalled' flag; the brief now leads with a gentle AND readable story (paywalled/charged stories stay in the five, just not first). - New GET /api/replacement returns the next-best readable, unshown article (honors mood+prefs via the merged prefs param; gentle=true for hero swaps). - UI: paywalled cards show 'May need a subscription'; a Replace / 'Find one I can read' action (always visible, while tuning actions stay tucked) swaps the card for a readable alternative, with a gentle notice when none remain. - Tests: paywall detection + replacement behavior (77 total). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/lib/components/ArticleCard.svelte | 25 ++++++-- frontend/src/routes/+page.svelte | 55 +++++++++++++++- goodnews/api.py | 62 +++++++++++++++++-- goodnews/paywall.py | 41 ++++++++++++ ideas.md | 8 +-- tests/test_paywall.py | 14 +++++ tests/test_replacement.py | 37 +++++++++++ 7 files changed, 226 insertions(+), 16 deletions(-) create mode 100644 goodnews/paywall.py create mode 100644 tests/test_paywall.py create mode 100644 tests/test_replacement.py diff --git a/frontend/src/lib/components/ArticleCard.svelte b/frontend/src/lib/components/ArticleCard.svelte index 9957243..976e81c 100644 --- a/frontend/src/lib/components/ArticleCard.svelte +++ b/frontend/src/lib/components/ArticleCard.svelte @@ -1,5 +1,5 @@