summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-03-16 16:12:14 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-03-16 16:12:40 +0100
commit77853c086d2b93b9e1dbdda69f49cd2ac5a9a7ea (patch)
treedba98a81943711f3c0d8793fa7d28c5487b5f15b
downloadauditor-77853c086d2b93b9e1dbdda69f49cd2ac5a9a7ea.tar.gz
auditor-77853c086d2b93b9e1dbdda69f49cd2ac5a9a7ea.tar.bz2
auditor-77853c086d2b93b9e1dbdda69f49cd2ac5a9a7ea.zip
initial commit
-rw-r--r--.gitmodules4
-rw-r--r--index.html.j255
m---------static/web-common0
-rwxr-xr-xtemplate.py81
4 files changed, 140 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..45c8efd
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,4 @@
+[submodule "static/web-common"]
+ path = static/web-common
+ url = git://taler.net/web-common
+ branch = master
diff --git a/index.html.j2 b/index.html.j2
new file mode 100644
index 0000000..93a5f46
--- /dev/null
+++ b/index.html.j2
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html lang="en" data-taler-nojs="true">
+<head profile="http://www.w3.org/2005/10/profile">
+ <meta charset="utf-8"/>
+ <title>Taler Demo - Auditor</title>
+ <link rel="stylesheet" type="text/css" href="{{ url('static/web-common/pure.css') }}" />
+ <link rel="stylesheet" type="text/css" href="{{ url('static/web-common/demo.css') }}" />
+ <link rel="stylesheet" type="text/css" href="{{ url('static/web-common/taler-fallback.css') }}" id="taler-presence-stylesheet" />
+ <link rel="icon" type="image/png" href="{{ url('static/web-common/favicon-taler.ico') }}" />
+
+ <style type="text/css">
+ a[disabled="true"] {
+ pointer-events: none;
+ color: grey;
+ }
+
+ .bluebox {
+ background-color: #C2C6FF;
+ border: solid;
+ border-radius: 5px;
+ padding: 0.5em;
+ }
+ .greenbox {
+ background-color: #5EFF64;
+ border: solid;
+ border-radius: 5px;
+ padding: 0.5em;
+ }
+ .graybox {
+ background-color: #DDDDDD;
+ border: solid;
+ border-radius: 5px;
+ padding: 0.5em;
+ }
+ </style>
+</head>
+
+<body>
+ <div class="demobar">
+ <h1><span class="tt adorn-brackets">Taler Demo</span></h1>
+ <h1><span class="it"><a href="#">Auditor</a></span></h1>
+ <p>This is an auditor for the currency "{{ currency }}".</p>
+ <ul>
+ <li><a href="{{ intro_url }}">Introduction</a></li>
+ <li><a href="{{ bank_url }}">Bank</a></li>
+ <li><a href="{{ merchant_blog_url }}">Essay Shop</a></li>
+ <li><a href="{{ merchant_donations_url }}">Donations</a></li>
+ </ul>
+ <p>You can learn more about Taler on our main <a href="https://taler.net">website</a>.</p>
+ </div>
+ <section id="main" class="content">
+ <button class="pure-button pure-button-primary" onclick="addAuditor()">Add Auditor</button>
+ </section>
+</body>
+</html>
diff --git a/static/web-common b/static/web-common
new file mode 160000
+Subproject 6dd8ca1675817cc0ca65f0819489234eeafaa2e
diff --git a/template.py b/template.py
new file mode 100755
index 0000000..c731c9c
--- /dev/null
+++ b/template.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+# This file is in the public domain.
+#
+# This script runs the jinga2 templating engine on an input template-file
+# using the specified locale for gettext translations, and outputs
+# the resulting (HTML) ouptut-file.
+#
+# Note that the gettext files need to be prepared first. This script
+# is thus to be invoked via the Makefile.
+import os
+import os.path
+import sys
+import re
+import gettext
+import jinja2
+import glob
+import codecs
+import os
+import os.path
+
+env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
+ extensions=["jinja2.ext.i18n"],
+ lstrip_blocks=True,
+ trim_blocks=True,
+
+ undefined=jinja2.StrictUndefined,
+ autoescape=False)
+
+default_ctx = {}
+default_ctx["merchant_blog_url"] = os.environ.get("TALER_ENV_URL_MERCHANT_BLOG", "#")
+default_ctx["merchant_donations_url"] = os.environ.get("TALER_ENV_URL_MERCHANT_DONATIONS", "#")
+default_ctx["intro_url"] = os.environ.get("TALER_ENV_URL_INTRO", "#")
+default_ctx["bank_url"] = os.environ.get("TALER_ENV_URL_BANK", "#")
+default_ctx["auditor_url"] = os.environ.get("TALER_ENV_URL_AUDITOR", "#")
+default_ctx["currency"] = os.environ.get("TALER_CONFIG_CURRENCY", "??")
+
+
+for in_file in glob.glob("*.j2"):
+ name, ext = re.match(r"(.*)\.([^.]+)$", in_file.rstrip(".j2")).groups()
+ tmpl = env.get_template(in_file)
+
+ def self_localized(other_locale):
+ """
+ Return URL for the current page in another locale.
+ """
+ return "../" + other_locale + "/" + in_file.rstrip(".j2")
+
+ def url_localized(filename):
+ return "../" + locale + "/" + filename
+
+ def url(x):
+ # TODO: look at the app root environment variable
+ # TODO: check if file exists
+ return "../" + x
+
+ for l in ("en", "de", "it", "es"):
+ locale = os.path.basename(l)
+
+ if os.path.isdir(os.path.join("./locale/", locale)):
+ tr = gettext.translation("messages",
+ localedir="locale",
+ languages=[locale])
+
+ env.install_gettext_translations(tr, newstyle=True)
+ else:
+ print("warning: locale {} not found".format(locale))
+
+ ctx = dict(
+ lang=locale,
+ url=url,
+ self_localized=self_localized,
+ url_localized=url_localized,
+ filename=name + "." + ext)
+ ctx.update(default_ctx)
+
+ content = tmpl.render(**ctx)
+ out_name = "./" + locale + "/" + in_file.rstrip(".j2")
+ os.makedirs("./" + locale, exist_ok=True)
+
+ with codecs.open(out_name, "w", "utf-8") as f:
+ f.write(content)