Parcourir la source

Display search form on results page

master
JustAnotherArchivist il y a 3 ans
Parent
révision
d4b823da80
1 fichiers modifiés avec 9 ajouts et 4 suppressions
  1. +9
    -4
      irclog.py

+ 9
- 4
irclog.py Voir le fichier

@@ -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>',


Chargement…
Annuler
Enregistrer