From 2bbb0f35d1a1a3bab1c52a94c6438f8bb9a68c34 Mon Sep 17 00:00:00 2001 From: dev Date: Thu, 4 Jun 2009 09:37:51 +0000 Subject: [PATCH] added theme support --- www.i2p2/app.py | 15 ++++++++++++++- www.i2p2/pages/_layout.html | 5 ++++- www.i2p2/pages/_layout_de.html | 7 +++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/www.i2p2/app.py b/www.i2p2/app.py index cffb6aa7..f21b18b2 100644 --- a/www.i2p2/app.py +++ b/www.i2p2/app.py @@ -27,6 +27,14 @@ def app(environ, start_response): """The WSGI application that connects all together.""" req = Request(environ) path = req.path[1:].lower() + # do theme handling + theme = 'light' + if 'style' in req.cookies: + theme = req.cookies['style'] + if 'theme' in req.args.keys(): + theme = req.args['theme'] + if not theme in ['light', 'dark']: + theme = 'light' if path == '': path = 'index' mime_type='text/html' @@ -44,7 +52,12 @@ def app(environ, start_response): tmpl = env.get_template(path + '.html') except TemplateNotFound: tmpl = env.get_template('not_found.html') - resp = Response(tmpl.render(static=False), mimetype=mime_type) + resp = Response(tmpl.render(static=False, theme=theme), mimetype=mime_type) + # more theme handling + if theme == 'light' and 'style' in req.cookies: + resp.delete_cookie('style') + elif theme != 'light': + resp.set_cookie('style', theme) resp.add_etag() resp.make_conditional(req) return resp(environ, start_response) diff --git a/www.i2p2/pages/_layout.html b/www.i2p2/pages/_layout.html index 9c8110ee..d1362a00 100644 --- a/www.i2p2/pages/_layout.html +++ b/www.i2p2/pages/_layout.html @@ -5,8 +5,11 @@ {% filter capture('title') %}{% block title %}{% endblock %}{% endfilter %} - I2P + {% if theme == 'light' %} - + {% else %} + + {% endif %} diff --git a/www.i2p2/pages/_layout_de.html b/www.i2p2/pages/_layout_de.html index b0aaa169..643cd0aa 100644 --- a/www.i2p2/pages/_layout_de.html +++ b/www.i2p2/pages/_layout_de.html @@ -6,8 +6,11 @@ {% filter capture('title') %}{% block title %}{% endblock %}{% endfilter %} - I2P - - + {% if theme == 'light' %} + + {% else %} + + {% endif %}