forked from indymedia/epicyon
Include description in newswire rss feed
parent
49414c7012
commit
30e63970f6
8
blog.py
8
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 = ' <item>'
|
||||
rssStr += ' <title>' + titleStr + '</title>'
|
||||
rssStr += ' <link>' + messageLink + '</link>'
|
||||
|
@ -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'
|
||||
|
|
|
@ -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 += '<item>\n'
|
||||
rssStr += ' <title>' + fields[0] + '</title>\n'
|
||||
description = firstParagraphFromString(fields[4])
|
||||
rssStr += ' <description>' + description + '</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'],
|
||||
|
|
3
utils.py
3
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 '<p>' not in content or '</p>' not in content:
|
||||
return removeHtml(content)
|
||||
paragraph = content.split('<p>')[1]
|
||||
|
|
Loading…
Reference in New Issue