From 978f1a4999937a56bd3861a219bb2d9082ba5de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Thu, 11 Apr 2013 21:47:56 +0200 Subject: 404 page in jinja --- app/views.py | 6 +++--- index.py | 4 ++++ static/css/style.css | 2 +- templates/404.jinja | 9 +++++++++ templates/404.mako | 11 ----------- templates/page.jinja | 27 +++++++++++++++++++++++++++ templates/page.mako | 36 ------------------------------------ templates/root.jinja | 3 ++- 8 files changed, 46 insertions(+), 52 deletions(-) create mode 100644 templates/404.jinja delete mode 100644 templates/404.mako create mode 100644 templates/page.jinja delete mode 100644 templates/page.mako 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 %} +

+ Sorry - die Seite {{page}} konnte nicht gefunden werden. +

+{% 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" /> -

- Sorry - die Seite ${page} konnte nicht gefunden werden. -

- -<%def name="heading()"> - 404 -- Seite nicht gefunden - 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) -%} + + + {{label}} + +{%- endmacro %} + +{% macro right_arrow(target,label) -%} + + + {{label}} + +{%- 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()}} + {% 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 - -

- <%block name="heading"> -

-${next.body()} - -## functions -<%def name="left_arrow(target,label)"> - - - ${label} - - - -<%def name="right_arrow(target,label)"> - - - ${label} - - - -<%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()} - % endif - 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 %} - {% block title -%}Kostenverwaltung{%- endblock %} + {{ title or "Kostenverwaltung" }} {% block style %} {% endblock %} @@ -39,6 +39,7 @@
+

{{ heading }}

{% block content %}{% endblock %}
-- cgit v1.2.3