First and last page numbers

master
Bob Mottram 2019-06-29 18:07:43 +01:00
parent fd09d2682a
commit 62b990fe5a
2 changed files with 9 additions and 9 deletions

View File

@ -47,7 +47,7 @@ setPreferredUsername(username,domain,'badger')
setBio(username,domain,'Some personal info')
#createPublicPost(username, domain, https, "G'day world!", False, True, None, None, 'Not suitable for Vogons')
#archivePosts(username,domain,4)
outboxJson=createOutbox(username,domain,https,2,False,None)
outboxJson=createOutbox(username,domain,https,2,True,None)
pprint(outboxJson)
#runDaemon(domain,port,federationList,useTor)

View File

@ -275,7 +275,7 @@ def createOutbox(username: str,domain: str,https: bool,itemsPerPage: int,headerO
outboxHeader = {'@context': 'https://www.w3.org/ns/activitystreams',
'first': prefix+'://'+domain+'/users/'+username+'/outbox?page=true',
'id': prefix+'://'+domain+'/users/'+username+'/outbox',
'last': prefix+'://'+domain+'/users/'+username+'/outbox?min_id=0&page=true',
'last': prefix+'://'+domain+'/users/'+username+'/outbox?page=true',
'totalItems': 0,
'type': 'OrderedCollection'}
outboxItems = {'@context': 'https://www.w3.org/ns/activitystreams',
@ -295,20 +295,20 @@ def createOutbox(username: str,domain: str,https: bool,itemsPerPage: int,headerO
outboxHeader['totalItems']=len(postsInOutbox)
prevPostFilename=None
if not pageNumber:
pageNumber=1
# Generate first and last entries within header
if len(postsInOutbox)>0:
postId = postsInOutbox[len(postsInOutbox)-1].split('#statuses#')[1].replace('#activity','')
lastPage=int(len(postsInOutbox)/itemsPerPage)
if lastPage<1:
lastPage=1
outboxHeader['last']= \
prefix+'://'+domain+'/users/'+username+'/outbox?min_id='+postId+'&page=true'
postId = postsInOutbox[0].split('#statuses#')[1].replace('#activity','')
outboxHeader['first']= \
prefix+'://'+domain+'/users/'+username+'/outbox?max_id='+postId+'&page=true'
prefix+'://'+domain+'/users/'+username+'/outbox?page='+str(lastPage)
# Insert posts
currPage=1
postsCtr=0
if not pageNumber:
pageNumber=1
for postFilename in postsInOutbox:
# Are we at the starting page yet?
if prevPostFilename and currPage==pageNumber and postsCtr==0: