1 # -*- coding: utf-8 -*-
6 from docutils.core import publish_parts
7 from flask import Flask
8 from flask import render_template
9 from flask import request
10 from flask.ext.babel import gettext as _
11 from flask.ext.babel import Babel
12 from config import LANGUAGES
13 from sayings import get_saying
16 LANGUAGE_SELECTED = "de"
17 #ToDo after engelish is implemented set LANGUAGE_SELECTED = None
22 app.config['BABEL_DEFAULT_LOCALE'] = 'de'
25 def get_content(filename, overrides=None):
27 if os.path.isfile(filename):
28 with codecs.open(filename, 'r', 'utf-8') as f:
31 content = publish_parts(rst_data, writer_name='html', settings_overrides=overrides)['html_body']
36 ('/ozoneloss', _(u'Ozoneloss')),
37 ('/eskp', _(u'ESKP')),
38 ('/iek-7', _(u'IEK-7')),
42 app.jinja_env.globals.update(get_topmenue=get_topmenue)
47 """ToDo: if translation is completed, switch to en """
48 return LANGUAGE_SELECTED or request.accept_languages.best_match(LANGUAGES.keys()) or 'de'
54 saying, author = get_saying()
55 return render_template("/index.html",
58 eskp_info=_(u'About ESKP'),
63 global LANGUAGE_SELECTED
64 LANGUAGE_SELECTED = "de"
65 saying, author = get_saying()
66 return render_template("/index.html",
69 eskp_info=_(u'About ESKP'),
74 saying, author = get_saying()
75 global LANGUAGE_SELECTED
76 LANGUAGE_SELECTED = "en"
77 return render_template("/index.html",
80 eskp_info=_(u'About ESKP'),
85 filename = os.path.join("templates", get_locale(), "rst", "eskp.rst")
86 content = get_content(filename)
87 return render_template("/content.html", act="eskp", content=content)
89 @app.route("/ozoneloss")
91 filename = os.path.join("templates", get_locale(), "rst", "ozoneloss.rst")
92 content = get_content(filename)
95 return render_template("/content.html", act="ozoneloss", content=content)
99 filename = os.path.join("templates", get_locale(), "rst", "iek-7.rst")
100 content = get_content(filename)
101 return render_template("/content.html", act="submission", content=content)
104 @app.route("/imprint")
106 filename = os.path.join("templates", get_locale(), "rst", "imprint.rst")
107 content = get_content(filename)
108 return render_template("/content.html", act="imprint", content=content)
112 @app.errorhandler(404)
113 def page_not_found(e):
114 msg = _(u"Url: %(url)s not found", url=request.url)
115 info = _(u"This information is not available!")
116 return render_template("404.html", msg=msg, info=info)
118 if __name__ == "__main__":
119 app.run(host='localhost', port=5014, debug=True)