summaryrefslogtreecommitdiffstats
path: root/pyload/web
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/web')
-rw-r--r--pyload/web/Gruntfile.js8
-rw-r--r--pyload/web/ServerThread.py10
-rw-r--r--pyload/web/app/index.html8
-rw-r--r--pyload/web/app/scripts/app.js7
-rw-r--r--pyload/web/app/scripts/views/headerView.js36
-rw-r--r--pyload/web/package.json4
-rw-r--r--pyload/web/pyload_app.py9
-rw-r--r--pyload/web/servers.py2
-rw-r--r--pyload/web/webinterface.py6
9 files changed, 51 insertions, 39 deletions
diff --git a/pyload/web/Gruntfile.js b/pyload/web/Gruntfile.js
index 0a97e7360..4711ca66d 100644
--- a/pyload/web/Gruntfile.js
+++ b/pyload/web/Gruntfile.js
@@ -21,7 +21,8 @@ module.exports = function(grunt) {
var yeomanConfig = {
app: 'app',
dist: 'dist',
- banner: '/* Copyright(c) 2008-2013 pyLoad Team */\n'
+ banner: '/* Copyright(c) 2008-2013 pyLoad Team */\n',
+ protocol: 'http'
};
grunt.initConfig({
@@ -50,7 +51,8 @@ module.exports = function(grunt) {
options: {
port: 9000,
// change this to '0.0.0.0' to access the server from outside
- hostname: 'localhost'
+ hostname: 'localhost',
+ protocol: '<%= yeoman.protocol %>'
},
livereload: {
options: {
@@ -85,7 +87,7 @@ module.exports = function(grunt) {
},
open: { // Opens the webbrowser
server: {
- path: 'http://localhost:<%= connect.options.port %>'
+ path: '<%= yeoman.protocol %>://localhost:<%= connect.options.port %>'
}
},
clean: {
diff --git a/pyload/web/ServerThread.py b/pyload/web/ServerThread.py
index 809c6c800..a2e375f1f 100644
--- a/pyload/web/ServerThread.py
+++ b/pyload/web/ServerThread.py
@@ -26,14 +26,14 @@ class WebServer(threading.Thread):
else:
raise Exception("No config context provided")
- self.server = config['webinterface']['server']
- self.https = config['webinterface']['https']
+ self.server = config['webUI']['server']
+ self.https = config['webUI']['https']
self.cert = config["ssl"]["cert"]
self.key = config["ssl"]["key"]
- self.host = config['webinterface']['host']
- self.port = config['webinterface']['port']
+ self.host = config['webUI']['host']
+ self.port = config['webUI']['port']
self.debug = config['general']['debug_mode']
- self.force_server = config['webinterface']['force_server']
+ self.force_server = config['webUI']['force_server']
self.error = None
self.setDaemon(True)
diff --git a/pyload/web/app/index.html b/pyload/web/app/index.html
index 98e1bf233..08366f665 100644
--- a/pyload/web/app/index.html
+++ b/pyload/web/app/index.html
@@ -22,7 +22,7 @@
// Use value set by templateEngine or default val
function configValue(string, defaultValue) {
- if (string.indexOf('{{') > -1)
+ if (string.indexOf('{{') > -1 && string !== 'None' && string !== '')
return defaultValue;
return string;
}
@@ -38,10 +38,10 @@
window.hostProtocol = window.location.protocol + '//';
window.hostAddress = window.location.hostname;
window.hostPort = configValue('{{web}}', '8001');
- // TODO
- window.pathPrefix = '/';
+ window.external = configValue('{{external}}', 'true').toLowerCase();
+ window.pathPrefix = configValue('{{prefix}}', '');
window.wsAddress = configValue('{{ws}}', 'ws://%s:7227');
- window.setup = configValue('{{setup}}', 'false');
+ window.setup = configValue('{{setup}}', 'false').toLowerCase();
require(['config'], function(Config) {
require(['default'], function(App) {
diff --git a/pyload/web/app/scripts/app.js b/pyload/web/app/scripts/app.js
index af5c50b14..68a20666d 100644
--- a/pyload/web/app/scripts/app.js
+++ b/pyload/web/app/scripts/app.js
@@ -41,8 +41,11 @@ define([
};
App.apiUrl = function(path) {
- var url = window.hostProtocol + window.hostAddress + ':' + window.hostPort + window.pathPrefix + path;
- return url;
+ var prefix = window.pathPrefix;
+ if (window.external !== 'false')
+ prefix = window.hostProtocol + window.hostAddress + ':' + window.hostPort + prefix;
+
+ return prefix + '/' + path;
};
// Add Global Helper functions
diff --git a/pyload/web/app/scripts/views/headerView.js b/pyload/web/app/scripts/views/headerView.js
index 49298d450..7d892bf01 100644
--- a/pyload/web/app/scripts/views/headerView.js
+++ b/pyload/web/app/scripts/views/headerView.js
@@ -62,21 +62,27 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle
});
// TODO: button to start stop refresh
- var ws = App.openWebSocket('/async');
- ws.onopen = function() {
- ws.send(JSON.stringify('start'));
- };
- // TODO compare with polling
- ws.onmessage = _.bind(this.onData, this);
- ws.onerror = function(error) {
- console.log(error);
- alert('WebSocket error' + error);
- };
- ws.onclose = function() {
- alert('WebSocket was closed');
- };
-
- this.ws = ws;
+ // TODO: catch ws errors / switch into ws less mode
+ try {
+ var ws = App.openWebSocket('/async');
+ ws.onopen = function() {
+ ws.send(JSON.stringify('start'));
+ };
+ // TODO compare with polling
+ ws.onmessage = _.bind(this.onData, this);
+ ws.onerror = function(error) {
+ console.log(error);
+ alert('WebSocket error ' + error);
+ };
+ ws.onclose = function() {
+ alert('WebSocket was closed');
+ };
+
+ this.ws = ws;
+
+ } catch (e) {
+ alert('Could not open WebSocket: ' + e);
+ }
},
gotoDashboard: function() {
diff --git a/pyload/web/package.json b/pyload/web/package.json
index 5de79a814..4ea7ce484 100644
--- a/pyload/web/package.json
+++ b/pyload/web/package.json
@@ -14,7 +14,7 @@
"grunt-contrib-jshint": "~0.4.1",
"grunt-contrib-less": "~0.5.2",
"grunt-contrib-cssmin": "~0.6.0",
- "grunt-contrib-connect": "~0.2.0",
+ "grunt-contrib-connect": "~0.5.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-requirejs": "~0.4.1",
@@ -29,7 +29,7 @@
"grunt-concurrent": "~0.1.0",
"matchdep": "~0.1.1",
"rjs-build-analysis": "0.0.3",
- "connect-livereload": "~0.2.0"
+ "connect-livereload": "~0.3.0"
},
"engines": {
"node": ">=0.8.0"
diff --git a/pyload/web/pyload_app.py b/pyload/web/pyload_app.py
index 50d9b9731..1a54c4a93 100644
--- a/pyload/web/pyload_app.py
+++ b/pyload/web/pyload_app.py
@@ -21,7 +21,7 @@ from os.path import join, exists
from bottle import route, static_file, response, request, redirect, template
-from webinterface import PYLOAD, PROJECT_DIR, SETUP, APP_PATH, UNAVAILALBE
+from webinterface import PYLOAD, PROJECT_DIR, SETUP, APP_PATH, UNAVAILALBE, PREFIX
from utils import login_required, add_json_header, select_language
@@ -71,16 +71,17 @@ def index():
# set variable depending on setup mode
setup = 'false' if SETUP is None else 'true'
ws = PYLOAD.getWSAddress() if PYLOAD else False
+ external = PYLOAD.getConfigValue('webUI', 'external') if PYLOAD else None
web = None
if PYLOAD:
- web = PYLOAD.getConfigValue('webinterface', 'port')
+ web = PYLOAD.getConfigValue('webUI', 'port')
elif SETUP:
- web = SETUP.config['webinterface']['port']
+ web = SETUP.config['webUI']['port']
# Render variables into the html page
if resp.status_code == 200:
content = resp.body.read()
- resp.body = template(content, ws=ws, web=web, setup=setup)
+ resp.body = template(content, ws=ws, web=web, setup=setup, external=external, prefix=PREFIX)
resp.content_length = len(resp.body)
return resp
diff --git a/pyload/web/servers.py b/pyload/web/servers.py
index a3c51e36b..2755cbaff 100644
--- a/pyload/web/servers.py
+++ b/pyload/web/servers.py
@@ -157,6 +157,6 @@ class FlupFCGIServer(ServerAdapter):
flup.server.fcgi.WSGIServer(handler, **self.options).run()
# Order is important and gives every server precedence over others!
-all_server = [BjoernServer, TornadoServer, EventletServer, CherryPyWSGI]
+all_server = [TornadoServer, EventletServer, CherryPyWSGI]
# Some are deactivated because they have some flaws
##all_server = [FapwsServer, MeinheldServer, BjoernServer, TornadoServer, EventletServer, CherryPyWSGI] \ No newline at end of file
diff --git a/pyload/web/webinterface.py b/pyload/web/webinterface.py
index 21c5f4a03..f732a933d 100644
--- a/pyload/web/webinterface.py
+++ b/pyload/web/webinterface.py
@@ -46,9 +46,9 @@ else:
from pyload.utils.JsEngine import JsEngine
JS = JsEngine()
-TEMPLATE = config.get('webinterface', 'template')
+TEMPLATE = config.get('webUI', 'template')
DL_ROOT = config.get('general', 'download_folder')
-PREFIX = config.get('webinterface', 'prefix')
+PREFIX = config.get('webUI', 'prefix')
if PREFIX:
PREFIX = PREFIX.rstrip("/")
@@ -59,7 +59,7 @@ APP_PATH = "app"
UNAVAILALBE = True
# webUI build is available
-if exists(join(PROJECT_DIR, "app", "components")) and exists(join(PROJECT_DIR, ".tmp")) and config.get('webinterface', 'develop'):
+if exists(join(PROJECT_DIR, "app", "components")) and exists(join(PROJECT_DIR, ".tmp")) and config.get('webUI', 'develop'):
UNAVAILALBE = False
elif exists(join(PROJECT_DIR, "dist", "index.html")):
APP_PATH = "dist"