forked from indymedia/epicyon
More generic profile page
parent
0f448553ab
commit
d0693db8ba
51
daemon.py
51
daemon.py
|
@ -46,8 +46,6 @@ from skills import outboxSkills
|
||||||
from availability import outboxAvailability
|
from availability import outboxAvailability
|
||||||
from webinterface import htmlIndividualPost
|
from webinterface import htmlIndividualPost
|
||||||
from webinterface import htmlProfile
|
from webinterface import htmlProfile
|
||||||
from webinterface import htmlFollowing
|
|
||||||
from webinterface import htmlFollowers
|
|
||||||
from webinterface import htmlInbox
|
from webinterface import htmlInbox
|
||||||
from webinterface import htmlOutbox
|
from webinterface import htmlOutbox
|
||||||
from webinterface import htmlPostReplies
|
from webinterface import htmlPostReplies
|
||||||
|
@ -638,27 +636,60 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.GETbusy=False
|
self.server.GETbusy=False
|
||||||
return
|
return
|
||||||
authorized=self._isAuthorized()
|
authorized=self._isAuthorized()
|
||||||
|
|
||||||
following=getFollowingFeed(self.server.baseDir,self.server.domain, \
|
following=getFollowingFeed(self.server.baseDir,self.server.domain, \
|
||||||
self.server.port,self.path, \
|
self.server.port,self.path, \
|
||||||
self.server.httpPrefix,
|
self.server.httpPrefix, \
|
||||||
authorized,followsPerPage)
|
authorized,followsPerPage)
|
||||||
if following:
|
if following:
|
||||||
if 'text/html' in self.headers['Accept']:
|
if 'text/html' in self.headers['Accept']:
|
||||||
self._set_headers('text/html')
|
if 'page=' not in self.path:
|
||||||
self.wfile.write(htmlFollowing(following).encode('utf-8'))
|
# get a page of following, not the summary
|
||||||
|
following=getFollowingFeed(self.server.baseDir,self.server.domain, \
|
||||||
|
self.server.port,self.path+'?page=1', \
|
||||||
|
self.server.httpPrefix, \
|
||||||
|
authorized,followsPerPage)
|
||||||
|
getPerson = personLookup(self.server.domain,self.path.replace('/following',''), \
|
||||||
|
self.server.baseDir)
|
||||||
|
if getPerson:
|
||||||
|
self._set_headers('text/html')
|
||||||
|
self.wfile.write(htmlProfile(self.server.baseDir, \
|
||||||
|
self.server.httpPrefix, \
|
||||||
|
authorized, \
|
||||||
|
self.server.ocapAlways, \
|
||||||
|
getPerson,'following', \
|
||||||
|
following).encode('utf-8'))
|
||||||
|
self.server.GETbusy=False
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
self._set_headers('application/json')
|
self._set_headers('application/json')
|
||||||
self.wfile.write(json.dumps(following).encode('utf-8'))
|
self.wfile.write(json.dumps(following).encode('utf-8'))
|
||||||
self.server.GETbusy=False
|
self.server.GETbusy=False
|
||||||
return
|
return
|
||||||
followers=getFollowingFeed(self.server.baseDir,self.server.domain, \
|
followers=getFollowingFeed(self.server.baseDir,self.server.domain, \
|
||||||
self.server.port,self.path, \
|
self.server.port,self.path, \
|
||||||
self.server.httpPrefix, \
|
self.server.httpPrefix, \
|
||||||
authorized,followsPerPage,'followers')
|
authorized,followsPerPage,'followers')
|
||||||
if followers:
|
if followers:
|
||||||
if 'text/html' in self.headers['Accept']:
|
if 'text/html' in self.headers['Accept']:
|
||||||
self._set_headers('text/html')
|
if 'page=' not in self.path:
|
||||||
self.wfile.write(htmlFollowers(followers).encode('utf-8'))
|
# get a page of followers, not the summary
|
||||||
|
followers=getFollowingFeed(self.server.baseDir,self.server.domain, \
|
||||||
|
self.server.port,self.path+'?page=1', \
|
||||||
|
self.server.httpPrefix, \
|
||||||
|
authorized,followsPerPage,'followers')
|
||||||
|
getPerson = personLookup(self.server.domain,self.path.replace('/followers',''), \
|
||||||
|
self.server.baseDir)
|
||||||
|
if getPerson:
|
||||||
|
self._set_headers('text/html')
|
||||||
|
self.wfile.write(htmlProfile(self.server.baseDir, \
|
||||||
|
self.server.httpPrefix, \
|
||||||
|
authorized, \
|
||||||
|
self.server.ocapAlways, \
|
||||||
|
getPerson,'followers', \
|
||||||
|
followers).encode('utf-8'))
|
||||||
|
self.server.GETbusy=False
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
self._set_headers('application/json')
|
self._set_headers('application/json')
|
||||||
self.wfile.write(json.dumps(followers).encode('utf-8'))
|
self.wfile.write(json.dumps(followers).encode('utf-8'))
|
||||||
|
@ -674,7 +705,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.httpPrefix, \
|
self.server.httpPrefix, \
|
||||||
authorized, \
|
authorized, \
|
||||||
self.server.ocapAlways, \
|
self.server.ocapAlways, \
|
||||||
getPerson).encode('utf-8'))
|
getPerson,'posts').encode('utf-8'))
|
||||||
else:
|
else:
|
||||||
self._set_headers('application/json')
|
self._set_headers('application/json')
|
||||||
self.wfile.write(json.dumps(getPerson).encode('utf-8'))
|
self.wfile.write(json.dumps(getPerson).encode('utf-8'))
|
||||||
|
|
110
webinterface.py
110
webinterface.py
|
@ -36,7 +36,22 @@ def htmlFooter() -> str:
|
||||||
'</html>\n'
|
'</html>\n'
|
||||||
return htmlStr
|
return htmlStr
|
||||||
|
|
||||||
def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool,ocapAlways: bool,profileJson: {}) -> str:
|
def htmlProfilePosts(baseDir: str,httpPrefix: str,authorized: bool,ocapAlways: bool,nickname: str,domain: str,port: int) -> str:
|
||||||
|
"""Shows posts on the profile screen
|
||||||
|
"""
|
||||||
|
profileStr=''
|
||||||
|
outboxFeed=personBoxJson(baseDir,domain, \
|
||||||
|
port,'/users/'+nickname+'/outbox?page=1', \
|
||||||
|
httpPrefix, \
|
||||||
|
4, 'outbox', \
|
||||||
|
authorized, \
|
||||||
|
ocapAlways)
|
||||||
|
for item in outboxFeed['orderedItems']:
|
||||||
|
if item['type']=='Create':
|
||||||
|
profileStr+=individualPostAsHtml(item)
|
||||||
|
return profileStr
|
||||||
|
|
||||||
|
def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool,ocapAlways: bool,profileJson: {},selected: str,extraJson=None) -> str:
|
||||||
"""Show the profile page as html
|
"""Show the profile page as html
|
||||||
"""
|
"""
|
||||||
nickname=profileJson['name']
|
nickname=profileJson['name']
|
||||||
|
@ -51,6 +66,24 @@ def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool,ocapAlways: bool,p
|
||||||
domainFull=domain+':'+str(port)
|
domainFull=domain+':'+str(port)
|
||||||
profileDescription=profileJson['publicKey']['summary']
|
profileDescription=profileJson['publicKey']['summary']
|
||||||
profileDescription='A test description'
|
profileDescription='A test description'
|
||||||
|
postsButton='button'
|
||||||
|
followingButton='button'
|
||||||
|
followersButton='button'
|
||||||
|
rolesButton='button'
|
||||||
|
skillsButton='button'
|
||||||
|
sharesButton='button'
|
||||||
|
if selected=='posts':
|
||||||
|
postsButton='buttonselected'
|
||||||
|
elif selected=='following':
|
||||||
|
followingButton='buttonselected'
|
||||||
|
elif selected=='followers':
|
||||||
|
followersButton='buttonselected'
|
||||||
|
elif selected=='roles':
|
||||||
|
rolesButton='buttonselected'
|
||||||
|
elif selected=='skills':
|
||||||
|
skillsButton='buttonselected'
|
||||||
|
elif selected=='shares':
|
||||||
|
sharesButton='buttonselected'
|
||||||
profileStr= \
|
profileStr= \
|
||||||
' <div class="hero-image">' \
|
' <div class="hero-image">' \
|
||||||
' <div class="hero-text">' \
|
' <div class="hero-text">' \
|
||||||
|
@ -62,12 +95,12 @@ def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool,ocapAlways: bool,p
|
||||||
'</div>' \
|
'</div>' \
|
||||||
'<div class="container">\n' \
|
'<div class="container">\n' \
|
||||||
' <center>' \
|
' <center>' \
|
||||||
' <a href="'+profileJson['id']+'/outbox?page=true"><button class="button"><span>Posts </span></button></a>' \
|
' <a href="'+profileJson['id']+'/outbox?page=true"><button class="'+postsButton+'"><span>Posts </span></button></a>' \
|
||||||
' <a href="'+profileJson['id']+'/following?page=true"><button class="button"><span>Following </span></button></a>' \
|
' <a href="'+profileJson['id']+'/following?page=true"><button class="'+followingButton+'"><span>Following </span></button></a>' \
|
||||||
' <a href="'+profileJson['id']+'/followers?page=true"><button class="button"><span>Followers </span></button></a>' \
|
' <a href="'+profileJson['id']+'/followers?page=true"><button class="'+followersButton+'"><span>Followers </span></button></a>' \
|
||||||
' <a href="'+profileJson['id']+'/roles?page=true"><button class="button"><span>Roles </span></button></a>' \
|
' <a href="'+profileJson['id']+'/roles?page=true"><button class="'+rolesButton+'"><span>Roles </span></button></a>' \
|
||||||
' <a href="'+profileJson['id']+'/skills?page=true"><button class="button"><span>Skills </span></button></a>' \
|
' <a href="'+profileJson['id']+'/skills?page=true"><button class="'+skillsButton+'"><span>Skills </span></button></a>' \
|
||||||
' <a href="'+profileJson['id']+'/shares?page=true"><button class="button"><span>Shares </span></button></a>' \
|
' <a href="'+profileJson['id']+'/shares?page=true"><button class="'+sharesButton+'"><span>Shares </span></button></a>' \
|
||||||
' </center>' \
|
' </center>' \
|
||||||
'</div>'
|
'</div>'
|
||||||
|
|
||||||
|
@ -157,6 +190,46 @@ def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool,ocapAlways: bool,p
|
||||||
' opacity: 1;' \
|
' opacity: 1;' \
|
||||||
' right: 0;' \
|
' right: 0;' \
|
||||||
'}' \
|
'}' \
|
||||||
|
'.buttonselected {' \
|
||||||
|
' border-radius: 4px;' \
|
||||||
|
' background-color: #666;' \
|
||||||
|
' border: none;' \
|
||||||
|
' color: #FFFFFF;' \
|
||||||
|
' text-align: center;' \
|
||||||
|
' font-size: 18px;' \
|
||||||
|
' padding: 10px;' \
|
||||||
|
' width: 20%;' \
|
||||||
|
' max-width: 200px;' \
|
||||||
|
' min-width: 100px;' \
|
||||||
|
' transition: all 0.5s;' \
|
||||||
|
' cursor: pointer;' \
|
||||||
|
' margin: 5px;' \
|
||||||
|
'}' \
|
||||||
|
'' \
|
||||||
|
'.buttonselected span {' \
|
||||||
|
' cursor: pointer;' \
|
||||||
|
' display: inline-block;' \
|
||||||
|
' position: relative;' \
|
||||||
|
' transition: 0.5s;' \
|
||||||
|
'}' \
|
||||||
|
'' \
|
||||||
|
'.buttonselected span:after {' \
|
||||||
|
" content: '\\00bb';" \
|
||||||
|
' position: absolute;' \
|
||||||
|
' opacity: 0;' \
|
||||||
|
' top: 0;' \
|
||||||
|
' right: -20px;' \
|
||||||
|
' transition: 0.5s;' \
|
||||||
|
'}' \
|
||||||
|
'' \
|
||||||
|
'.buttonselected:hover span {' \
|
||||||
|
' padding-right: 25px;' \
|
||||||
|
'}' \
|
||||||
|
'' \
|
||||||
|
'.buttonselected:hover span:after {' \
|
||||||
|
' opacity: 1;' \
|
||||||
|
' right: 0;' \
|
||||||
|
'}' \
|
||||||
'.container {' \
|
'.container {' \
|
||||||
' border: 2px solid #dedede;' \
|
' border: 2px solid #dedede;' \
|
||||||
' background-color: #f1f1f1;' \
|
' background-color: #f1f1f1;' \
|
||||||
|
@ -219,30 +292,11 @@ def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool,ocapAlways: bool,p
|
||||||
' color: #999;' \
|
' color: #999;' \
|
||||||
'}'
|
'}'
|
||||||
|
|
||||||
# show some posts
|
if selected=='posts':
|
||||||
outboxFeed=personBoxJson(baseDir,domain, \
|
profileStr+=htmlProfilePosts(baseDir,httpPrefix,authorized,ocapAlways,nickname,domain,port)
|
||||||
port,'/users/'+nickname+'/outbox?page=1', \
|
|
||||||
httpPrefix, \
|
|
||||||
4, 'outbox', \
|
|
||||||
authorized, \
|
|
||||||
ocapAlways)
|
|
||||||
for item in outboxFeed['orderedItems']:
|
|
||||||
if item['type']=='Create':
|
|
||||||
profileStr+=individualPostAsHtml(item)
|
|
||||||
|
|
||||||
profileStr=htmlHeader(profileStyle)+profileStr+htmlFooter()
|
profileStr=htmlHeader(profileStyle)+profileStr+htmlFooter()
|
||||||
return profileStr
|
return profileStr
|
||||||
|
|
||||||
def htmlFollowing(followingJson: {}) -> str:
|
|
||||||
"""Show the following collection as html
|
|
||||||
"""
|
|
||||||
return htmlHeader()+"<h1>Following collection</h1>"+htmlFooter()
|
|
||||||
|
|
||||||
def htmlFollowers(followersJson: {}) -> str:
|
|
||||||
"""Show the followers collection as html
|
|
||||||
"""
|
|
||||||
return htmlHeader()+"<h1>Followers collection</h1>"+htmlFooter()
|
|
||||||
|
|
||||||
def individualPostAsHtml(postJsonObject: {}) -> str:
|
def individualPostAsHtml(postJsonObject: {}) -> str:
|
||||||
avatarPosition=''
|
avatarPosition=''
|
||||||
containerClass='container'
|
containerClass='container'
|
||||||
|
|
Loading…
Reference in New Issue