summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2013-04-11 21:47:56 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2013-04-11 21:47:56 +0200
commit978f1a4999937a56bd3861a219bb2d9082ba5de6 (patch)
tree69a55977f09000e1c867a2c253c7018050951e72
parent0567318344330295512176569a84afc9748d79c5 (diff)
downloadkosten-978f1a4999937a56bd3861a219bb2d9082ba5de6.tar.gz
kosten-978f1a4999937a56bd3861a219bb2d9082ba5de6.tar.bz2
kosten-978f1a4999937a56bd3861a219bb2d9082ba5de6.zip
404 page in jinja
Diffstat (limited to '')
-rw-r--r--app/views.py6
-rwxr-xr-xindex.py4
-rw-r--r--static/css/style.css2
-rw-r--r--templates/404.jinja9
-rw-r--r--templates/404.mako11
-rw-r--r--templates/page.jinja27
-rw-r--r--templates/page.mako36
-rw-r--r--templates/root.jinja3
8 files changed, 46 insertions, 52 deletions
diff --git a/app/views.py b/app/views.py
index 7450946..accbeb5 100644
--- a/app/views.py
+++ b/app/views.py
@@ -18,9 +18,9 @@ def static_url(s):
return url_for("static", filename=s)
-#@app.errorhandler(404)
-#def page_not_found (error):
-# print request.path
+@app.errorhandler(404)
+def page_not_found (error):
+ return render_template("404.jinja", page = request.path), 404
@app.route("/")
@app.route("/index")
diff --git a/index.py b/index.py
index c3ad9fa..1426022 100755
--- a/index.py
+++ b/index.py
@@ -1,4 +1,6 @@
#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
import sys
from app import app, db
@@ -12,5 +14,7 @@ if cmd == "create":
db.create_all()
elif cmd == "drop":
db.drop_all()
+elif cmd == "compile":
+ app.jinja_env.compile_templates("comp", zip = None)
else:
app.run()
diff --git a/static/css/style.css b/static/css/style.css
index d308227..5b4381b 100644
--- a/static/css/style.css
+++ b/static/css/style.css
@@ -229,7 +229,7 @@ ul.arrow {
margin-bottom: 20px;
}
-.content .title {
+.content .page_heading {
margin-bottom: 20px;
padding-bottom: 5px;
}
diff --git a/templates/404.jinja b/templates/404.jinja
new file mode 100644
index 0000000..c802610
--- /dev/null
+++ b/templates/404.jinja
@@ -0,0 +1,9 @@
+{% extends "page.jinja" %}
+{% set title = "404 -- Seite konnte nicht gefunden werden!" %}
+{% set heading = "404 -- Seite nicht gefunden" %}
+
+{% block content %}
+<p>
+ Sorry - die Seite <i>{{page}}</i> konnte nicht gefunden werden.
+</p>
+{% endblock %}
diff --git a/templates/404.mako b/templates/404.mako
deleted file mode 100644
index c8f5cd2..0000000
--- a/templates/404.mako
+++ /dev/null
@@ -1,11 +0,0 @@
-<%!
- title = "404 -- Seite konnte nicht gefunden werden!"
-%>
-<%inherit file="/page.mako" />
-<p>
- Sorry - die Seite <i>${page}</i> konnte nicht gefunden werden.
-</p>
-
-<%def name="heading()">
- 404 -- Seite nicht gefunden
-</%def>
diff --git a/templates/page.jinja b/templates/page.jinja
new file mode 100644
index 0000000..e1f8af7
--- /dev/null
+++ b/templates/page.jinja
@@ -0,0 +1,27 @@
+{% extends "root.jinja" %}
+
+{# functions #}
+{% macro left_arrow(target,label) -%}
+ <a id="left" href="{{ url_for(target) }}">
+ <img src="{{ "images/arrow_left.png" | static_url }}">
+ <span class="navdate">{{label}}</span>
+ </a>
+{%- endmacro %}
+
+{% macro right_arrow(target,label) -%}
+ <a id="right" href="{{ url_for(target) }}">
+ <img src="{{ "images/arrow_right.png" | static_url }}">
+ <span class="navdate">{{label}}</span>
+ </a>
+{%- endmacro %}
+
+{% macro colorize(fgcolor=None, bgcolor=None, tag='span') -%}
+ {% if not fgcolor and not bgcolor %}
+ {{ caller() }}
+ {% else %}
+ {% set style = "" %}
+ {% if fgcolor: %}{% set style = style + " color: " + fgcolor %}{% endif %}
+ {% if bgcolor: %}{% set style = style + " background: " + bgcolor %}{% endif %}
+ <{{tag}} style="{{style}}">{{caller()}}</{{tag}}>
+ {% endif %}
+{% endmacro %}
diff --git a/templates/page.mako b/templates/page.mako
deleted file mode 100644
index 77d24a2..0000000
--- a/templates/page.mako
+++ /dev/null
@@ -1,36 +0,0 @@
-<%inherit file="/root.mako" />
-
-## content
-
-<h1 class="title">
- <%block name="heading"></%block>
-</h1>
-${next.body()}
-
-## functions
-<%def name="left_arrow(target,label)">
- <a id="left" href=${"/%s" % target | url}>
- <img src=${"/static/images/arrow_left.png" | url} />
- <span class="navdate">${label}</span>
- </a>
-</%def>
-
-<%def name="right_arrow(target,label)">
- <a id="right" href=${"/%s" % target | url}>
- <img src=${"/static/images/arrow_right.png" | url} />
- <span class="navdate">${label}</span>
- </a>
-</%def>
-
-<%def name="colorize(fgcolor=None, bgcolor=None, tag='span')">
- % if fgcolor is None and bgcolor is None:
- ${caller.body()}
- % else:
- <%
- style = ""
- if fgcolor is not None: style += " color: " + fgcolor
- if bgcolor is not None: style += " background: "+ bgcolor
- %>
- <${tag} style="${style}">${caller.body()}</${tag}>
- % endif
-</%def>
diff --git a/templates/root.jinja b/templates/root.jinja
index 7debb6a..b17ac92 100644
--- a/templates/root.jinja
+++ b/templates/root.jinja
@@ -9,7 +9,7 @@
{% endblock %}
{% endif %}
<link rel="shortcut icon" href="{{ "images/currency.png" | static_url }}" type="image/icon">
- <title>{% block title -%}Kostenverwaltung{%- endblock %}</title>
+ <title>{{ title or "Kostenverwaltung" }}</title>
{% block style %}
<link href="{{ "css/style.css" | static_url }}" rel="stylesheet" type="text/css">
{% endblock %}
@@ -39,6 +39,7 @@
<div id="page">
<div class="content">
+ <h1 class="page_heading">{{ heading }}</h1>
{% block content %}{% endblock %}
</div>
<div style="clear: both;"></div>