forked from indymedia/epicyon
Search for shared items
parent
a44cabb849
commit
1dae3bacca
13
daemon.py
13
daemon.py
|
@ -91,6 +91,7 @@ from webinterface import htmlEditProfile
|
||||||
from webinterface import htmlTermsOfService
|
from webinterface import htmlTermsOfService
|
||||||
from webinterface import htmlHashtagSearch
|
from webinterface import htmlHashtagSearch
|
||||||
from webinterface import htmlModerationInfo
|
from webinterface import htmlModerationInfo
|
||||||
|
from webinterface import htmlSearchSharedItems
|
||||||
from shares import getSharesFeedForPerson
|
from shares import getSharesFeedForPerson
|
||||||
from shares import outboxShareUpload
|
from shares import outboxShareUpload
|
||||||
from shares import outboxUndoShareUpload
|
from shares import outboxUndoShareUpload
|
||||||
|
@ -2225,9 +2226,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.wfile.write(hashtagStr.encode('utf-8'))
|
self.wfile.write(hashtagStr.encode('utf-8'))
|
||||||
self.server.POSTbusy=False
|
self.server.POSTbusy=False
|
||||||
return
|
return
|
||||||
if '@' in searchStr:
|
elif '@' in searchStr:
|
||||||
# profile search
|
# profile search
|
||||||
print('Search: '+searchStr)
|
|
||||||
nickname=getNicknameFromActor(self.path)
|
nickname=getNicknameFromActor(self.path)
|
||||||
if not self.server.session:
|
if not self.server.session:
|
||||||
self.server.session= \
|
self.server.session= \
|
||||||
|
@ -2248,6 +2248,15 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.wfile.write(profileStr.encode('utf-8'))
|
self.wfile.write(profileStr.encode('utf-8'))
|
||||||
self.server.POSTbusy=False
|
self.server.POSTbusy=False
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
# shared items search
|
||||||
|
sharedItemsStr= \
|
||||||
|
htmlSearchSharedItems(self.server.baseDir,searchStr)
|
||||||
|
if sharedItemsStr:
|
||||||
|
self._login_headers('text/html')
|
||||||
|
self.wfile.write(sharedItemsStr.encode('utf-8'))
|
||||||
|
self.server.POSTbusy=False
|
||||||
|
return
|
||||||
self._redirect_headers(actorStr,cookie)
|
self._redirect_headers(actorStr,cookie)
|
||||||
self.server.POSTbusy=False
|
self.server.POSTbusy=False
|
||||||
return
|
return
|
||||||
|
|
|
@ -35,6 +35,49 @@ from content import getMentionsFromHtml
|
||||||
from config import getConfigParam
|
from config import getConfigParam
|
||||||
from skills import getSkills
|
from skills import getSkills
|
||||||
|
|
||||||
|
def htmlSearchSharedItems(baseDir: str,searchStr: str) -> str:
|
||||||
|
sharedItemsForm=''
|
||||||
|
searchStrLower=searchStr.lower()
|
||||||
|
with open(baseDir+'/epicyon-profile.css', 'r') as cssFile:
|
||||||
|
sharedItemsCSS=cssFile.read()
|
||||||
|
sharedItemsForm=htmlHeader(sharedItemsCSS)
|
||||||
|
sharedItemsForm+='<center><h1>Shared Items Search</h1></center>'
|
||||||
|
resultsExist=False
|
||||||
|
for subdir, dirs, files in os.walk(baseDir+'/accounts'):
|
||||||
|
for handle in dirs:
|
||||||
|
if '@' not in handle:
|
||||||
|
continue
|
||||||
|
sharesFilename=baseDir+'/accounts/'+handle+'/shares.json'
|
||||||
|
if not os.path.isfile(sharesFilename):
|
||||||
|
continue
|
||||||
|
with open(sharesFilename, 'r') as fp:
|
||||||
|
sharesJson=commentjson.load(fp)
|
||||||
|
for name,sharedItem in sharesJson.items():
|
||||||
|
matched=False
|
||||||
|
if sharedItem['location'].lower() in searchStrLower:
|
||||||
|
matched=True
|
||||||
|
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:
|
||||||
|
sharedItemsForm+='<div class="container">'
|
||||||
|
sharedItemsForm+='<p class="share-title">'+sharedItem['displayName']+'</p>'
|
||||||
|
sharedItemsForm+='<a href="'+sharedItem['imageUrl']+'">'
|
||||||
|
sharedItemsForm+='<img src="'+sharedItem['imageUrl']+'" alt="Item image"></a>'
|
||||||
|
sharedItemsForm+='<p>'+sharedItem['summary']+'</p>'
|
||||||
|
sharedItemsForm+='<p><b>Type:</b> '+sharedItem['itemType']+' '
|
||||||
|
sharedItemsForm+='<b>Category:</b> '+sharedItem['category']+' '
|
||||||
|
sharedItemsForm+='<b>Location:</b> '+sharedItem['location']+'</p>'
|
||||||
|
sharedItemsForm+='</div>'
|
||||||
|
resultsExist=True
|
||||||
|
if not resultsExist:
|
||||||
|
sharedItemsForm+='<center><h5>No results</h5></center>'
|
||||||
|
sharedItemsForm+=htmlFooter()
|
||||||
|
return sharedItemsForm
|
||||||
|
|
||||||
def htmlModerationInfo(baseDir: str) -> str:
|
def htmlModerationInfo(baseDir: str) -> str:
|
||||||
infoForm=''
|
infoForm=''
|
||||||
with open(baseDir+'/epicyon-profile.css', 'r') as cssFile:
|
with open(baseDir+'/epicyon-profile.css', 'r') as cssFile:
|
||||||
|
|
Loading…
Reference in New Issue