Browse Source

Make search case-insensitive by default and add a checkbox for toggling

master
JustAnotherArchivist 3 years ago
parent
commit
9cb31c17cd
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      irclog.py

+ 6
- 1
irclog.py View File

@@ -1050,6 +1050,8 @@ class WebServer:
'<form>',
'<input name="q" ', f'value="{html.escape(request.query["q"])}" ' if 'q' in request.query else '', '/>',
'<input type="submit" value="Search!" />',
'<br />',
'<input type="checkbox" name="casesensitive" value="true" ', 'checked ' if 'casesensitive' in request.query else '', '/>&nbsp;Case-sensitive',
'</form>',
])

@@ -1072,8 +1074,11 @@ class WebServer:
# So instead, use a wrapper script in Bash which sets the niceness and memory limit.
cmd = [
os.path.join('.', os.path.dirname(__file__), 'nicegrep'), str(self.config['web']['search']['nice']), str(self.config['web']['search']['maxMemory']),
'--fixed-strings', '--recursive', '--with-filename', '--null', '--line-number', request.query['q']
'--fixed-strings', '--recursive', '--with-filename', '--null', '--line-number',
]
if 'casesensitive' not in request.query:
cmd.append('--ignore-case')
cmd.append(request.query['q'])
for path in itertools.chain((request.match_info['path'],), self._paths[request.match_info['path']][3]):
cmd.append(os.path.join(self.config['storage']['path'], path, ''))



Loading…
Cancel
Save