From 010f90e1fe49797dd43e61ceb1d0c44b05174771 Mon Sep 17 00:00:00 2001 From: Michael Thies Date: Sun, 24 May 2020 21:45:56 +0200 Subject: [PATCH] web: Add finished date to results pages and improve headings --- qaqa_bot/i18n/de/LC_MESSAGES/qaqa_bot.po | 34 +++++++++++++---------- qaqa_bot/templates/game_result.mako.html | 5 +++- qaqa_bot/templates/sheet_result.mako.html | 7 +++-- qaqa_bot/web.py | 3 ++ qaqa_bot/web_static/style.css | 6 ++++ setup.py | 1 + 6 files changed, 39 insertions(+), 17 deletions(-) diff --git a/qaqa_bot/i18n/de/LC_MESSAGES/qaqa_bot.po b/qaqa_bot/i18n/de/LC_MESSAGES/qaqa_bot.po index 51a64af..05b9560 100644 --- a/qaqa_bot/i18n/de/LC_MESSAGES/qaqa_bot.po +++ b/qaqa_bot/i18n/de/LC_MESSAGES/qaqa_bot.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: QAQABot\n" "Report-Msgid-Bugs-To: mail@mhthies.de\n" -"POT-Creation-Date: 2020-05-12 22:28+0200\n" +"POT-Creation-Date: 2020-05-24 21:41+0200\n" "PO-Revision-Date: 2020-04-22 21:32+0200\n" "Last-Translator: Michael Thies \n" "Language: de\n" @@ -116,10 +116,10 @@ msgid "" " want to play the game with and spawn, join and start a game." msgstr "" "Hi! Ich bin der nette QAQA-Bot 🤖. \n" -"Ich werde dich durch (hoffentlich) viele Runden des Frage-Antwort-" -"Frage-Antwort-Party-Spiels führen. Danke für's Anmelden! Wechsle nun" -" in die Gruppe, in der du das Spiel spielen möchtest, tritt dem Spiel" -" dort bei und starte es." +"Ich werde dich durch (hoffentlich) viele Runden des Frage-Antwort-Frage-" +"Antwort-Party-Spiels führen. Danke für's Anmelden! Wechsle nun in die " +"Gruppe, in der du das Spiel spielen möchtest, tritt dem Spiel dort bei " +"und starte es." #: qaqa_bot/game.py:284 msgid "Already a running or pending game in this chat" @@ -240,8 +240,8 @@ msgid "" "Changing message “{old_text}” is not accepted, because the relevant game " "is already finished." msgstr "" -"Die Veränderung der Nachricht „{old_text}“ wurde nicht akzeptiert, da das " -"zugehörige Spiel bereits beendet ist." +"Die Veränderung der Nachricht „{old_text}“ wurde nicht akzeptiert, da das" +" zugehörige Spiel bereits beendet ist." #: qaqa_bot/game.py:619 msgid "" @@ -433,22 +433,28 @@ msgstr "" "href=\"{url}\">{url} an." #: qaqa_bot/templates/game_result.mako.html:5 -#: qaqa_bot/templates/game_result.mako.html:8 +msgid "Game in {game_name} on {date}" +msgstr "Spiel in {game_name} am {date}" + +#: qaqa_bot/templates/game_result.mako.html:10 msgid "Game in {game_name}" msgstr "Spiel in {game_name}" -#: qaqa_bot/templates/game_result.mako.html:16 +#: qaqa_bot/templates/game_result.mako.html:19 msgid "Results without authors" msgstr "Ergebnisse ohne Autoren" #: qaqa_bot/templates/sheet_result.mako.html:5 -#: qaqa_bot/templates/sheet_result.mako.html:10 -msgid "Sheet from Game in {game_name}" -msgstr "Blatt aus Spiel in {game_name}" +msgid "Sheet from {game_name} on {date}" +msgstr "Blatt aus {game_name} vom {date}" + +#: qaqa_bot/templates/sheet_result.mako.html:12 +msgid "Sheet from {game_name}" +msgstr "Blatt aus {game_name}" -#: qaqa_bot/templates/sheet_result.mako.html:16 +#: qaqa_bot/templates/sheet_result.mako.html:19 msgid "Sheet without authors" -msgstr "Blätter ohne Autoren" +msgstr "Blatt ohne Autoren" #: qaqa_bot/templates/util.mako.html:17 msgid "Q:" diff --git a/qaqa_bot/templates/game_result.mako.html b/qaqa_bot/templates/game_result.mako.html index 406f64f..89aa81a 100644 --- a/qaqa_bot/templates/game_result.mako.html +++ b/qaqa_bot/templates/game_result.mako.html @@ -2,10 +2,13 @@ <%namespace name="util" file="util.mako.html"/> ## TODO add date -<%block name="title">${gettext("Game in {game_name}").format(game_name=game.name)} | QAQA Game Bot +<%block name="title">${gettext("Game in {game_name} on {date}")\ + .format(game_name=game.name,\ + date=format_date(game.finished, locale=lang))} | QAQA Game Bot ## TODO add date

${gettext("Game in {game_name}").format(game_name=game.name)}

+
${format_datetime(game.finished, locale=lang)}
% for sheet in game.sheets: ${util.print_sheet(sheet=sheet)} diff --git a/qaqa_bot/templates/sheet_result.mako.html b/qaqa_bot/templates/sheet_result.mako.html index caa649d..e874502 100644 --- a/qaqa_bot/templates/sheet_result.mako.html +++ b/qaqa_bot/templates/sheet_result.mako.html @@ -2,12 +2,15 @@ <%namespace name="util" file="util.mako.html"/> ## TODO add date -<%block name="title">${gettext("Sheet from Game in {game_name}").format(game_name=sheet.game.name)} +<%block name="title">${gettext("Sheet from {game_name} on {date}")\ + .format(game_name=sheet.game.name,\ + date=format_date(sheet.game.finished, locale=lang))} | QAQA Game Bot ## TODO add date -

${gettext("Sheet from Game in {game_name}").format(game_name=sheet.game.name)}

+

${gettext("Sheet from {game_name}").format(game_name=sheet.game.name)}

+
${format_datetime(sheet.game.finished, locale=lang)}
${util.print_sheet(sheet=sheet)} diff --git a/qaqa_bot/web.py b/qaqa_bot/web.py index c189686..5d33684 100644 --- a/qaqa_bot/web.py +++ b/qaqa_bot/web.py @@ -30,6 +30,7 @@ import os from typing import Dict, Any, Optional +import babel.dates import cherrypy import mako.lookup import markupsafe @@ -90,6 +91,8 @@ def __init__(self, config: Dict[str, Any], game_server: GameServer): 'base_url': config['web']['base_url'], 'static_url': lambda file_name: "{}/static/{}".format(config['web']['base_url'], file_name), # TODO add version to control caching 'encode_id': lambda realm, val: encode_secure_id(val, config['secret'], realm), + 'format_date': babel.dates.format_date, + 'format_datetime': babel.dates.format_datetime, } def render_template(self, template_name: str, params: Dict[str, Any], locale: Optional[str] = None) -> str: diff --git a/qaqa_bot/web_static/style.css b/qaqa_bot/web_static/style.css index ba42500..c91fad0 100644 --- a/qaqa_bot/web_static/style.css +++ b/qaqa_bot/web_static/style.css @@ -3,6 +3,12 @@ body { font-size: 20px; } +.subtitle { + margin: -1rem 0 2rem; + font-size: 1.5rem; + font-weight: bold; +} + .container { width: 100%; max-width: 600px; diff --git a/setup.py b/setup.py index dffb297..cde2b1c 100644 --- a/setup.py +++ b/setup.py @@ -60,6 +60,7 @@ class build_with_l10n(build): 'python-telegram-bot>=12.2', 'toml>=0.10', 'alembic>=1.0', + 'Babel>=2.8', 'cherrypy', ], classifiers=[