Different link for blog posts

main
Bob Mottram 2020-02-24 23:14:49 +00:00
parent ac3de67ddd
commit e36b6a8646
5 changed files with 29 additions and 20 deletions

View File

@ -68,7 +68,6 @@ from posts import createDirectMessagePost
from posts import populateRepliesJson
from posts import addToField
from posts import expireCache
from inbox import isBlogPost
from inbox import inboxPermittedMessage
from inbox import inboxMessageHasParams
from inbox import runInboxQueue
@ -152,6 +151,7 @@ from shares import outboxUndoShareUpload
from shares import addShare
from shares import removeShare
from shares import expireShares
from utils import isBlogPost
from utils import removeAvatarFromCache
from utils import locatePost
from utils import getCachedPostFilename

View File

@ -62,23 +62,6 @@ from webinterface import getIconsDir
from question import questionUpdateVotes
from media import replaceYouTube
def isBlogPost(postJsonObject: {}) -> bool:
"""Is the given post a blog post?
"""
if postJsonObject['type']!='Create':
return False
if not postJsonObject.get('object'):
return False
if not isinstance(postJsonObject['object'], dict):
return False
if not postJsonObject['object'].get('type'):
return False
if not postJsonObject['object'].get('content'):
return False
if postJsonObject['object']['type']!='Article':
return False
return True
def storeHashTags(baseDir: str,nickname: str,postJsonObject: {}) -> None:
"""Extracts hashtags from an incoming post and updates the
relevant tags files.

View File

@ -14,6 +14,7 @@ from posts import outboxMessageCreateWrap
from posts import savePostToBox
from posts import sendToFollowersThread
from posts import sendToNamedAddresses
from utils import isBlogPost
from utils import getDomainFromActor
from blocking import isBlockedDomain
from blocking import outboxBlock
@ -22,7 +23,6 @@ from media import replaceYouTube
from media import getMediaPath
from media import createMediaDirs
from inbox import inboxUpdateIndex
from inbox import isBlogPost
from announce import outboxAnnounce
from follow import outboxUndoFollow
from roles import outboxDelegate

View File

@ -598,3 +598,20 @@ def mergeDicts(dict1: {}, dict2: {}) -> {}:
"""
res = {**dict1, **dict2}
return res
def isBlogPost(postJsonObject: {}) -> bool:
"""Is the given post a blog post?
"""
if postJsonObject['type']!='Create':
return False
if not postJsonObject.get('object'):
return False
if not isinstance(postJsonObject['object'], dict):
return False
if not postJsonObject['object'].get('type'):
return False
if not postJsonObject['object'].get('content'):
return False
if postJsonObject['object']['type']!='Article':
return False
return True

View File

@ -23,6 +23,7 @@ from pgp import getPGPpubKey
from xmpp import getXmppAddress
from matrix import getMatrixAddress
from donate import getDonationUrl
from utils import isBlogPost
from utils import updateRecentPostsCache
from utils import getNicknameFromActor
from utils import getDomainFromActor
@ -3213,7 +3214,15 @@ def individualPostAsHtml(recentPostsCache: {},maxRecentPosts: int, \
publishedStr=publishedStr.replace('T',' ').split('.')[0]
datetimeObject = parse(publishedStr)
publishedStr=datetimeObject.strftime("%a %b %d, %H:%M")
footerStr='<a href="'+messageId+'" class="'+timeClass+'">'+publishedStr+'</a>\n'
publishedLink=messageId
# blog posts should have no /statuses/ in their link
if isBlogPost(postJsonObject):
# is this a post to the local domain?
if '/'+domain in messageId:
publishedLink=messageId.replace('/statuses/','/')
footerStr='<a href="'+publishedLink+'" class="'+timeClass+'">'+publishedStr+'</a>\n'
# change the background color for DMs in inbox timeline
if showDMicon: