diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-02-18 22:33:06 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-02-18 22:33:06 +0100 |
commit | d79c1b3a6d1a6481b77598edf71fcb53eb6bb655 (patch) | |
tree | 04746ec4511a4d3e134a3781cb7e68dc3974411c /module/web | |
parent | youtube fix, xdccrequest abort dl implemented (diff) | |
download | pyload-d79c1b3a6d1a6481b77598edf71fcb53eb6bb655.tar.xz |
Diffstat (limited to 'module/web')
-rw-r--r-- | module/web/ServerThread.py | 8 | ||||
-rw-r--r-- | module/web/pyload_app.py | 21 | ||||
-rw-r--r-- | module/web/templates/jinja/default/base.html | 4 | ||||
-rw-r--r-- | module/web/templates/jinja/default/setup.html | 13 | ||||
-rw-r--r-- | module/web/webinterface.py | 26 |
5 files changed, 54 insertions, 18 deletions
diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 9af888c6e..b343b6526 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -1,11 +1,11 @@ #!/usr/bin/env python from __future__ import with_statement -from os import makedirs -from os.path import exists, join +from os.path import exists import threading import logging core = None +setup = None log = logging.getLogger("log") class WebServer(threading.Thread): @@ -28,10 +28,6 @@ class WebServer(threading.Thread): import webinterface global webinterface - cache = join("tmp", "jinja_cache") - if not exists(cache): - makedirs(cache) - if self.https: if not exists(self.cert) or not exists(self.key): log.warning(_("SSL certificates not found.")) diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py index 4d6d4354c..82701e755 100644 --- a/module/web/pyload_app.py +++ b/module/web/pyload_app.py @@ -33,7 +33,7 @@ from urllib import unquote from bottle import route, static_file, request, response, redirect, HTTPError, error -from webinterface import PYLOAD, PROJECT_DIR +from webinterface import PYLOAD, PROJECT_DIR, SETUP from utils import render_to_response, parse_permissions, parse_userdata, login_required from filters import relpath, unquotepath @@ -70,7 +70,7 @@ def base(messages): @error(500) def error500(error): return base(["An Error occured, please enable debug mode to get more details.", error, - error.traceback.replace("\n", "<br>")]) + error.traceback.replace("\n", "<br>") if error.traceback else "No Traceback"]) @route('/media/:path#.+#') @@ -86,7 +86,10 @@ def favicon(): @route('/login', method="GET") def login(): - return render_to_response("login.html", proc=[pre_processor]) + if not PYLOAD and SETUP: + redirect("/setup") + else: + return render_to_response("login.html", proc=[pre_processor]) @route("/login", method="POST") def login_post(): @@ -285,7 +288,7 @@ def config(): elif not data["trafficleft"]: data["trafficleft"] = _("not available") else: - data["trafficleft"] = formatSize(data["trafficleft"]) + data["trafficleft"] = formatSize(data["trafficleft"] * 1024) if data["validuntil"] == -1: data["validuntil"] = _("unlimited") @@ -493,4 +496,12 @@ def logs(item=-1): @route("/admin") def admin(): - return base([])
\ No newline at end of file + return base(["Comming Soon."]) + + +@route("/setup") +def setup(): + if PYLOAD or not SETUP: + return base([_("Run pyLoadCore.py -s to access the setup.")]) + + return render_to_response('setup.html', {"user" : False, "perms": False}) diff --git a/module/web/templates/jinja/default/base.html b/module/web/templates/jinja/default/base.html index 04c6dfbad..f5e2b9634 100644 --- a/module/web/templates/jinja/default/base.html +++ b/module/web/templates/jinja/default/base.html @@ -201,7 +201,9 @@ function AddBox() <div id="head-panel">
+
<div id="head-search-and-login">
+ {% block headpanel %}
{% if user.is_authenticated %}
@@ -222,6 +224,7 @@ function AddBox() <span style="padding-right: 2px;">{{_("Please Login!")}}</span>
{% endif %}
+ {% endblock %}
</div>
<a href="/"><img id="head-logo" src="/media/default/img/pyload-logo-edited3.5-new-font-small.png" alt="pyLoad" /></a>
@@ -293,6 +296,7 @@ function AddBox() <div class="level1" style="clear:both">
</div>
+<noscript><h1>Enable JavaScript to use the webinterface.</h1></noscript>
{% for message in messages %}
<b><p>{{message}}</p></b>
diff --git a/module/web/templates/jinja/default/setup.html b/module/web/templates/jinja/default/setup.html new file mode 100644 index 000000000..39ef6f1e8 --- /dev/null +++ b/module/web/templates/jinja/default/setup.html @@ -0,0 +1,13 @@ +{% extends 'default/base.html' %} + +{% block title %}{{ _("Setup") }} - {{ super() }} {% endblock %} +{% block subtitle %}{{ _("Setup") }}{% endblock %} +{% block headpanel %}Welcome to pyLoad{% endblock %} +{% block menu %} + <li style="height: 25px"> <!-- Needed to get enough margin --> + </li> +{% endblock %} + +{% block content %} + Comming Soon. +{% endblock %}
\ No newline at end of file diff --git a/module/web/webinterface.py b/module/web/webinterface.py index ef5046f44..0d94fb4dc 100644 --- a/module/web/webinterface.py +++ b/module/web/webinterface.py @@ -36,13 +36,21 @@ from bottle import run, app from jinja2 import Environment, FileSystemLoader, PrefixLoader, FileSystemBytecodeCache from middlewares import StripPathMiddleware, GZipMiddleWare -try: - import module.web.ServerThread +SETUP = None +PYLOAD = None - if not module.web.ServerThread.core: - raise Exception - PYLOAD = module.web.ServerThread.core.server_methods - config = module.web.ServerThread.core.config +try: + from module.web import ServerThread + + if not ServerThread.core: + if ServerThread.setup: + SETUP = ServerThread.setup + config = SETUP.config + else: + raise Exception + else: + PYLOAD = ServerThread.core.server_methods + config = ServerThread.core.config except: import xmlrpclib @@ -85,7 +93,11 @@ LOG_ROOT = config.get('log', 'log_folder') DEBUG = config.get("general","debug_mode") bottle.debug(DEBUG) -bcc = FileSystemBytecodeCache(join("tmp","jinja_cache")) +cache = join("tmp", "jinja_cache") +if not exists(cache): + makedirs(cache) + +bcc = FileSystemBytecodeCache(cache) loader = PrefixLoader({ "default": FileSystemLoader(join(PROJECT_DIR, "templates", "jinja", "default")) }) |