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=False
|
matched=True
|
||||||
if sharedItem['location'].lower() in searchStrLower:
|
ctr=0
|
||||||
matched=True
|
for searchSubstr in searchStrLowerList:
|
||||||
elif searchStrLower in sharedItem['summary'].lower():
|
subStrMatched=False
|
||||||
matched=True
|
searchSubstr=searchSubstr.strip()
|
||||||
elif sharedItem['displayName'].lower() in searchStrLower:
|
if searchSubstr in sharedItem['location'].lower():
|
||||||
matched=True
|
subStrMatched=True
|
||||||
elif sharedItem['category'].lower() in searchStrLower:
|
elif searchSubstr in sharedItem['summary'].lower():
|
||||||
matched=True
|
subStrMatched=True
|
||||||
|
elif searchSubstr in sharedItem['displayName'].lower():
|
||||||
|
subStrMatched=True
|
||||||
|
elif searchSubstr in sharedItem['category'].lower():
|
||||||
|
subStrMatched=True
|
||||||
|
if not subStrMatched:
|
||||||
|
matched=False
|
||||||
|
break
|
||||||
|
ctr+=1
|
||||||
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