From 0481b5bf9853163c055db9893103e2c518968bf5 Mon Sep 17 00:00:00 2001 From: s3lph Date: Mon, 9 Jul 2018 22:46:35 +0200 Subject: [PATCH 1/2] Always add Matemat version number to Jinja template. --- matemat/webserver/responses.py | 4 +++- templates/base.html | 17 +++++++++++++++++ templates/login.html | 19 ++++--------------- templates/main.html | 19 ++++--------------- templates/touchkey.html | 19 ++++--------------- 5 files changed, 32 insertions(+), 46 deletions(-) create mode 100644 templates/base.html diff --git a/matemat/webserver/responses.py b/matemat/webserver/responses.py index f1e7f90..6f0308f 100644 --- a/matemat/webserver/responses.py +++ b/matemat/webserver/responses.py @@ -1,6 +1,8 @@ from jinja2 import Environment, Template +from matemat import __version__ + class PageletResponse: """ @@ -60,4 +62,4 @@ class TemplateResponse(PageletResponse): :return: An UTF-8 encoded bytes object containing the template rendering result. """ template: Template = jinja_env.get_template(self.name) - return template.render(**self.kwargs).encode('utf-8') + return template.render(**self.kwargs, __version__=__version__).encode('utf-8') diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..1ddd113 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,17 @@ + + + + Matemat + + + +

Matemat {{__version__}}

+ {% block main %} + {% endblock %} + + diff --git a/templates/login.html b/templates/login.html index bdb7168..13c5dca 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,20 +1,9 @@ - - - - Matemat - - - -

Matemat

+{% extends "base.html" %} + +{% block main %}
Username:
Password:
- - +{% endblock%} diff --git a/templates/main.html b/templates/main.html index d9a6d45..6aa5887 100644 --- a/templates/main.html +++ b/templates/main.html @@ -1,16 +1,6 @@ - - - - Matemat - - - -

Matemat

+{% extends "base.html" %} + +{% block main %} {{ user|default("") }} - - +{% endblock %} diff --git a/templates/touchkey.html b/templates/touchkey.html index ab12308..bb0a5b9 100644 --- a/templates/touchkey.html +++ b/templates/touchkey.html @@ -1,20 +1,9 @@ - - - - Matemat - - - -

Matemat

+{% extends "base.html" %} + +{% block main %}

Touchkey:
- - +{% endblock %} From 63a1ac291f6aaf2f1826cba21ceec69c627a798b Mon Sep 17 00:00:00 2001 From: s3lph Date: Mon, 9 Jul 2018 23:48:37 +0200 Subject: [PATCH 2/2] Updated pagelet documentation to adopt the PageletResponse return value API. --- doc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc b/doc index 51e9404..9634785 160000 --- a/doc +++ b/doc @@ -1 +1 @@ -Subproject commit 51e940460ddbaebb7f2ffc48d00d9ef19cf8d33f +Subproject commit 9634785e5621b324f72598b3cee83bbc45c25d7b