Browse Source

Display search form on results page

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

+ 9
- 4
irclog.py View File

@@ -969,16 +969,20 @@ class WebServer:
if self._paths[request.match_info['path']][2]: # Hidden channels aren't searchable
return aiohttp.web.HTTPNotFound()

searchForm = ''.join([
'<form>',
'<input name="q" ', f'value="{html.escape(request.query["q"])}" ' if 'q' in request.query else '', '/>',
'<input type="submit" value="Search!" />',
'</form>',
])

if 'q' not in request.query:
return aiohttp.web.Response(
text = ''.join([
'<!DOCTYPE html><html lang="en">'
f'<head><title>{html.escape(self._paths[request.match_info["path"]][0])} search</title></head>',
'<body>',
'<form>',
'<input name="q" />',
'<input type="submit" value="Search!" />',
'</form>',
searchForm,
'</body>',
'</html>'
]),
@@ -1067,6 +1071,7 @@ class WebServer:
'<style>#incomplete { background-color: #FF6666; padding: 10px; }</style>',
'</head>',
'<body>',
searchForm,
'<p id="incomplete">Warning: output incomplete due to exceeding time or size limits</p>' if incomplete else '',
self._render_log(lines, withDate = True) or 'No results.',
'</body>',


Loading…
Cancel
Save