From f50aa7f0d881c44f8111a33b5c8f030b7e1c95c6 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Mon, 19 Oct 2020 03:23:46 +0000 Subject: [PATCH] More style updates and crosslinks --- irclog.py | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/irclog.py b/irclog.py index 5c51b8a..4062399 100644 --- a/irclog.py +++ b/irclog.py @@ -817,6 +817,10 @@ class WebServer: 'tr.command_NICK, tr.command_ACCOUNT, tr.command_MODE, tr.command_TOPIC, tr.command_TOPICWHO, tr.command_WHOX { color: grey; }', 'tr.command_NOTICE td:nth-child(3) { font-style: italic; }', ]) + '' + generalStyleTag = '' def __init__(self, config): self.config = config @@ -889,11 +893,23 @@ class WebServer: async def get_channel_info(self, request): self.logger.info(f'Received request {id(request)} from {request.remote!r} for {request.path!r}') + description = html.escape(self._paths[request.match_info["path"]][4]) if self._paths[request.match_info["path"]][4] else '(not available)' return aiohttp.web.Response( text = ''.join([ '', - f'{html.escape(self._paths[request.match_info["path"]][0])}', - f'{html.escape(self._paths[request.match_info["path"]][4] or "")}', + f'{html.escape(self._paths[request.match_info["path"]][0])}{self.generalStyleTag}', + '', + '', + '
', + '

', + f'Channel: {html.escape(self._paths[request.match_info["path"]][0])}
', + f'Description: {description}', + '

', + '', '' ]), content_type = 'text/html' @@ -965,24 +981,25 @@ class WebServer: date = datetime.datetime.strptime(request.match_info['date'], '%Y-%m-%d').replace(tzinfo = datetime.timezone.utc) dateStart = date.timestamp() dateEnd = (date + datetime.timedelta(days = 1)).timestamp() - channelLinks = ' '.join([ + channelLinks = '' #TODO Implement this in a better way... fn = date.strftime('%Y-%m.log') lines = list(self._raw_to_lines(self._file_iter_with_path(os.path.join(self.config['storage']['path'], request.match_info["path"], fn), request.match_info["path"]), filter = lambda path, ts, command, content: dateStart <= ts <= dateEnd)) return aiohttp.web.Response( text = ''.join([ '', - f'{html.escape(self._paths[request.match_info["path"]][0])} log for {date:%Y-%m-%d}{self.logStyleTag}', + f'{html.escape(self._paths[request.match_info["path"]][0])} log for {date:%Y-%m-%d}{self.generalStyleTag}{self.logStyleTag}', '', - f'

{channelLinks}

', + channelLinks, '
', self._render_log(lines), '
', - f'

{channelLinks}

', + channelLinks, '', '', ]), @@ -995,6 +1012,12 @@ class WebServer: if self._paths[request.match_info['path']][2]: # Hidden channels aren't searchable return aiohttp.web.HTTPNotFound() + linkBar = ''.join([ + '', + ]) searchForm = ''.join([ '
', '', @@ -1006,8 +1029,9 @@ class WebServer: return aiohttp.web.Response( text = ''.join([ '' - f'{html.escape(self._paths[request.match_info["path"]][0])} search', + f'{html.escape(self._paths[request.match_info["path"]][0])} search{self.generalStyleTag}', '', + linkBar, searchForm, '', '' @@ -1093,13 +1117,16 @@ class WebServer: '', '', f'{html.escape(self._paths[request.match_info["path"]][0])} search results for "{html.escape(request.query["q"])}"', + self.generalStyleTag, self.logStyleTag, '', '', '', + linkBar, searchForm, '

Warning: output incomplete due to exceeding time or size limits

' if incomplete else '', self._render_log(lines, withDate = True) or 'No results.', + linkBar, '', '' ]),