Show contact and remove buttons on shares timeline

main2
Bob Mottram 2019-11-03 09:19:37 +00:00
parent 24bcef6b11
commit a2a90f6bd1
1 changed files with 13 additions and 4 deletions

View File

@ -1154,7 +1154,7 @@ def htmlProfileSkills(translate: {},nickname: str,domain: str,skillsJson: {}) ->
profileStr='<center><div class="skill-title">'+profileStr+'</div></center>' profileStr='<center><div class="skill-title">'+profileStr+'</div></center>'
return profileStr return profileStr
def htmlIndividualShare(actor: str,item: {},translate: {},showContact: bool) -> str: def htmlIndividualShare(actor: str,item: {},translate: {},showContact: bool,removeButton: bool) -> str:
"""Returns an individual shared item as html """Returns an individual shared item as html
""" """
profileStr='<div class="container">' profileStr='<div class="container">'
@ -1169,6 +1169,8 @@ def htmlIndividualShare(actor: str,item: {},translate: {},showContact: bool) ->
if showContact: if showContact:
contactActor=item['actor'] contactActor=item['actor']
profileStr+='<p><a href="'+actor+'?replydm=sharedesc:'+item['displayName']+'?mention='+contactActor+'"><button class="button">'+translate['Contact']+'</button></a>' profileStr+='<p><a href="'+actor+'?replydm=sharedesc:'+item['displayName']+'?mention='+contactActor+'"><button class="button">'+translate['Contact']+'</button></a>'
if removeButton:
profileStr+=' <a href="'+actor+'?rmshare='+item['displayName']+'"><button class="button">'+translate['Remove']+'</button></a>'
profileStr+='</div>' profileStr+='</div>'
return profileStr return profileStr
@ -1177,7 +1179,7 @@ def htmlProfileShares(actor: str,translate: {},nickname: str,domain: str,sharesJ
""" """
profileStr='' profileStr=''
for item in sharesJson['orderedItems']: for item in sharesJson['orderedItems']:
profileStr+=htmlIndividualShare(actor,item,translate,False) profileStr+=htmlIndividualShare(actor,item,translate,False,False)
if len(profileStr)>0: if len(profileStr)>0:
profileStr='<div class="share-title">'+profileStr+'</div>' profileStr='<div class="share-title">'+profileStr+'</div>'
return profileStr return profileStr
@ -1198,8 +1200,10 @@ def sharesTimelineJson(actor: str,pageNumber: int,itemsPerPage: int, \
sharesJson=loadJson(sharesFilename) sharesJson=loadJson(sharesFilename)
if not sharesJson: if not sharesJson:
continue continue
owner=actor.split('/users/')[0]+handle.split('@')[0]
ctr=0 ctr=0
for itemID,item in sharesJson.items(): for itemID,item in sharesJson.items():
item['actor']=owner
allSharesJson[str(item['published'])]=item allSharesJson[str(item['published'])]=item
ctr+=1 ctr+=1
if ctr>=maxSharesPerAccount: if ctr>=maxSharesPerAccount:
@ -1224,7 +1228,6 @@ def sharesTimelineJson(actor: str,pageNumber: int,itemsPerPage: int, \
if ctr<startIndex: if ctr<startIndex:
ctr+=1 ctr+=1
continue continue
item['actor']=actor
resultJson[published]=item resultJson[published]=item
ctr+=1 ctr+=1
return resultJson,lastPage return resultJson,lastPage
@ -1249,7 +1252,13 @@ def htmlSharesTimeline(translate: {},pageNumber: int,itemsPerPage: int, \
timelineStr+='<center><a href="'+actor+'/tlshares?page='+str(pageNumber-1)+'"><img loading="lazy" class="pageicon" src="/'+iconsDir+'/pageup.png" title="'+translate['Page up']+'" alt="'+translate['Page up']+'"></a></center>' timelineStr+='<center><a href="'+actor+'/tlshares?page='+str(pageNumber-1)+'"><img loading="lazy" class="pageicon" src="/'+iconsDir+'/pageup.png" title="'+translate['Page up']+'" alt="'+translate['Page up']+'"></a></center>'
for published,item in sharesJson.items(): for published,item in sharesJson.items():
timelineStr+=htmlIndividualShare(actor,item,translate,True) showContactButton=False
if item['actor']!=actor:
showContactButton=True
showRemoveButton=False
if item['actor']==actor:
showRemoveButton=True
timelineStr+=htmlIndividualShare(actor,item,translate,showContactButton,showRemoveButton)
if not lastPage: if not lastPage:
timelineStr+='<center><a href="'+actor+'/tlshares?page='+str(pageNumber+1)+'"><img loading="lazy" class="pageicon" src="/'+iconsDir+'/pagedown.png" title="'+translate['Page down']+'" alt="'+translate['Page down']+'"></a></center>' timelineStr+='<center><a href="'+actor+'/tlshares?page='+str(pageNumber+1)+'"><img loading="lazy" class="pageicon" src="/'+iconsDir+'/pagedown.png" title="'+translate['Page down']+'" alt="'+translate['Page down']+'"></a></center>'