From f36265443efae3d5aae8f9d3c844331fcc81ec6c Mon Sep 17 00:00:00 2001 From: n9k Date: Tue, 22 Feb 2022 23:03:14 +0000 Subject: [PATCH] Beautify nojs chat template, strip jinja whitespace --- anonstream/__init__.py | 4 ++++ anonstream/templates/nojs_chat.html | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/anonstream/__init__.py b/anonstream/__init__.py index 440c878..2fcbd73 100644 --- a/anonstream/__init__.py +++ b/anonstream/__init__.py @@ -20,6 +20,10 @@ def create_app(config_file): print('Broadcaster password:', auth_password) app = Quart('anonstream') + app.jinja_options.update({ + 'trim_blocks': True, + 'lstrip_blocks': True, + }) app.config.update({ 'SECRET_KEY': config['secret_key'].encode(), 'AUTH_USERNAME': config['auth']['username'], diff --git a/anonstream/templates/nojs_chat.html b/anonstream/templates/nojs_chat.html index 1d841b4..5b53681 100644 --- a/anonstream/templates/nojs_chat.html +++ b/anonstream/templates/nojs_chat.html @@ -136,7 +136,21 @@ {% for message in messages | reverse %}
  • {% with user = users_by_token[message.token] %} -  {{ user.name or get_default_name(user) }}{% if not user.broadcaster and user.name is none %}{{ user.tag }}{% endif %}{% if user.tripcode %} {{ user.tripcode.digest }}{% endif %}: {{ message.markup }} + + {{- ' ' | safe -}} + + {{- user.name or get_default_name(user) -}} + {%- if not user.broadcaster and user.name is none -%} + {{ user.tag }} + {%- endif -%} + + {%- if user.tripcode -%} +   + {{- '' -}} + {{ user.tripcode.digest }} + {%- endif -%} + {{- ': ' | safe -}} + {{ message.markup }} {% endwith %}
  • {% endfor %}