diff options
author | godofdream <soilfiction@gmail.com> | 2012-08-16 17:48:39 +0200 |
---|---|---|
committer | godofdream <soilfiction@gmail.com> | 2012-08-16 17:48:39 +0200 |
commit | d8119f648e63a4728433e67e79d2a99296a8c2c1 (patch) | |
tree | b965abb3d9597305828b3c44a82745c0ef549a4e /module/web/pyload_app.py | |
parent | improved QueueLayout (diff) | |
download | pyload-d8119f648e63a4728433e67e79d2a99296a8c2c1.tar.xz |
Added Mobile WebIf, some Layouting
Diffstat (limited to 'module/web/pyload_app.py')
-rw-r--r-- | module/web/pyload_app.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py index 843919b85..eaaabd58e 100644 --- a/module/web/pyload_app.py +++ b/module/web/pyload_app.py @@ -23,7 +23,7 @@ from bottle import route, static_file, request, response, redirect, HTTPError, e from webinterface import PYLOAD, PROJECT_DIR, SETUP, env -from utils import render_to_response, login_required, set_session, get_user_api +from utils import render_to_response, login_required, set_session, get_user_api, is_mobile ########## @@ -99,8 +99,10 @@ def login(): if not PYLOAD and SETUP: redirect("/setup") else: - return render_to_response("login.html", proc=[pre_processor]) - + if is_mobile(): + return render_to_response("app_login.html", proc=[pre_processor]) + else: + return render_to_response("login.html", proc=[pre_processor]) @route('/nopermission') def nopermission(): @@ -111,19 +113,30 @@ def nopermission(): def login_post(): username = request.forms.get("username") password = request.forms.get("password") - user = PYLOAD.checkAuth(username, password) - if not user: - return render_to_response("login.html", {"errors": True}, [pre_processor]) - + if is_mobile(): + response.set_cookie("mobile", str(True)) + if not user: + return render_to_response("app_login.html", {"errors": True}, [pre_processor]) + else: + response.set_cookie("mobile", str(False)) + if not user: + return render_to_response("login.html", {"errors": True}, [pre_processor]) + set_session(request, user) return redirect("/") +@route("/toggle_mobile") +def toggle_mobile(): + response.set_cookie("mobile", str(not is_mobile())) + return redirect("/login") @route("/logout") def logout(): s = request.environ.get('beaker.session') s.delete() + if is_mobile(): + return render_to_response("app_login.html", {"logout": True}, [pre_processor]) return render_to_response("logout.html", proc=[pre_processor]) @route("/queue") |