From 7b6f2a6468dd5fd306ba574f0504607ffc7dadef Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 28 Aug 2019 09:58:16 +0100 Subject: [PATCH] Get actor from json --- daemon.py | 1 + webinterface.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/daemon.py b/daemon.py index 48b98d70..6235c099 100644 --- a/daemon.py +++ b/daemon.py @@ -2515,6 +2515,7 @@ class PubServer(BaseHTTPRequestHandler): searchStr=searchStr.replace('*','').strip() skillStr= \ htmlSkillsSearch(self.server.baseDir,searchStr, \ + self.server.domainFull, \ maxPostsInFeed) if skillStr: msg=skillStr.encode('utf-8') diff --git a/webinterface.py b/webinterface.py index 20a2af32..e82f3e8f 100644 --- a/webinterface.py +++ b/webinterface.py @@ -284,7 +284,7 @@ def htmlHashtagSearch(baseDir: str,hashtag: str,pageNumber: int,postsPerPage: in hashtagSearchForm+=htmlFooter() return hashtagSearchForm -def htmlSkillsSearch(baseDir: str,skillsearch: str,postsPerPage: int) -> str: +def htmlSkillsSearch(baseDir: str,skillsearch: str,domainFull: str,postsPerPage: int) -> str: """Show a page containing search results for a skill """ if skillsearch.startswith('*'): @@ -302,11 +302,14 @@ def htmlSkillsSearch(baseDir: str,skillsearch: str,postsPerPage: int) -> str: continue if f.startswith('inbox@'): continue - actor=f.replace('.json','').replace('#','/') actorFilename = os.path.join(subdir, f) with open(actorFilename, 'r') as fp: actorJson=commentjson.load(fp) - if actorJson.get('skills') and actorJson.get('name') and actorJson.get('icon'): + if actorJson.get('id') and \ + actorJson.get('skills') and \ + actorJson.get('name') and \ + actorJson.get('icon'): + actor=actorJson['id'] for skillName,skillLevel in actorJson['skills'].items(): skillName=skillName.lower() if skillName in skillsearch or skillsearch in skillName: @@ -327,13 +330,16 @@ def htmlSkillsSearch(baseDir: str,skillsearch: str,postsPerPage: int) -> str: continue if f.startswith('inbox@'): continue - actor=f.replace('.json','').replace('#','/') actorFilename = os.path.join(subdir, f) with open(actorFilename, 'r') as fp: cachedActorJson=commentjson.load(fp) if cachedActorJson.get('actor'): actorJson=cachedActorJson['actor'] - if actorJson.get('skills') and actorJson.get('name') and actorJson.get('icon'): + if actorJson.get('id') and \ + actorJson.get('skills') and \ + actorJson.get('name') and \ + actorJson.get('icon'): + actor=actorJson['id'] for skillName,skillLevel in actorJson['skills'].items(): skillName=skillName.lower() if skillName in skillsearch or skillsearch in skillName: