diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2012-01-15 11:12:11 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2012-01-15 11:12:11 +0100 |
commit | dc36e320ef4d90b0bf802c6b54877971e2249d1a (patch) | |
tree | fa0f23bc0e0920c77587135cf1e4ab92e0e1275d | |
parent | c2b7abf89ec9747cf8a32c2d1480833fc94fca09 (diff) | |
download | kosten-dc36e320ef4d90b0bf802c6b54877971e2249d1a.tar.gz kosten-dc36e320ef4d90b0bf802c6b54877971e2249d1a.tar.bz2 kosten-dc36e320ef4d90b0bf802c6b54877971e2249d1a.zip |
Do not load JS for mobile browsers
Diffstat (limited to '')
-rwxr-xr-x | index.py | 12 | ||||
-rw-r--r-- | templates/root.mako | 10 |
2 files changed, 17 insertions, 5 deletions
@@ -39,13 +39,23 @@ def handle_sql(handler): return h # +# Check for mobile (at least somewhat) +# +mobile_checks = ["J2ME", "Opera Mini"] +def handle_mobile(): + ua = web.ctx.env.get("HTTP_USER_AGENT", "") + + web.ctx.is_mobile = any((x in ua) for x in mobile_checks) + +# # The App # app = web.application(urls, globals()) app.notfound = controller.FourOhFour.catch -# add orm processor +# add processors app.add_processor(handle_sql) +app.add_processor(web.loadhook(handle_mobile)) # debug for the moment web.config.debug = True diff --git a/templates/root.mako b/templates/root.mako index b744bbd..19af96e 100644 --- a/templates/root.mako +++ b/templates/root.mako @@ -2,10 +2,12 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> - <%block name="js"> - <script type="text/javascript" src=${"/static/js/jquery-1.4.2.js" | url}></script> - <script type="text/javascript" src=${"/static/js/lib.js" | url}></script> - </%block> + % if not w.ctx.is_mobile: + <%block name="js"> + <script type="text/javascript" src=${"/static/js/jquery-1.4.2.js" | url}></script> + <script type="text/javascript" src=${"/static/js/lib.js" | url}></script> + </%block> + % endif <link rel="shortcut icon" href=${"/static/images/currency.png" | url} type="image/icon"> <title><%block name="title">Kostenverwaltung</%block></title> <%block name="style"> |