Contact link on shared items search

master
Bob Mottram 2019-08-25 22:48:51 +01:00
parent 634bcd4a14
commit 0335cd0c94
1 changed files with 8 additions and 0 deletions

View File

@ -99,6 +99,11 @@ def htmlSearchSharedItems(baseDir: str,searchStr: str,pageNumber: int,resultsPer
""" """
currPage=1 currPage=1
ctr=0 ctr=0
actorDomain,actorPort=getDomainFromActor(actor)
if actorPort:
if actorPort!=80 and actorPort!=443:
actorDomain=actorDomain+':'+str(actorPort)
actorHttpPrefix=actor.split('://')[0]
sharedItemsForm='' sharedItemsForm=''
searchStrLower=searchStr.replace('%2B','+').replace('%40','@').replace('%3A',':').replace('%23','#').lower().strip('\n') searchStrLower=searchStr.replace('%2B','+').replace('%40','@').replace('%3A',':').replace('%23','#').lower().strip('\n')
searchStrLowerList=searchStrLower.split('+') searchStrLowerList=searchStrLower.split('+')
@ -111,6 +116,7 @@ def htmlSearchSharedItems(baseDir: str,searchStr: str,pageNumber: int,resultsPer
for handle in dirs: for handle in dirs:
if '@' not in handle: if '@' not in handle:
continue continue
contactNickname=handle.split('@')[0]
sharesFilename=baseDir+'/accounts/'+handle+'/shares.json' sharesFilename=baseDir+'/accounts/'+handle+'/shares.json'
if not os.path.isfile(sharesFilename): if not os.path.isfile(sharesFilename):
continue continue
@ -143,6 +149,8 @@ def htmlSearchSharedItems(baseDir: str,searchStr: str,pageNumber: int,resultsPer
sharedItemsForm+='<p><b>Type:</b> '+sharedItem['itemType']+' ' sharedItemsForm+='<p><b>Type:</b> '+sharedItem['itemType']+' '
sharedItemsForm+='<b>Category:</b> '+sharedItem['category']+' ' sharedItemsForm+='<b>Category:</b> '+sharedItem['category']+' '
sharedItemsForm+='<b>Location:</b> '+sharedItem['location']+'</p>' sharedItemsForm+='<b>Location:</b> '+sharedItem['location']+'</p>'
contactActor=actorHttpPrefix+'://'+actorDomain+'/users/'+contactNickname
sharedItemsForm+='<p><a href="'+actor+'?replydm='+sharedItem['displayName']+'?mention='+contactActor+'">Contact</a>'
sharedItemsForm+='</div>' sharedItemsForm+='</div>'
if not resultsExist and currPage>1: if not resultsExist and currPage>1:
# previous page link, needs to be a POST # previous page link, needs to be a POST