8 from flask import render_template |
8 from flask import render_template |
9 from flask import request |
9 from flask import request |
10 from flask.ext.babel import gettext as _ |
10 from flask.ext.babel import gettext as _ |
11 from flask.ext.babel import Babel |
11 from flask.ext.babel import Babel |
12 from config import LANGUAGES |
12 from config import LANGUAGES |
13 from sayings import get_saying |
|
14 |
|
15 |
13 |
16 LANGUAGE_SELECTED = "de" |
14 LANGUAGE_SELECTED = "de" |
17 #ToDo after engelish is implemented set LANGUAGE_SELECTED = None |
15 #ToDo after engelish is implemented set LANGUAGE_SELECTED = None |
18 |
16 |
19 app = Flask(__name__) |
17 app = Flask(__name__) |
39 ] |
37 ] |
40 return menue |
38 return menue |
41 |
39 |
42 app.jinja_env.globals.update(get_topmenue=get_topmenue) |
40 app.jinja_env.globals.update(get_topmenue=get_topmenue) |
43 |
41 |
|
42 def get_ozone_dates(): |
|
43 menue = [('/ozoneloss/2014', _(u'2014')), |
|
44 ('/ozoneloss/2013', _(u'2013')), |
|
45 ('/ozoneloss/2012', _(u'2012')), |
|
46 ('/ozoneloss/2011', _(u'2011')), |
|
47 ('/ozoneloss/2010', _(u'2010')), |
|
48 ] |
|
49 return menue |
|
50 |
|
51 app.jinja_env.globals.update(get_ozone_dates=get_ozone_dates) |
44 |
52 |
45 @babel.localeselector |
53 @babel.localeselector |
46 def get_locale(): |
54 def get_locale(): |
47 """ToDo: if translation is completed, switch to en """ |
55 """ToDo: if translation is completed, switch to en """ |
48 return LANGUAGE_SELECTED or request.accept_languages.best_match(LANGUAGES.keys()) or 'de' |
56 return LANGUAGE_SELECTED or request.accept_languages.best_match(LANGUAGES.keys()) or 'de' |
49 |
57 |
50 |
58 |
51 @app.route("/") |
59 @app.route("/") |
52 @app.route("/index") |
60 @app.route("/index") |
53 def index(): |
61 def index(): |
54 saying, author = get_saying() |
|
55 return render_template("/index.html", |
62 return render_template("/index.html", |
56 saying=saying, |
|
57 author=author, |
|
58 eskp_info=_(u'About ESKP'), |
63 eskp_info=_(u'About ESKP'), |
59 ) |
64 ) |
|
65 |
|
66 |
|
67 @app.route('/ozoneloss/2014') |
|
68 def y2014(): |
|
69 filename = os.path.join("templates", get_locale(), "rst", "ozoneloss.rst") |
|
70 content = get_content(filename) |
|
71 return render_template("/ozoneloss.html", act="ozoneloss", content=content, year=2014) |
|
72 |
|
73 @app.route('/ozoneloss/2013') |
|
74 def y2013(): |
|
75 filename = os.path.join("templates", get_locale(), "rst", "ozoneloss.rst") |
|
76 content = get_content(filename) |
|
77 return render_template("/ozoneloss.html", act="ozoneloss", content=content, year=2013) |
|
78 |
|
79 @app.route('/ozoneloss/2012') |
|
80 def y2012(): |
|
81 filename = os.path.join("templates", get_locale(), "rst", "ozoneloss.rst") |
|
82 content = get_content(filename) |
|
83 return render_template("/ozoneloss.html", act="ozoneloss", content=content, year=2012) |
|
84 |
|
85 @app.route('/ozoneloss/2011') |
|
86 def y2011(): |
|
87 filename = os.path.join("templates", get_locale(), "rst", "ozoneloss.rst") |
|
88 content = get_content(filename) |
|
89 return render_template("/ozoneloss.html", act="ozoneloss", content=content, year=2011) |
|
90 |
|
91 @app.route('/ozoneloss/2010') |
|
92 def y2010(): |
|
93 filename = os.path.join("templates", get_locale(), "rst", "ozoneloss.rst") |
|
94 content = get_content(filename) |
|
95 return render_template("/ozoneloss.html", act="ozoneloss", content=content, year=2010) |
60 |
96 |
61 @app.route('/de') |
97 @app.route('/de') |
62 def de(): |
98 def de(): |
63 global LANGUAGE_SELECTED |
99 global LANGUAGE_SELECTED |
64 LANGUAGE_SELECTED = "de" |
100 LANGUAGE_SELECTED = "de" |
90 def task(): |
126 def task(): |
91 filename = os.path.join("templates", get_locale(), "rst", "ozoneloss.rst") |
127 filename = os.path.join("templates", get_locale(), "rst", "ozoneloss.rst") |
92 content = get_content(filename) |
128 content = get_content(filename) |
93 print content |
129 print content |
94 print filename |
130 print filename |
95 return render_template("/content.html", act="ozoneloss", content=content) |
131 return render_template("/ozoneloss.html", act="ozoneloss", content=content, year=2014) |
96 |
132 |
97 @app.route("/iek-7") |
133 @app.route("/iek-7") |
98 def submission(): |
134 def submission(): |
99 filename = os.path.join("templates", get_locale(), "rst", "iek-7.rst") |
135 filename = os.path.join("templates", get_locale(), "rst", "iek-7.rst") |
100 content = get_content(filename) |
136 content = get_content(filename) |