Quellcode durchsuchen

Display search form on results page

master
JustAnotherArchivist vor 3 Jahren
Ursprung
Commit
d4b823da80
1 geänderte Dateien mit 9 neuen und 4 gelöschten Zeilen
  1. +9
    -4
      irclog.py

+ 9
- 4
irclog.py Datei anzeigen

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


Laden…
Abbrechen
Speichern