diff --git a/blog.py b/blog.py
index 4c3e83c70..606fc923f 100644
--- a/blog.py
+++ b/blog.py
@@ -19,6 +19,7 @@ from utils import getNicknameFromActor
from utils import getDomainFromActor
from utils import locatePost
from utils import loadJson
+from utils import firstParagraph
from posts import createBlogsTimeline
from newswire import rss2Header
from newswire import rss2Footer
@@ -312,9 +313,12 @@ def htmlBlogPostRSS2(authorized: bool,
pubDate = datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
titleStr = postJsonObject['object']['summary']
rssDateStr = pubDate.strftime("%a, %d %b %Y %H:%M:%S UT")
+ description = firstParagraph(postJsonObject)
rssStr = '
' not in content or '
' not in content: - return removeHtml(content) - paragraph = content.split('')[1] - if '
' in paragraph: - paragraph = paragraph.split('')[0] - return removeHtml(paragraph) - - def addAccountBlogsToNewswire(baseDir: str, nickname: str, domain: str, newswire: {}, maxBlogsPerAccount: int, diff --git a/utils.py b/utils.py index 08d21f159..6640e1dde 100644 --- a/utils.py +++ b/utils.py @@ -19,6 +19,19 @@ from calendar import monthrange from followingCalendar import addPersonToCalendar +def firstParagraph(postJsonObject: {}) -> str: + """Get the first paragraph from a blog post + to be used as a summary in the newswire feed + """ + content = postJsonObject['object']['content'] + if '' not in content or '
' not in content: + return removeHtml(content) + paragraph = content.split('')[1] + if '
' in paragraph: + paragraph = paragraph.split('')[0] + return removeHtml(paragraph) + + def removeHtml(content: str) -> str: """Removes html links from the given content. Used to ensure that profile descriptions don't contain dubious content