Page up and down on following list on profile page

master
Bob Mottram 2019-09-05 17:17:09 +01:00
parent d666581c54
commit 42740a6781
2 changed files with 49 additions and 11 deletions

View File

@ -1446,7 +1446,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.session, \ self.server.session, \
self.server.cachedWebfingers, \ self.server.cachedWebfingers, \
self.server.personCache, \ self.server.personCache, \
actorJson['roles']).encode('utf-8') actorJson['roles'], \
None,None).encode('utf-8')
self._set_headers('text/html',len(msg),cookie) self._set_headers('text/html',len(msg),cookie)
self.wfile.write(msg) self.wfile.write(msg)
else: else:
@ -1481,7 +1482,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.session, \ self.server.session, \
self.server.cachedWebfingers, \ self.server.cachedWebfingers, \
self.server.personCache, \ self.server.personCache, \
actorJson['skills']).encode('utf-8') actorJson['skills'], \
None,None).encode('utf-8')
self._set_headers('text/html',len(msg),cookie) self._set_headers('text/html',len(msg),cookie)
self.wfile.write(msg) self.wfile.write(msg)
else: else:
@ -1797,6 +1799,7 @@ class PubServer(BaseHTTPRequestHandler):
sharesPerPage) sharesPerPage)
if shares: if shares:
if self._requestHTTP(): if self._requestHTTP():
pageNumber=1
if '?page=' not in self.path: if '?page=' not in self.path:
searchPath=self.path searchPath=self.path
# get a page of shares, not the summary # get a page of shares, not the summary
@ -1805,6 +1808,9 @@ class PubServer(BaseHTTPRequestHandler):
self.server.httpPrefix, \ self.server.httpPrefix, \
sharesPerPage) sharesPerPage)
else: else:
pageNumberStr=self.path.split('?page=')[1]
if pageNumberStr.isdigit():
pageNumber=int(pageNumberStr)
searchPath=self.path.split('?page=')[0] searchPath=self.path.split('?page=')[0]
getPerson = personLookup(self.server.domain,searchPath.replace('/shares',''), \ getPerson = personLookup(self.server.domain,searchPath.replace('/shares',''), \
self.server.baseDir) self.server.baseDir)
@ -1823,7 +1829,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.session, \ self.server.session, \
self.server.cachedWebfingers, \ self.server.cachedWebfingers, \
self.server.personCache, \ self.server.personCache, \
shares).encode('utf-8') shares, \
pageNumber,sharesPerPage).encode('utf-8')
self._set_headers('text/html',len(msg),cookie) self._set_headers('text/html',len(msg),cookie)
self.wfile.write(msg) self.wfile.write(msg)
self.server.GETbusy=False self.server.GETbusy=False
@ -1841,6 +1848,7 @@ class PubServer(BaseHTTPRequestHandler):
authorized,followsPerPage) authorized,followsPerPage)
if following: if following:
if self._requestHTTP(): if self._requestHTTP():
pageNumber=1
if '?page=' not in self.path: if '?page=' not in self.path:
searchPath=self.path searchPath=self.path
# get a page of following, not the summary # get a page of following, not the summary
@ -1849,6 +1857,9 @@ class PubServer(BaseHTTPRequestHandler):
self.server.httpPrefix, \ self.server.httpPrefix, \
authorized,followsPerPage) authorized,followsPerPage)
else: else:
pageNumberStr==self.path.split('?page=')[1]
if pageNumberStr.isdigit():
pageNumber=int(pageNumberStr)
searchPath=self.path.split('?page=')[0] searchPath=self.path.split('?page=')[0]
getPerson = personLookup(self.server.domain,searchPath.replace('/following',''), \ getPerson = personLookup(self.server.domain,searchPath.replace('/following',''), \
self.server.baseDir) self.server.baseDir)
@ -1868,7 +1879,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.session, \ self.server.session, \
self.server.cachedWebfingers, \ self.server.cachedWebfingers, \
self.server.personCache, \ self.server.personCache, \
following).encode('utf-8') following, \
pageNumber,followsPerPage).encode('utf-8')
self._set_headers('text/html',len(msg),cookie) self._set_headers('text/html',len(msg),cookie)
self.wfile.write(msg) self.wfile.write(msg)
self.server.GETbusy=False self.server.GETbusy=False
@ -1885,6 +1897,7 @@ class PubServer(BaseHTTPRequestHandler):
authorized,followsPerPage,'followers') authorized,followsPerPage,'followers')
if followers: if followers:
if self._requestHTTP(): if self._requestHTTP():
pageNumber=1
if '?page=' not in self.path: if '?page=' not in self.path:
searchPath=self.path searchPath=self.path
# get a page of followers, not the summary # get a page of followers, not the summary
@ -1893,6 +1906,9 @@ class PubServer(BaseHTTPRequestHandler):
self.server.httpPrefix, \ self.server.httpPrefix, \
authorized,followsPerPage,'followers') authorized,followsPerPage,'followers')
else: else:
pageNumberStr=self.path.split('?page=')[1]
if pageNumberStr.isdigit():
pageNumber=int(pageNumberStr)
searchPath=self.path.split('?page=')[0] searchPath=self.path.split('?page=')[0]
getPerson = personLookup(self.server.domain,searchPath.replace('/followers',''), \ getPerson = personLookup(self.server.domain,searchPath.replace('/followers',''), \
self.server.baseDir) self.server.baseDir)
@ -1911,7 +1927,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.session, \ self.server.session, \
self.server.cachedWebfingers, \ self.server.cachedWebfingers, \
self.server.personCache, \ self.server.personCache, \
followers).encode('utf-8') followers, \
pageNumber,followsPerPage).encode('utf-8')
self._set_headers('text/html',len(msg),cookie) self._set_headers('text/html',len(msg),cookie)
self.wfile.write(msg) self.wfile.write(msg)
self.server.GETbusy=False self.server.GETbusy=False
@ -1940,7 +1957,8 @@ class PubServer(BaseHTTPRequestHandler):
getPerson,'posts', getPerson,'posts',
self.server.session, \ self.server.session, \
self.server.cachedWebfingers, \ self.server.cachedWebfingers, \
self.server.personCache).encode('utf-8') self.server.personCache, \
None,None).encode('utf-8')
self._set_headers('text/html',len(msg),cookie) self._set_headers('text/html',len(msg),cookie)
self.wfile.write(msg) self.wfile.write(msg)
else: else:

View File

@ -920,10 +920,20 @@ def htmlProfileFollowing(baseDir: str,httpPrefix: str, \
nickname: str,domain: str,port: int, \ nickname: str,domain: str,port: int, \
session,wfRequest: {},personCache: {}, \ session,wfRequest: {},personCache: {}, \
followingJson: {},projectVersion: str, \ followingJson: {},projectVersion: str, \
buttons: []) -> str: buttons: [], \
feedName: str,actor: str, \
pageNumber: int, \
maxItemsPerPage: int) -> str:
"""Shows following on the profile screen """Shows following on the profile screen
""" """
profileStr='' profileStr=''
if authorized and pageNumber:
if authorized and pageNumber>1:
# page up arrow
profileStr+= \
'<center><a href="'+actor+'/'+feedName+'?page='+str(pageNumber-1)+'"><img class="pageicon" src="/icons/pageup.png" title="Page up" alt="Page up"></a></center>'
for item in followingJson['orderedItems']: for item in followingJson['orderedItems']:
profileStr+= \ profileStr+= \
individualFollowAsHtml(baseDir,session, \ individualFollowAsHtml(baseDir,session, \
@ -931,6 +941,11 @@ def htmlProfileFollowing(baseDir: str,httpPrefix: str, \
domain,item,authorized,nickname, \ domain,item,authorized,nickname, \
httpPrefix,projectVersion, \ httpPrefix,projectVersion, \
buttons) buttons)
if authorized and maxItemsPerPage and pageNumber:
if len(followingJson['orderedItems'])>=maxItemsPerPage:
# page down arrow
profileStr+= \
'<center><a href="'+actor+'/'+feedName+'?page='+str(pageNumber+1)+'"><img class="pageicon" src="/icons/pagedown.png" title="Page down" alt="Page down"></a></center>'
return profileStr return profileStr
def htmlProfileRoles(nickname: str,domain: str,rolesJson: {}) -> str: def htmlProfileRoles(nickname: str,domain: str,rolesJson: {}) -> str:
@ -985,7 +1000,8 @@ def htmlProfile(projectVersion: str, \
baseDir: str,httpPrefix: str,authorized: bool, \ baseDir: str,httpPrefix: str,authorized: bool, \
ocapAlways: bool,profileJson: {},selected: str, \ ocapAlways: bool,profileJson: {},selected: str, \
session,wfRequest: {},personCache: {}, \ session,wfRequest: {},personCache: {}, \
extraJson=None) -> str: extraJson=None, \
pageNumber=None,maxItemsPerPage=None) -> str:
"""Show the profile page as html """Show the profile page as html
""" """
nickname=profileJson['preferredUsername'] nickname=profileJson['preferredUsername']
@ -1104,15 +1120,19 @@ def htmlProfile(projectVersion: str, \
domain,port,session, \ domain,port,session, \
wfRequest,personCache,extraJson, \ wfRequest,personCache,extraJson, \
projectVersion, \ projectVersion, \
["unfollow"]) ["unfollow"], \
selected,actor, \
pageNumber,maxItemsPerPage)
if selected=='followers': if selected=='followers':
profileStr+= \ profileStr+= \
htmlProfileFollowing(baseDir,httpPrefix, \ htmlProfileFollowing(baseDir,httpPrefix, \
authorized,ocapAlways,nickname, \ authorized,ocapAlways,nickname, \
domain,port,session, \ domain,port,session, \
wfRequest,personCache,extraJson, \ wfRequest,personCache,extraJson, \
projectVersion, projectVersion, \
["block"]) ["block"], \
selected,actor, \
pageNumber,maxItemsPerPage)
if selected=='roles': if selected=='roles':
profileStr+= \ profileStr+= \
htmlProfileRoles(nickname,domainFull,extraJson) htmlProfileRoles(nickname,domainFull,extraJson)