diff --git a/blog.py b/blog.py index 606fc923..96d52a1f 100644 --- a/blog.py +++ b/blog.py @@ -19,7 +19,7 @@ from utils import getNicknameFromActor from utils import getDomainFromActor from utils import locatePost from utils import loadJson -from utils import firstParagraph +from utils import firstParagraphFromString from posts import createBlogsTimeline from newswire import rss2Header from newswire import rss2Footer @@ -313,7 +313,8 @@ 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) + content = postJsonObject['object']['content'] + description = firstParagraphFromString(content) rssStr = ' ' rssStr += ' ' + titleStr + '' rssStr += ' ' + messageLink + '' @@ -343,7 +344,8 @@ def htmlBlogPostRSS3(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) + content = postJsonObject['object']['content'] + description = firstParagraphFromString(content) rssStr = 'title: ' + titleStr + '\n' rssStr += 'link: ' + messageLink + '\n' rssStr += 'description: ' + description + '\n' diff --git a/newswire.py b/newswire.py index e738fef4..4fca15a7 100644 --- a/newswire.py +++ b/newswire.py @@ -12,7 +12,7 @@ from socket import error as SocketError import errno from datetime import datetime from collections import OrderedDict -from utils import firstParagraph +from utils import firstParagraphFromString from utils import isPublicPost from utils import locatePost from utils import loadJson @@ -387,6 +387,8 @@ def getRSSfromDict(baseDir: str, newswire: {}, continue rssStr += '\n' rssStr += ' ' + fields[0] + '\n' + description = firstParagraphFromString(fields[4]) + rssStr += ' ' + description + '\n' url = fields[1] if domainFull not in url: url = httpPrefix + '://' + domainFull + url @@ -502,7 +504,8 @@ def addAccountBlogsToNewswire(baseDir: str, nickname: str, domain: str, votes = [] if os.path.isfile(fullPostFilename + '.votes'): votes = loadJson(fullPostFilename + '.votes') - description = firstParagraph(postJsonObject) + content = postJsonObject['object']['content'] + description = firstParagraphFromString(content) addNewswireDictEntry(baseDir, domain, newswire, published, postJsonObject['object']['summary'], diff --git a/utils.py b/utils.py index 6640e1dd..11d00aa0 100644 --- a/utils.py +++ b/utils.py @@ -19,11 +19,10 @@ from calendar import monthrange from followingCalendar import addPersonToCalendar -def firstParagraph(postJsonObject: {}) -> str: +def firstParagraphFromString(content: str) -> 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]