mirror of https://gitlab.com/bashrc2/epicyon
Show skills on profile screen
parent
1e5b44aef1
commit
84de304df0
37
daemon.py
37
daemon.py
|
@ -567,7 +567,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
getPerson = \
|
||||
personLookup(self.server.domain,self.path.replace('/roles',''), \
|
||||
self.server.baseDir)
|
||||
if getPerson:
|
||||
if getPerson:
|
||||
self._set_headers('text/html')
|
||||
self.wfile.write(htmlProfile(self.server.baseDir, \
|
||||
self.server.httpPrefix, \
|
||||
|
@ -581,9 +581,40 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._set_headers('application/json')
|
||||
self.wfile.write(json.dumps(actorJson['roles']).encode('utf-8'))
|
||||
self.server.GETbusy=False
|
||||
self.server.GETbusy=False
|
||||
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
|
||||
if '/statuses/' in self.path and '/users/' in self.path:
|
||||
namedStatus=self.path.split('/users/')[1]
|
||||
|
|
|
@ -1,139 +1,139 @@
|
|||
body, html {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.hero-image {
|
||||
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("image.png");
|
||||
height: 50%;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
position: relative;
|
||||
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("image.png");
|
||||
height: 50%;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.hero-text {
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: white;
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.roles {
|
||||
text-align: center;
|
||||
left: 35%;
|
||||
background-color: #f1f1f1;
|
||||
text-align: center;
|
||||
left: 35%;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
.roles-inner {
|
||||
padding: 10px 25px;
|
||||
background-color: #ffffff;
|
||||
padding: 10px 25px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.hero-text img {
|
||||
border-radius: 10%;
|
||||
width: 50%;
|
||||
border-radius: 10%;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.hero-text button {
|
||||
border: none;
|
||||
outline: 0;
|
||||
display: inline-block;
|
||||
padding: 10px 25px;
|
||||
color: black;
|
||||
background-color: #ddd;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
outline: 0;
|
||||
display: inline-block;
|
||||
padding: 10px 25px;
|
||||
color: black;
|
||||
background-color: #ddd;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.hero-text button:hover {
|
||||
background-color: #555;
|
||||
color: white;
|
||||
background-color: #555;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.button {
|
||||
border-radius: 4px;
|
||||
background-color: #999;
|
||||
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;
|
||||
border-radius: 4px;
|
||||
background-color: #999;
|
||||
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;
|
||||
}
|
||||
|
||||
.button span {
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
transition: 0.5s;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
transition: 0.5s;
|
||||
}
|
||||
|
||||
.button span:after {
|
||||
content: '\00bb';
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
top: 0;
|
||||
right: -20px;
|
||||
transition: 0.5s;
|
||||
content: '\00bb';
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
top: 0;
|
||||
right: -20px;
|
||||
transition: 0.5s;
|
||||
}
|
||||
|
||||
.button:hover span {
|
||||
padding-right: 25px;
|
||||
padding-right: 25px;
|
||||
}
|
||||
|
||||
.button:hover span:after {
|
||||
opacity: 1;
|
||||
right: 0;
|
||||
opacity: 1;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
content: '\00bb';
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
top: 0;
|
||||
right: -20px;
|
||||
transition: 0.5s;
|
||||
}
|
||||
|
||||
.buttonselected:hover span {
|
||||
padding-right: 25px;
|
||||
padding-right: 25px;
|
||||
}
|
||||
|
||||
.buttonselected:hover span:after {
|
||||
opacity: 1;
|
||||
right: 0;
|
||||
opacity: 1;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
|
@ -197,3 +197,25 @@ body, html {
|
|||
margin-top: 0px;
|
||||
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>'
|
||||
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, \
|
||||
ocapAlways: bool,profileJson: {},selected: str, \
|
||||
session,wfRequest: {},personCache: {}, \
|
||||
|
@ -160,6 +172,9 @@ def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool, \
|
|||
if selected=='roles':
|
||||
profileStr+= \
|
||||
htmlProfileRoles(nickname,domainFull,extraJson)
|
||||
if selected=='skills':
|
||||
profileStr+= \
|
||||
htmlProfileSkills(nickname,domainFull,extraJson)
|
||||
profileStr=htmlHeader(profileStyle)+profileStr+htmlFooter()
|
||||
return profileStr
|
||||
|
||||
|
|
Loading…
Reference in New Issue