Always add Matemat version number to Jinja template.
This commit is contained in:
parent
1b00c80133
commit
0481b5bf98
5 changed files with 32 additions and 46 deletions
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
from jinja2 import Environment, Template
|
from jinja2 import Environment, Template
|
||||||
|
|
||||||
|
from matemat import __version__
|
||||||
|
|
||||||
|
|
||||||
class PageletResponse:
|
class PageletResponse:
|
||||||
"""
|
"""
|
||||||
|
@ -60,4 +62,4 @@ class TemplateResponse(PageletResponse):
|
||||||
:return: An UTF-8 encoded bytes object containing the template rendering result.
|
:return: An UTF-8 encoded bytes object containing the template rendering result.
|
||||||
"""
|
"""
|
||||||
template: Template = jinja_env.get_template(self.name)
|
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')
|
||||||
|
|
17
templates/base.html
Normal file
17
templates/base.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Matemat</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
color: #f0f0f0;
|
||||||
|
background: #000000;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Matemat {{__version__}}</h1>
|
||||||
|
{% block main %}
|
||||||
|
{% endblock %}
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,20 +1,9 @@
|
||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html>
|
|
||||||
<head>
|
{% block main %}
|
||||||
<title>Matemat</title>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
color: #f0f0f0;
|
|
||||||
background: #000000;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Matemat</h1>
|
|
||||||
<form action="/login" method="post">
|
<form action="/login" method="post">
|
||||||
Username: <input type="text" name="username"/><br/>
|
Username: <input type="text" name="username"/><br/>
|
||||||
Password: <input type="password" name="password" /><br/>
|
Password: <input type="password" name="password" /><br/>
|
||||||
<input type="submit" value="Login"/>
|
<input type="submit" value="Login"/>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
{% endblock%}
|
||||||
</html>
|
|
||||||
|
|
|
@ -1,16 +1,6 @@
|
||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html>
|
|
||||||
<head>
|
{% block main %}
|
||||||
<title>Matemat</title>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
color: #f0f0f0;
|
|
||||||
background: #000000;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Matemat</h1>
|
|
||||||
{{ user|default("") }}
|
{{ user|default("") }}
|
||||||
<ul>
|
<ul>
|
||||||
{% if user is defined %}
|
{% if user is defined %}
|
||||||
|
@ -29,5 +19,4 @@
|
||||||
<li/> <a href="/login">Password login</a>
|
<li/> <a href="/login">Password login</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
{% endblock %}
|
||||||
</html>
|
|
||||||
|
|
|
@ -1,20 +1,9 @@
|
||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html>
|
|
||||||
<head>
|
{% block main %}
|
||||||
<title>Matemat</title>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
color: #f0f0f0;
|
|
||||||
background: #000000;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Matemat</h1>
|
|
||||||
<form action="/touchkey" method="post">
|
<form action="/touchkey" method="post">
|
||||||
<input type="hidden" name="username" value="{{ username }}"/><br/>
|
<input type="hidden" name="username" value="{{ username }}"/><br/>
|
||||||
Touchkey: <input type="password" name="touchkey" /><br/>
|
Touchkey: <input type="password" name="touchkey" /><br/>
|
||||||
<input type="submit" value="Login"/>
|
<input type="submit" value="Login"/>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
{% endblock %}
|
||||||
</html>
|
|
||||||
|
|
Loading…
Reference in a new issue