mirror of https://gitlab.com/bashrc2/epicyon
Add cw script to history search
parent
1831af8226
commit
70443f4d04
17
utils.py
17
utils.py
|
@ -7,7 +7,6 @@ __email__ = "bob@freedombone.net"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
import datetime
|
import datetime
|
||||||
|
@ -733,27 +732,25 @@ def isBlogPost(postJsonObject: {}) -> bool:
|
||||||
|
|
||||||
|
|
||||||
def searchBoxPosts(baseDir: str, nickname: str, domain: str,
|
def searchBoxPosts(baseDir: str, nickname: str, domain: str,
|
||||||
searchRegex: str, maxResults: int,
|
searchStr: str, maxResults: int,
|
||||||
boxName='outbox') -> []:
|
boxName='outbox') -> []:
|
||||||
"""Uses a regular expression to search for posts
|
"""Search your posts and return a list of the filenames
|
||||||
and returns a list of the filenames
|
containing matching strings
|
||||||
"""
|
"""
|
||||||
path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName
|
path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
print('SEARCH: directory does not exist ' + path)
|
print('SEARCH: directory does not exist ' + path)
|
||||||
return []
|
return []
|
||||||
searchRegex = searchRegex.strip()
|
searchStr = searchStr.strip()
|
||||||
# regObj = re.compile(searchRegex)
|
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
for root, dirs, fnames in os.walk(path):
|
for root, dirs, fnames in os.walk(path):
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
filePath = os.path.join(root, fname)
|
filePath = os.path.join(root, fname)
|
||||||
with open(filePath, 'r') as postFile:
|
with open(filePath, 'r') as postFile:
|
||||||
data = postFile.read()
|
data = postFile.read()
|
||||||
# if not regObj.match(data):
|
if searchStr not in data:
|
||||||
if searchRegex not in data:
|
continue
|
||||||
continue
|
|
||||||
|
|
||||||
res.append(filePath)
|
res.append(filePath)
|
||||||
if len(res) >= maxResults:
|
if len(res) >= maxResults:
|
||||||
|
|
|
@ -771,6 +771,7 @@ def htmlHistorySearch(translate: {}, baseDir: str,
|
||||||
historySearchCSS.replace('https://',
|
historySearchCSS.replace('https://',
|
||||||
httpPrefix + '://')
|
httpPrefix + '://')
|
||||||
historySearchForm = htmlHeader(cssFilename, historySearchCSS)
|
historySearchForm = htmlHeader(cssFilename, historySearchCSS)
|
||||||
|
historySearchForm += '<script>' + contentWarningScript() + '</script>'
|
||||||
|
|
||||||
# add the page title
|
# add the page title
|
||||||
historySearchForm += \
|
historySearchForm += \
|
||||||
|
|
Loading…
Reference in New Issue