'
+ profileStr+=htmlIndividualShare(actor,item,translate,False)
if len(profileStr)>0:
profileStr='
'+profileStr+'
'
return profileStr
+def sharesTimelineJson(actor: str,pageNumber: int,itemsPerPage: int, \
+ baseDir: str,maxSharesPerAccount: int) -> ({},bool):
+ """Get a page on the shared items timeline as json
+ maxSharesPerAccount helps to avoid one person dominating the timeline
+ by sharing a large number of things
+ """
+ allSharesJson={}
+ for subdir, dirs, files in os.walk(baseDir+'/accounts'):
+ for handle in dirs:
+ if '@' in handle:
+ accountDir=baseDir+'/accounts/'+handle
+ sharesFilename=accountDir+'/shares.json'
+ if os.path.isfile(sharesFilename):
+ sharesJson=loadJson(sharesFilename)
+ if not sharesJson:
+ continue
+ ctr=0
+ for itemID,item in sharesJson.items():
+ allSharesJson[str(item['published'])]=item
+ ctr+=1
+ if ctr>=maxSharesPerAccount:
+ break
+ # sort the shared items in descending order of publication date
+ sharesJson=OrderedDict(sorted(allSharesJson.items(),reverse=True))
+ lastPage=False
+ startIndex=itemsPerPage*pageNumber
+ maxIndex=len(sharesJson.items())
+ if maxIndex=maxIndex-itemsPerPage:
+ lastPage=True
+ startIndex=maxIndex-itemsPerPage
+ if startIndex<0:
+ startIndex=0
+ ctr=0
+ resultJson={}
+ for published,item in sharesJson.items():
+ if ctr>=startIndex+itemsPerPage:
+ break
+ if ctr str:
+ """Show shared items timeline as html
+ """
+ sharesJson,lastPage= \
+ sharesTimelineJson(actor,pageNumber,itemsPerPage, \
+ baseDir,maxSharesPerAccount)
+ domainFull=domain
+ if port!=80 and port!=443:
+ if ':' not in domain:
+ domainFull=domain+':'+str(port)
+ actor=httpPrefix+'://'+domainFull+'/users/'+nickname
+ timelineStr=''
+
+ if pageNumber>1:
+ timelineStr+='
'
+
+ for published,item in sharesJson.items():
+ timelineStr+=htmlIndividualShare(actor,item,translate,True)
+
+ if not lastPage:
+ timelineStr+='