From de024bc937f4b8b326616df76c8a64878a235c91 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Thu, 21 Feb 2013 15:26:24 +0100 Subject: added a base template to the webapp --- base.html | 10 ++++++++++ webapp.py | 49 +++++++++++++++++++++++++++++++------------------ 2 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 base.html diff --git a/base.html b/base.html new file mode 100644 index 0000000..65bc6df --- /dev/null +++ b/base.html @@ -0,0 +1,10 @@ + + + {% block title %}{% endblock %} + {% block header %}{% endblock %} + + +{% block content %} +{% endblock %} + + diff --git a/webapp.py b/webapp.py index b37dca5..e175507 100755 --- a/webapp.py +++ b/webapp.py @@ -8,7 +8,7 @@ from werkzeug.exceptions import HTTPException, NotFound from werkzeug.routing import Map, Rule, RequestRedirect from werkzeug.wrappers import Request, Response -jinjaenv = jinja2.Environment() +jinjaenv = jinja2.Environment(loader=jinja2.FileSystemLoader(".")) def format_size(size): assert isinstance(size, int) @@ -27,9 +27,13 @@ def format_size(size): jinjaenv.filters["format_size"] = format_size +base_template = jinjaenv.get_template("base.html") + package_template = jinjaenv.from_string( -"""duplication of {{ package|e }} -

{{ package|e }}

+"""{% extends "base.html" %} +{% block title %}duplication of {{ package|e }}{% endblock %} +{% block header %}{% endblock %} +{% block content %}

{{ package|e }}

Version: {{ version|e }}

Architecture: {{ architecture|e }}

Number of files: {{ num_files }}

@@ -48,12 +52,13 @@ package_template = jinjaenv.from_string( {%- endfor -%} {%- endif -%} -{{ content }} -""") +{% endblock %}""") detail_template = jinjaenv.from_string( -"""sharing between {{ details1.package|e }} and {{ details2.package|e }} -

{{ details1.package|e }} <-> {{ details2.package|e }}

+"""{% extends "base.html" %} +{% block title %}sharing between {{ details1.package|e }} and {{ details2.package|e }}{% endblock%} +{% block content %} +

{{ details1.package|e }} <-> {{ details2.package|e }}

{%- if shared -%} {%- for entry in shared|sort(attribute="size", reverse=true) -%} @@ -62,18 +67,32 @@ detail_template = jinjaenv.from_string( {%- endfor -%}
sizefilename in {{ details1.package|e }}filename in {{ details2.package|e }}hash functions
{%- endif -%} -""") +{% endblock %}""") hash_template = jinjaenv.from_string( -"""information on {{ function|e }} hash {{ hashvalue|e }} -

{{ function|e }} {{ hashvalue|e }}

+"""{% extends "base.html" %} +{% block title %}information on {{ function|e }} hash {{ hashvalue|e }}{% endblock %} +{% block content %} +

{{ function|e }} {{ hashvalue|e }}

{%- for entry in entries -%} {%- endfor -%}
packagefilenamesize
{{ entry.package|e }} {{ entry.filename|e }}{{ entry.size|format_size }}
-""") +{% endblock %}""") + +index_template = jinjaenv.from_string( +"""{% extends "base.html" %} +{% block title %}Debian duplication detector{% endblock %} +{% block content %} +

Debian duplication detector

+