Implemented template inheritance and brought back errors

This commit is contained in:
Simon Willison 2017-10-23 19:56:27 -07:00
commit b20d7119e4
5 changed files with 40 additions and 15 deletions

14
templates/base.html Normal file
View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% endblock %}</title>
{% block extra_head %}{% endblock %}
</head>
<body>
{% if error %}
<div style="padding: 1em; margin: 1em; border: 3px solid red;">{{ error }}</div>
{% endif %}
{% block content %}
{% endblock %}
</body>
</html>

View file

@ -1,3 +1,8 @@
{% extends "base.html" %}
{% block title %}{{ database }}{% endblock %}
{% block content %}
<h1>{{ database }}</h1>
<style>
@ -25,3 +30,4 @@ td {
</tr>
{% endfor %}
</table>
{% endblock %}

View file

@ -1,4 +1,11 @@
{% extends "base.html" %}
{% block title %}Databases{% endblock %}
{% block content %}
<h1>Database{% if databases.keys()|length != 1 %}s{% endif %}</h1>
{% for name, info in databases.items() %}
<p><a href="{{ name}}-{{ info.hash|truncate(7, end='') }}">{{ name }}</a></p>
{% endfor %}
{% endblock %}

View file

@ -1,3 +1,8 @@
{% extends "base.html" %}
{% block title %}{{ database }}: {{ table }}{% endblock %}
{% block content %}
<h1><a href="/{{ database }}-{{ database_hash }}">{{ database }}</a></h1>
<h2>{{ table }}</h2>
@ -22,3 +27,4 @@ td {
</tr>
{% endfor %}
</table>
{% endblock %}