mirror of https://gitlab.com/bashrc2/epicyon
Include description within rss feeds
parent
bb936c455a
commit
49414c7012
6
blog.py
6
blog.py
|
@ -19,6 +19,7 @@ from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
|
from utils import firstParagraph
|
||||||
from posts import createBlogsTimeline
|
from posts import createBlogsTimeline
|
||||||
from newswire import rss2Header
|
from newswire import rss2Header
|
||||||
from newswire import rss2Footer
|
from newswire import rss2Footer
|
||||||
|
@ -312,9 +313,12 @@ def htmlBlogPostRSS2(authorized: bool,
|
||||||
pubDate = datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
|
pubDate = datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
titleStr = postJsonObject['object']['summary']
|
titleStr = postJsonObject['object']['summary']
|
||||||
rssDateStr = pubDate.strftime("%a, %d %b %Y %H:%M:%S UT")
|
rssDateStr = pubDate.strftime("%a, %d %b %Y %H:%M:%S UT")
|
||||||
|
description = firstParagraph(postJsonObject)
|
||||||
rssStr = ' <item>'
|
rssStr = ' <item>'
|
||||||
rssStr += ' <title>' + titleStr + '</title>'
|
rssStr += ' <title>' + titleStr + '</title>'
|
||||||
rssStr += ' <link>' + messageLink + '</link>'
|
rssStr += ' <link>' + messageLink + '</link>'
|
||||||
|
rssStr += \
|
||||||
|
' <description>' + description + '</description>'
|
||||||
rssStr += ' <pubDate>' + rssDateStr + '</pubDate>'
|
rssStr += ' <pubDate>' + rssDateStr + '</pubDate>'
|
||||||
rssStr += ' </item>'
|
rssStr += ' </item>'
|
||||||
return rssStr
|
return rssStr
|
||||||
|
@ -339,8 +343,10 @@ def htmlBlogPostRSS3(authorized: bool,
|
||||||
pubDate = datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
|
pubDate = datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
titleStr = postJsonObject['object']['summary']
|
titleStr = postJsonObject['object']['summary']
|
||||||
rssDateStr = pubDate.strftime("%a, %d %b %Y %H:%M:%S UT")
|
rssDateStr = pubDate.strftime("%a, %d %b %Y %H:%M:%S UT")
|
||||||
|
description = firstParagraph(postJsonObject)
|
||||||
rssStr = 'title: ' + titleStr + '\n'
|
rssStr = 'title: ' + titleStr + '\n'
|
||||||
rssStr += 'link: ' + messageLink + '\n'
|
rssStr += 'link: ' + messageLink + '\n'
|
||||||
|
rssStr += 'description: ' + description + '\n'
|
||||||
rssStr += 'created: ' + rssDateStr + '\n\n'
|
rssStr += 'created: ' + rssDateStr + '\n\n'
|
||||||
return rssStr
|
return rssStr
|
||||||
|
|
||||||
|
|
14
newswire.py
14
newswire.py
|
@ -12,6 +12,7 @@ from socket import error as SocketError
|
||||||
import errno
|
import errno
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from utils import firstParagraph
|
||||||
from utils import isPublicPost
|
from utils import isPublicPost
|
||||||
from utils import locatePost
|
from utils import locatePost
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
|
@ -444,19 +445,6 @@ def getHashtagsFromPost(postJsonObject: {}) -> []:
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
|
|
||||||
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 '<p>' not in content or '</p>' not in content:
|
|
||||||
return removeHtml(content)
|
|
||||||
paragraph = content.split('<p>')[1]
|
|
||||||
if '</p>' in paragraph:
|
|
||||||
paragraph = paragraph.split('</p>')[0]
|
|
||||||
return removeHtml(paragraph)
|
|
||||||
|
|
||||||
|
|
||||||
def addAccountBlogsToNewswire(baseDir: str, nickname: str, domain: str,
|
def addAccountBlogsToNewswire(baseDir: str, nickname: str, domain: str,
|
||||||
newswire: {},
|
newswire: {},
|
||||||
maxBlogsPerAccount: int,
|
maxBlogsPerAccount: int,
|
||||||
|
|
13
utils.py
13
utils.py
|
@ -19,6 +19,19 @@ from calendar import monthrange
|
||||||
from followingCalendar import addPersonToCalendar
|
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 '<p>' not in content or '</p>' not in content:
|
||||||
|
return removeHtml(content)
|
||||||
|
paragraph = content.split('<p>')[1]
|
||||||
|
if '</p>' in paragraph:
|
||||||
|
paragraph = paragraph.split('</p>')[0]
|
||||||
|
return removeHtml(paragraph)
|
||||||
|
|
||||||
|
|
||||||
def removeHtml(content: str) -> str:
|
def removeHtml(content: str) -> str:
|
||||||
"""Removes html links from the given content.
|
"""Removes html links from the given content.
|
||||||
Used to ensure that profile descriptions don't contain dubious content
|
Used to ensure that profile descriptions don't contain dubious content
|
||||||
|
|
Loading…
Reference in New Issue