From 70443f4d041b8d0b9de53fdf950a96b2ac2023cc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 11 Apr 2020 14:20:52 +0100 Subject: [PATCH] Add cw script to history search --- utils.py | 17 +++++++---------- webinterface.py | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/utils.py b/utils.py index d10688787..fe631b2ee 100644 --- a/utils.py +++ b/utils.py @@ -7,7 +7,6 @@ __email__ = "bob@freedombone.net" __status__ = "Production" import os -import re import time import shutil import datetime @@ -733,27 +732,25 @@ def isBlogPost(postJsonObject: {}) -> bool: def searchBoxPosts(baseDir: str, nickname: str, domain: str, - searchRegex: str, maxResults: int, + searchStr: str, maxResults: int, boxName='outbox') -> []: - """Uses a regular expression to search for posts - and returns a list of the filenames + """Search your posts and return a list of the filenames + containing matching strings """ path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName if not os.path.isdir(path): print('SEARCH: directory does not exist ' + path) return [] - searchRegex = searchRegex.strip() - # regObj = re.compile(searchRegex) - + searchStr = searchStr.strip() + res = [] for root, dirs, fnames in os.walk(path): for fname in fnames: filePath = os.path.join(root, fname) with open(filePath, 'r') as postFile: data = postFile.read() - # if not regObj.match(data): - if searchRegex not in data: - continue + if searchStr not in data: + continue res.append(filePath) if len(res) >= maxResults: diff --git a/webinterface.py b/webinterface.py index 6ad502b1f..3fbe7eec9 100644 --- a/webinterface.py +++ b/webinterface.py @@ -771,6 +771,7 @@ def htmlHistorySearch(translate: {}, baseDir: str, historySearchCSS.replace('https://', httpPrefix + '://') historySearchForm = htmlHeader(cssFilename, historySearchCSS) + historySearchForm += '' # add the page title historySearchForm += \