Digest email: 'Daily Highlights' masthead + warm intro, point back to the site

Per user feedback: rename from 'Today's good news' (which implied the site was
done for the day) to a publication-style 'Upbeat Bytes — Daily Highlights'
masthead with a warm morning intro and a sign-off that links back to the site
('more good news is always waiting'). Adds 'why it's here' to the plain-text
part too. No images by design (lightweight, mail-client-safe).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jay
2026-06-09 16:55:17 -04:00
parent 0199e5108c
commit 7da14bd4fd
2 changed files with 20 additions and 7 deletions
+18 -6
View File
@@ -68,14 +68,21 @@ def build_digest(items: list[dict], brief_date: str, unsub_url: str, base: str |
if weekday == "today":
subject = f"Today's Upbeat Bytes · {n} calm reads"
text_lines = [f"Today's good news — {n} calm reads.\n"]
text_lines = [
f"Upbeat Bytes — Daily Highlights",
f"{n} calm read{'' if n == 1 else 's'} for {weekday}.\n",
"Good morning. A small, hopeful handful of what's going right — and there's",
"always more waiting on the site whenever you want it.\n",
]
for it in items:
text_lines.append(f"{it['title']} ({it['source']})")
if it.get("summary"):
text_lines.append(f" {it['summary']}")
if it.get("reason_text"):
text_lines.append(f" Why it's here: {it['reason_text']}")
text_lines.append(f" Read: {base}/a/{it['id']}")
text_lines.append(f" Source: {it['canonical_url']}\n")
text_lines.append("That's today's good news. You're caught up — see you tomorrow.")
text_lines.append(f"That's today's highlights — more good news is always waiting at {base}. See you tomorrow.")
text_lines.append(f"\nTo stop these emails: {unsub_url}")
text = "\n".join(text_lines)
@@ -97,11 +104,16 @@ def build_digest(items: list[dict], brief_date: str, unsub_url: str, base: str |
html = (
'<div style="max-width:600px;margin:0 auto;padding:8px 4px;'
'font-family:-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;color:#16263a">'
'<h1 style="font-size:22px;margin:0 0 4px">Todays good news</h1>'
f'<p style="color:#5d6b78;font-size:14px;margin:0 0 22px">{n} calm reads for {escape(weekday)}</p>'
'<div style="font-family:Georgia,\'Times New Roman\',serif;font-size:26px;font-weight:700;'
'letter-spacing:-0.01em;margin:0">Upbeat Bytes</div>'
'<div style="font-size:11px;letter-spacing:0.14em;text-transform:uppercase;color:#0083ad;'
f'margin:4px 0 0">Daily Highlights · {escape(weekday)}</div>'
'<p style="font-size:15px;line-height:1.5;color:#3b4754;margin:16px 0 24px">'
'Good morning. A small, hopeful handful of whats going right — and theres always more '
f'<a href="{base}" style="color:#0083ad;text-decoration:none">waiting on the site</a> when you want it.</p>'
+ "".join(blocks)
+ '<p style="font-size:15px;color:#3f7048;margin:8px 0 0">Thats todays good news. '
'Youre caught up — see you tomorrow.</p>'
+ '<p style="font-size:15px;color:#3f7048;margin:8px 0 0">Thats todays highlights — more good news is '
f'always <a href="{base}" style="color:#3f7048">waiting on Upbeat Bytes</a>. See you tomorrow.</p>'
f'<p style="font-size:12px;color:#9aa6b2;margin-top:24px">Youre getting this because you turned on '
f'the daily digest. <a href="{unsub_url}" style="color:#9aa6b2">Unsubscribe</a>.</p>'
'</div>'
+2 -1
View File
@@ -21,7 +21,8 @@ def test_build_digest_is_calm_and_dated():
items = [{"id": 1, "title": "Good thing", "canonical_url": "http://a/1", "source": "Src", "summary": "nice", "reason_text": "wonder", "paywalled": False}]
subject, text, html = digest.build_digest(items, "2026-06-09", "http://ub/unsub")
assert "Tuesday's Upbeat Bytes" in subject and "1 calm read" in subject
assert "You're caught up" in text and "http://ub/unsub" in text
assert "Daily Highlights" in text and "Daily Highlights" in html
assert "more good news is always" in text and "http://ub/unsub" in text # points back to the site
assert "Good thing" in html and "Read on Upbeat Bytes" in html and "Unsubscribe" in html
assert "you missed" not in (text + html).lower() # no guilt language