Avatar icon on media timeline

main
Bob Mottram 2019-11-28 13:39:03 +00:00
parent fb17bfceae
commit 5ea0306973
1 changed files with 46 additions and 49 deletions

View File

@ -1998,6 +1998,20 @@ def individualPostAsHtml(recentPostsCache: {},maxRecentPosts: int, \
if isPersonSnoozed(baseDir,nickname,domain,postActor): if isPersonSnoozed(baseDir,nickname,domain,postActor):
return '' return ''
messageIdStr=''
if messageId:
messageIdStr=';'+messageId
fullDomain=domain
if port:
if port!=80 and port!=443:
if ':' not in domain:
fullDomain=domain+':'+str(port)
pageNumberParam=''
if pageNumber:
pageNumberParam='?page='+str(pageNumber)
if not showPublicOnly and storeToCache and boxName!='tlmedia': if not showPublicOnly and storeToCache and boxName!='tlmedia':
# update avatar if needed # update avatar if needed
if not avatarUrl: if not avatarUrl:
@ -2013,6 +2027,37 @@ def individualPostAsHtml(recentPostsCache: {},maxRecentPosts: int, \
postJsonObject,postHtml) postJsonObject,postHtml)
return postHtml return postHtml
if not avatarUrl:
avatarUrl=getPersonAvatarUrl(baseDir,postActor,personCache)
avatarUrl=updateAvatarImageCache(session,baseDir,httpPrefix,postActor,avatarUrl,personCache)
else:
updateAvatarImageCache(session,baseDir,httpPrefix,postActor,avatarUrl,personCache)
if not avatarUrl:
avatarUrl=postActor+'/avatar.png'
if fullDomain not in postActor:
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,displayName = \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,nickname,domain,'outbox')
if avatarUrl2:
avatarUrl=avatarUrl2
if displayName:
if ':' in displayName:
displayName= \
addEmojiToDisplayName(baseDir,httpPrefix, \
nickname,domain, \
displayName,False)
titleStr=displayName+' '+titleStr
avatarLink=' <a href="'+postActor+'">'
avatarLink+=' <img loading="lazy" src="'+avatarUrl+'" title="'+translate['Show profile']+'" alt=" "'+avatarPosition+'/></a>'
if showAvatarOptions and fullDomain+'/users/'+nickname not in postActor:
avatarLink=' <a href="/users/'+nickname+'?options='+postActor+';'+str(pageNumber)+';'+avatarUrl+messageIdStr+'">'
avatarLink+=' <img loading="lazy" title="'+translate['Show options for this person']+'" src="'+avatarUrl+'" '+avatarPosition+'/></a>'
avatarImageInPost= ' <div class="timeline-avatar">'+avatarLink+'</div>'
# don't create new html within the bookmarks timeline # don't create new html within the bookmarks timeline
# it should already have been created for the inbox # it should already have been created for the inbox
if boxName=='tlbookmarks': if boxName=='tlbookmarks':
@ -2087,20 +2132,6 @@ def individualPostAsHtml(recentPostsCache: {},maxRecentPosts: int, \
if showDMicon: if showDMicon:
titleStr=titleStr+' <img loading="lazy" src="/'+iconsDir+'/dm.png" class="DMicon"/>' titleStr=titleStr+' <img loading="lazy" src="/'+iconsDir+'/dm.png" class="DMicon"/>'
messageIdStr=''
if messageId:
messageIdStr=';'+messageId
fullDomain=domain
if port:
if port!=80 and port!=443:
if ':' not in domain:
fullDomain=domain+':'+str(port)
pageNumberParam=''
if pageNumber:
pageNumberParam='?page='+str(pageNumber)
replyStr='' replyStr=''
if showIcons: if showIcons:
replyToLink=postJsonObject['object']['id'] replyToLink=postJsonObject['object']['id']
@ -2307,7 +2338,7 @@ def individualPostAsHtml(recentPostsCache: {},maxRecentPosts: int, \
else: else:
galleryStr+='<label class="transparent">---</label><br>' galleryStr+='<label class="transparent">---</label><br>'
galleryStr+=' <div class="mediaicons">\n' galleryStr+=' <div class="mediaicons">\n'
galleryStr+=' '+replyStr+announceStr+likeStr+bookmarkStr+deleteStr+'\n' galleryStr+=' '+replyStr+announceStr+likeStr+bookmarkStr+deleteStr+avatarLink+'\n'
galleryStr+=' </div>\n' galleryStr+=' </div>\n'
galleryStr+='</div>\n' galleryStr+='</div>\n'
@ -2363,40 +2394,6 @@ def individualPostAsHtml(recentPostsCache: {},maxRecentPosts: int, \
attachmentCtr+=1 attachmentCtr+=1
attachmentStr+='</div>' attachmentStr+='</div>'
if not avatarUrl:
avatarUrl=getPersonAvatarUrl(baseDir,postActor,personCache)
avatarUrl=updateAvatarImageCache(session,baseDir,httpPrefix,postActor,avatarUrl,personCache)
else:
updateAvatarImageCache(session,baseDir,httpPrefix,postActor,avatarUrl,personCache)
if not avatarUrl:
avatarUrl=postActor+'/avatar.png'
if fullDomain not in postActor:
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,displayName = \
getPersonBox(baseDir,session,wfRequest,personCache, \
projectVersion,httpPrefix,nickname,domain,'outbox')
if avatarUrl2:
avatarUrl=avatarUrl2
if displayName:
if ':' in displayName:
displayName= \
addEmojiToDisplayName(baseDir,httpPrefix, \
nickname,domain, \
displayName,False)
titleStr=displayName+' '+titleStr
avatarImageInPost=' <div class="timeline-avatar">'
avatarImageInPost+=' <a href="'+postActor+'">'
avatarImageInPost+=' <img loading="lazy" src="'+avatarUrl+'" title="'+translate['Show profile']+'" alt=" "'+avatarPosition+'/></a>'
avatarImageInPost+=' </div>'
if showAvatarOptions and fullDomain+'/users/'+nickname not in postActor:
avatarImageInPost=' <div class="timeline-avatar">'
avatarImageInPost+=' <a href="/users/'+nickname+'?options='+postActor+';'+str(pageNumber)+';'+avatarUrl+messageIdStr+'">'
avatarImageInPost+=' <img loading="lazy" title="'+translate['Show options for this person']+'" src="'+avatarUrl+'" '+avatarPosition+'/></a>'
avatarImageInPost+=' </div>'
publishedStr=postJsonObject['object']['published'] publishedStr=postJsonObject['object']['published']
if '.' not in publishedStr: if '.' not in publishedStr:
if '+' not in publishedStr: if '+' not in publishedStr: