From 8fdcb93546f3e6c3292166469935b1e4f925bdb3 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 9 Aug 2019 09:46:38 +0100 Subject: [PATCH] Formatting of ' --- daemon.py | 21 +++++++++++++++++++++ epicyon-profile.css | 34 ++++++++++++++++++++++++++++++++++ posts.py | 2 +- skills.py | 10 ++++++++++ webinterface.py | 18 ++++++++++++++++++ 5 files changed, 84 insertions(+), 1 deletion(-) diff --git a/daemon.py b/daemon.py index 1c67e8285..61163dd8a 100644 --- a/daemon.py +++ b/daemon.py @@ -1807,6 +1807,27 @@ class PubServer(BaseHTTPRequestHandler): with open(actorFilename, 'r') as fp: actorJson=commentjson.load(fp) actorChanged=False + skillCtr=1 + newSkills={} + while skillCtr<10: + skillName=fields.get('skillName'+str(skillCtr)) + if not skillName: + skillCtr+=1 + continue + skillValue=fields.get('skillValue'+str(skillCtr)) + if not skillValue: + skillCtr+=1 + continue + if not actorJson['skills'].get(skillName): + actorChanged=True + else: + if actorJson['skills'][skillName]!=int(skillValue): + actorChanged=True + newSkills[skillName]=int(skillValue) + skillCtr+=1 + if len(actorJson['skills'].items())!=len(newSkills.items()): + actorChanged=True + actorJson['skills']=newSkills if fields.get('preferredNickname'): if fields['preferredNickname']!=actorJson['preferredUsername']: actorJson['preferredUsername']=fields['preferredNickname'] diff --git a/epicyon-profile.css b/epicyon-profile.css index 2108e8942..93d2571f0 100644 --- a/epicyon-profile.css +++ b/epicyon-profile.css @@ -564,3 +564,37 @@ input[type=checkbox] padding: 10px; margin: 10px 5px; } + +.slider { + -webkit-appearance: none; + width: 57%; + height: 25px; + background: #d3d3d3; + outline: none; + opacity: 0.7; + -webkit-transition: .2s; + transition: opacity .2s; + float: right; + margin: 5px 0; + padding: 12px 0; +} + +.slider:hover { + opacity: 1; +} + +.slider::-webkit-slider-thumb { + -webkit-appearance: none; + appearance: none; + width: 25px; + height: 25px; + background: #4CAF50; + cursor: pointer; +} + +.slider::-moz-range-thumb { + width: 25px; + height: 25px; + background: #4CAF50; + cursor: pointer; +} diff --git a/posts.py b/posts.py index c6b30ef1a..fc22978fa 100644 --- a/posts.py +++ b/posts.py @@ -232,7 +232,7 @@ def getPosts(session,outboxUrl: str,maxPosts: int, \ if not isPublic: continue - content = item['object']['content'] + content = item['object']['content'].replace(''',"'") mentions=[] emoji={} diff --git a/skills.py b/skills.py index fe55a510b..749776d81 100644 --- a/skills.py +++ b/skills.py @@ -38,6 +38,16 @@ def setSkillLevel(baseDir: str,nickname: str,domain: str, \ commentjson.dump(actorJson, fp, indent=4, sort_keys=False) return True +def setSkills(baseDir: str,nickname: str,domain: str,skills: {}) -> None: + actorFilename=baseDir+'/accounts/'+nickname+'@'+domain+'.json' + if not os.path.isfile(actorFilename): + return False + with open(actorFilename, 'r') as fp: + actorJson=commentjson.load(fp) + actorJson['skills']=skills + with open(actorFilename, 'w') as fp: + commentjson.dump(actorJson, fp, indent=4, sort_keys=False) + def getSkills(baseDir: str,nickname: str,domain: str) -> []: """Returns the skills for a given person """ diff --git a/webinterface.py b/webinterface.py index c2e44a5c1..37e4cdf3d 100644 --- a/webinterface.py +++ b/webinterface.py @@ -31,6 +31,7 @@ from announce import announcedByPerson from blocking import isBlocked from content import getMentionsFromHtml from config import getConfigParam +from skills import getSkills def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str: """Shows the edit profile screen @@ -84,6 +85,18 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str: with open(allowedInstancesFilename, 'r') as allowedInstancesFile: allowedInstancesStr=allowedInstancesFile.read() + skills=getSkills(baseDir,nickname,domain) + skillsStr='' + skillCtr=1 + if skills: + for skillDesc,skillValue in skills.items(): + skillsStr+='

' + skillsStr+='

' + skillCtr+=1 + + skillsStr+='

' + skillsStr+='

' \ + with open(baseDir+'/epicyon-profile.css', 'r') as cssFile: newPostCSS = cssFile.read() @@ -124,6 +137,11 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str: '
Federate only with a defined set of instances. One domain name per line.' \ ' ' \ ' ' \ + '
' \ + ' Skills
' \ + ' If you want to participate within organizations then you can indicate some skills that you have and approximate proficiency levels. This helps organizers to construct teams with an appropriate combination of skills.'+ \ + skillsStr+ \ + '
' \ ' ' \ '' editProfileForm+=htmlFooter()