Skip to content

Commit dc29d0b

Browse files
committed
fix: don't put folks on blast for missing summaries.
also, remove the dependency on `textwrap`. adds a usage description of the feature to the README and an entry to CHANGES.md
1 parent a268c2f commit dc29d0b

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ this project doesn't really have releases (or even versioning, until now), it
77
is a project that effects Recursers in "real ways". It would be nice to have a
88
place to quickly see the latest changes that the project has undergone.
99

10+
## 2025-06
11+
12+
- [#190] Add text from the blog post summary to the Zulip announcement, if present -- @robbielyman
1013

1114
## 2021-09
1215

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ already been seen by blaggregator. So, if you published more than 2 posts
100100
between consecutive (hourly) crawls by blaggregator, only the last two posts
101101
will be notified on Zulip.
102102

103+
### My blog post appears on Zulip, but with no summary quote.
104+
105+
The quote is pulled from [feedparser's](https://pypi.org/project/feedparser/) summary field,
106+
which in turn is populated with, e.g. RSS or Atom's "summary" or "description" fields.
107+
Make sure that your feed is generating content for those tags!
108+
103109
### My blog is multi-purpose and not wholly code/Recurse Center specific
104110

105111
No problem! RCers usually enjoy reading non-technical posts by others.

home/zulip_helpers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import logging
44
import os
55
import re
6-
import textwrap
76

87
# 3rd-party library
98
from django.conf import settings
@@ -18,8 +17,8 @@
1817
ZULIP_EMAIL = os.environ.get("ZULIP_EMAIL")
1918
MESSAGES_URL = "https://recurse.zulipchat.com/api/v1/messages"
2019
MEMBERS_URL = "https://recurse.zulipchat.com/api/v1/users"
21-
ANNOUNCE_MESSAGE = "{} has a new blog post: [{}]({})\n```quote\n{}\n```"
22-
PLACEHOLDER = "Consider adding a `summary` to your next blog post! It'll show up here."
20+
ANNOUNCE_MESSAGE = "{} has a new blog post: [{}]({})\n"
21+
QUOTE = "```quote\n{}\n```"
2322
log = logging.getLogger("blaggregator")
2423

2524

@@ -46,9 +45,10 @@ def announce_posts(posts, debug=True):
4645
subject = title if len(title) <= 60 else title[:57] + "..."
4746
path = reverse("view_post", kwargs={"slug": post.slug})
4847
url = "{}/{}".format(settings.ROOT_URL.rstrip("/"), path.lstrip("/"))
49-
summary = post.content if post.content else PLACEHOLDER
50-
summary = textwrap.shorten(summary, width = 200, placeholder = "...")
51-
content = ANNOUNCE_MESSAGE.format(author, title, url, summary)
48+
content = ANNOUNCE_MESSAGE.format(author, title, url)
49+
if post.content
50+
summary = post.content if len(post.content) <= 480 else post.content[:477] + "..."
51+
content = content + QUOTE.format(summary)
5252
send_message_zulip(to, subject, content, type_="stream")
5353

5454

0 commit comments

Comments
 (0)