mirror of https://gitlab.com/bashrc2/epicyon
Function to match shared items during search
parent
8c3c22aec3
commit
3a19ec4d2e
|
@ -102,6 +102,23 @@ def htmlSearchEmoji(cssCache: {}, translate: {},
|
||||||
return emojiForm
|
return emojiForm
|
||||||
|
|
||||||
|
|
||||||
|
def _matchSharedItem(searchStrLowerList: [],
|
||||||
|
sharedItem: {}) -> bool:
|
||||||
|
"""Returns true if the shared item matches search criteria
|
||||||
|
"""
|
||||||
|
for searchSubstr in searchStrLowerList:
|
||||||
|
searchSubstr = searchSubstr.strip()
|
||||||
|
if searchSubstr in sharedItem['location'].lower():
|
||||||
|
return True
|
||||||
|
elif searchSubstr in sharedItem['summary'].lower():
|
||||||
|
return True
|
||||||
|
elif searchSubstr in sharedItem['displayName'].lower():
|
||||||
|
return True
|
||||||
|
elif searchSubstr in sharedItem['category'].lower():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def htmlSearchSharedItems(cssCache: {}, translate: {},
|
def htmlSearchSharedItems(cssCache: {}, translate: {},
|
||||||
baseDir: str, searchStr: str,
|
baseDir: str, searchStr: str,
|
||||||
pageNumber: int,
|
pageNumber: int,
|
||||||
|
@ -133,7 +150,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
|
||||||
resultsExist = False
|
resultsExist = False
|
||||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||||
for handle in dirs:
|
for handle in dirs:
|
||||||
if '@' not in handle:
|
if not isAccountDir(handle):
|
||||||
continue
|
continue
|
||||||
contactNickname = handle.split('@')[0]
|
contactNickname = handle.split('@')[0]
|
||||||
sharesFilename = baseDir + '/accounts/' + handle + \
|
sharesFilename = baseDir + '/accounts/' + handle + \
|
||||||
|
@ -146,22 +163,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for name, sharedItem in sharesJson.items():
|
for name, sharedItem in sharesJson.items():
|
||||||
matched = True
|
if _matchSharedItem(searchStrLowerList, sharedItem):
|
||||||
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
|
|
||||||
break
|
|
||||||
if matched:
|
|
||||||
if currPage == pageNumber:
|
if currPage == pageNumber:
|
||||||
sharedItemsForm += '<div class="container">\n'
|
sharedItemsForm += '<div class="container">\n'
|
||||||
sharedItemsForm += \
|
sharedItemsForm += \
|
||||||
|
|
Loading…
Reference in New Issue