mirror of https://gitlab.com/bashrc2/epicyon
Show skills on profile screen
parent
1e5b44aef1
commit
84de304df0
31
daemon.py
31
daemon.py
|
@ -584,6 +584,37 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.GETbusy=False
|
self.server.GETbusy=False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.path.endswith('/skills') and '/users/' in self.path:
|
||||||
|
namedStatus=self.path.split('/users/')[1]
|
||||||
|
if '/' in namedStatus:
|
||||||
|
postSections=namedStatus.split('/')
|
||||||
|
nickname=postSections[0]
|
||||||
|
actorFilename=self.server.baseDir+'/accounts/'+nickname+'@'+self.server.domain+'.json'
|
||||||
|
if os.path.isfile(actorFilename):
|
||||||
|
with open(actorFilename, 'r') as fp:
|
||||||
|
actorJson=commentjson.load(fp)
|
||||||
|
if actorJson.get('skills'):
|
||||||
|
if 'text/html' in self.headers['Accept']:
|
||||||
|
getPerson = \
|
||||||
|
personLookup(self.server.domain,self.path.replace('/skills',''), \
|
||||||
|
self.server.baseDir)
|
||||||
|
if getPerson:
|
||||||
|
self._set_headers('text/html')
|
||||||
|
self.wfile.write(htmlProfile(self.server.baseDir, \
|
||||||
|
self.server.httpPrefix, \
|
||||||
|
True, \
|
||||||
|
self.server.ocapAlways, \
|
||||||
|
getPerson,'skills', \
|
||||||
|
self.server.session, \
|
||||||
|
self.server.cachedWebfingers, \
|
||||||
|
self.server.personCache, \
|
||||||
|
actorJson['skills']).encode('utf-8'))
|
||||||
|
else:
|
||||||
|
self._set_headers('application/json')
|
||||||
|
self.wfile.write(json.dumps(actorJson['skills']).encode('utf-8'))
|
||||||
|
self.server.GETbusy=False
|
||||||
|
return
|
||||||
|
|
||||||
# get an individual post from the path /users/nickname/statuses/number
|
# get an individual post from the path /users/nickname/statuses/number
|
||||||
if '/statuses/' in self.path and '/users/' in self.path:
|
if '/statuses/' in self.path and '/users/' in self.path:
|
||||||
namedStatus=self.path.split('/users/')[1]
|
namedStatus=self.path.split('/users/')[1]
|
||||||
|
|
|
@ -197,3 +197,25 @@ body, html {
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.skill-title {
|
||||||
|
margin-left: 25%;
|
||||||
|
text-align: left;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #666;
|
||||||
|
line-height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#myProgress {
|
||||||
|
float: left;
|
||||||
|
width: 70%;
|
||||||
|
background-color: #f1f1f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#myBar {
|
||||||
|
float: left;
|
||||||
|
width: 10%;
|
||||||
|
height: 30px;
|
||||||
|
background-color: #999;
|
||||||
|
}
|
||||||
|
|
|
@ -86,6 +86,18 @@ def htmlProfileRoles(nickname: str,domain: str,rolesJson: {}) -> str:
|
||||||
profileStr='<div>'+profileStr+'</div>'
|
profileStr='<div>'+profileStr+'</div>'
|
||||||
return profileStr
|
return profileStr
|
||||||
|
|
||||||
|
def htmlProfileSkills(nickname: str,domain: str,skillsJson: {}) -> str:
|
||||||
|
"""Shows skills on the profile screen
|
||||||
|
"""
|
||||||
|
profileStr=''
|
||||||
|
for skill,level in skillsJson.items():
|
||||||
|
profileStr+='<div>'+skill+'<br><div id="myProgress"><div id="myBar" style="width:'+str(level)+'%"></div></div></div><br>'
|
||||||
|
if len(profileStr)==0:
|
||||||
|
profileStr+='<p>@'+nickname+'@'+domain+' has no skills assigned</p>'
|
||||||
|
else:
|
||||||
|
profileStr='<center><div class="skill-title">'+profileStr+'</div></center>'
|
||||||
|
return profileStr
|
||||||
|
|
||||||
def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool, \
|
def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool, \
|
||||||
ocapAlways: bool,profileJson: {},selected: str, \
|
ocapAlways: bool,profileJson: {},selected: str, \
|
||||||
session,wfRequest: {},personCache: {}, \
|
session,wfRequest: {},personCache: {}, \
|
||||||
|
@ -160,6 +172,9 @@ def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool, \
|
||||||
if selected=='roles':
|
if selected=='roles':
|
||||||
profileStr+= \
|
profileStr+= \
|
||||||
htmlProfileRoles(nickname,domainFull,extraJson)
|
htmlProfileRoles(nickname,domainFull,extraJson)
|
||||||
|
if selected=='skills':
|
||||||
|
profileStr+= \
|
||||||
|
htmlProfileSkills(nickname,domainFull,extraJson)
|
||||||
profileStr=htmlHeader(profileStyle)+profileStr+htmlFooter()
|
profileStr=htmlHeader(profileStyle)+profileStr+htmlFooter()
|
||||||
return profileStr
|
return profileStr
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue