forked from indymedia/epicyon
Multi-part search for shared items
parent
1dae3bacca
commit
23462f1380
|
@ -37,7 +37,8 @@ from skills import getSkills
|
||||||
|
|
||||||
def htmlSearchSharedItems(baseDir: str,searchStr: str) -> str:
|
def htmlSearchSharedItems(baseDir: str,searchStr: str) -> str:
|
||||||
sharedItemsForm=''
|
sharedItemsForm=''
|
||||||
searchStrLower=searchStr.lower()
|
searchStrLower=searchStr.replace('%2B','+').replace('%40','@').replace('%3A',':').replace('%23','#').lower().strip('\n')
|
||||||
|
searchStrLowerList=searchStrLower.split('+')
|
||||||
with open(baseDir+'/epicyon-profile.css', 'r') as cssFile:
|
with open(baseDir+'/epicyon-profile.css', 'r') as cssFile:
|
||||||
sharedItemsCSS=cssFile.read()
|
sharedItemsCSS=cssFile.read()
|
||||||
sharedItemsForm=htmlHeader(sharedItemsCSS)
|
sharedItemsForm=htmlHeader(sharedItemsCSS)
|
||||||
|
@ -53,15 +54,23 @@ def htmlSearchSharedItems(baseDir: str,searchStr: str) -> str:
|
||||||
with open(sharesFilename, 'r') as fp:
|
with open(sharesFilename, 'r') as fp:
|
||||||
sharesJson=commentjson.load(fp)
|
sharesJson=commentjson.load(fp)
|
||||||
for name,sharedItem in sharesJson.items():
|
for name,sharedItem in sharesJson.items():
|
||||||
|
matched=True
|
||||||
|
ctr=0
|
||||||
|
for searchSubstr in searchStrLowerList:
|
||||||
|
subStrMatched=False
|
||||||
|
searchSubstr=searchSubstr.strip()
|
||||||
|
if searchSubstr in sharedItem['location'].lower():
|
||||||
|
subStrMatched=True
|
||||||
|
elif searchSubstr in sharedItem['summary'].lower():
|
||||||
|
subStrMatched=True
|
||||||
|
elif searchSubstr in sharedItem['displayName'].lower():
|
||||||
|
subStrMatched=True
|
||||||
|
elif searchSubstr in sharedItem['category'].lower():
|
||||||
|
subStrMatched=True
|
||||||
|
if not subStrMatched:
|
||||||
matched=False
|
matched=False
|
||||||
if sharedItem['location'].lower() in searchStrLower:
|
break
|
||||||
matched=True
|
ctr+=1
|
||||||
elif searchStrLower in sharedItem['summary'].lower():
|
|
||||||
matched=True
|
|
||||||
elif sharedItem['displayName'].lower() in searchStrLower:
|
|
||||||
matched=True
|
|
||||||
elif sharedItem['category'].lower() in searchStrLower:
|
|
||||||
matched=True
|
|
||||||
if matched:
|
if matched:
|
||||||
sharedItemsForm+='<div class="container">'
|
sharedItemsForm+='<div class="container">'
|
||||||
sharedItemsForm+='<p class="share-title">'+sharedItem['displayName']+'</p>'
|
sharedItemsForm+='<p class="share-title">'+sharedItem['displayName']+'</p>'
|
||||||
|
|
Loading…
Reference in New Issue