summaryrefslogtreecommitdiffstats
path: root/pyload
diff options
context:
space:
mode:
Diffstat (limited to 'pyload')
-rw-r--r--pyload/web/Gruntfile.js136
-rw-r--r--pyload/web/ServerThread.py11
-rwxr-xr-xpyload/web/app/fonts/Abel-Regular.ttfbin0 -> 36400 bytes
-rw-r--r--pyload/web/app/fonts/Abel-Regular.woffbin0 -> 16284 bytes
-rw-r--r--pyload/web/app/index.html11
-rw-r--r--pyload/web/app/styles/font.css10
-rw-r--r--pyload/web/package.json4
-rw-r--r--pyload/web/pyload_app.py21
-rw-r--r--pyload/web/webinterface.py42
9 files changed, 151 insertions, 84 deletions
diff --git a/pyload/web/Gruntfile.js b/pyload/web/Gruntfile.js
index 4799afb01..803810b14 100644
--- a/pyload/web/Gruntfile.js
+++ b/pyload/web/Gruntfile.js
@@ -5,6 +5,8 @@ var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function(connect, dir) {
return connect.static(require('path').resolve(dir));
};
+var fs = require('fs');
+var path = require('path');
// # Globbing
// for performance reasons we're only matching one level down:
@@ -19,7 +21,8 @@ module.exports = function(grunt) {
// configurable paths
var yeomanConfig = {
app: 'app',
- dist: 'dist'
+ dist: 'dist',
+ banner: '/* Copyright(c) 2008-2013 pyLoad Team */\n'
};
grunt.initConfig({
@@ -38,7 +41,7 @@ module.exports = function(grunt) {
},
files: [
'<%= yeoman.app %>/**/*.html',
- '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
+ '{.tmp,<%= yeoman.app %>}/styles/**/*.css',
'{.tmp,<%= yeoman.app %>}/scripts/**/*.js',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
@@ -81,11 +84,11 @@ module.exports = function(grunt) {
}
}
},
- open: {
- server: {
- path: 'http://localhost:<%= connect.options.port %>'
- }
- },
+// open: { // Opens the webbrowser
+// server: {
+// path: 'http://localhost:<%= connect.options.port %>'
+// }
+// },
clean: {
dist: {
files: [
@@ -156,7 +159,40 @@ module.exports = function(grunt) {
// http://requirejs.org/docs/errors.html#sourcemapcomments
preserveLicenseComments: false,
useStrict: true,
- wrap: true
+ wrap: true,
+
+ // Delete already included files from dist
+ done: function(done, output) {
+ var root = path.join(path.resolve('.'), yeomanConfig.app);
+ var parse = require('rjs-build-analysis').parse(output);
+ parse.bundles.forEach(function(bundle) {
+ var parent = path.relative(path.resolve('.'), bundle.parent);
+ bundle.children.forEach(function(f) {
+ // Skip templates
+ if (f.indexOf('hbs!') > -1) return;
+
+ var rel = path.relative(root, f);
+ var target = path.join(yeomanConfig.dist, rel);
+
+ if (target === parent)
+ return;
+
+ if (fs.existsSync(target)) {
+ console.log('Removing', target);
+ fs.unlinkSync(target);
+
+ // Remove the empty directories
+ var files = fs.readdirSync(path.dirname(target));
+ if (files.length === 0) {
+ fs.rmdirSync(path.dirname(target));
+ console.log('Removing dir', path.dirname(target));
+ }
+
+ }
+ });
+ });
+ done();
+ }
//uglify2: {} // https://github.com/mishoo/UglifyJS2
}
}
@@ -165,10 +201,9 @@ module.exports = function(grunt) {
dist: {
files: {
src: [
- '<%= yeoman.dist %>/scripts/{,*/}*.js',
- '<%= yeoman.dist %>/styles/{,*/}*.css',
- '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
- '<%= yeoman.dist %>/fonts/*'
+ // TODO only main script needs a rev
+ '<%= yeoman.dist %>/scripts/default.js',
+ '<%= yeoman.dist %>/styles/{,*/}*.css'
]
}
}
@@ -183,8 +218,8 @@ module.exports = function(grunt) {
options: {
dirs: ['<%= yeoman.dist %>']
},
- html: ['<%= yeoman.dist %>/{,*/}*.html'],
- css: ['<%= yeoman.dist %>/styles/{,*/}*.css']
+ html: ['<%= yeoman.dist %>/**/*.html'],
+ css: ['<%= yeoman.dist %>/styles/**/*.css']
},
imagemin: {
dist: {
@@ -192,7 +227,7 @@ module.exports = function(grunt) {
{
expand: true,
cwd: '<%= yeoman.app %>/images',
- src: '{,*/}*.{png,jpg,jpeg}',
+ src: '**/*.{png,jpg,jpeg}',
dest: '<%= yeoman.dist %>/images'
}
]
@@ -204,19 +239,36 @@ module.exports = function(grunt) {
{
expand: true,
cwd: '<%= yeoman.app %>/images',
- src: '{,*/}*.svg',
+ src: '**/*.svg',
dest: '<%= yeoman.dist %>/images'
}
]
}
},
cssmin: {
+ options: {
+ banner: yeomanConfig.banner
+ },
dist: {
expand: true,
cwd: '<%= yeoman.app %>/styles',
- src: ['{,*/}*.css', '!*.min.css'],
+ src: ['**/*.css', '!*.min.css'],
dest: '<%= yeoman.dist %>/styles',
- ext: '.min.css'
+ ext: '.css'
+ }
+ },
+ uglify: { // JS min
+ options: {
+ mangle: true,
+ report: 'min',
+ preserveComments: false,
+ banner: yeomanConfig.banner
+ },
+ dist: {
+ expand: true,
+ cwd: '<%= yeoman.dist %>/scripts',
+ dest: '<%= yeoman.dist %>/scripts',
+ src: ['**/*.js']
}
},
htmlmin: {
@@ -236,7 +288,7 @@ module.exports = function(grunt) {
{
expand: true,
cwd: '<%= yeoman.app %>',
- src: '*.html',
+ src: ['*.html'],
dest: '<%= yeoman.dist %>'
}
]
@@ -245,24 +297,26 @@ module.exports = function(grunt) {
// Put files not handled in other tasks here
copy: {
// Copy files from third party libraries
- // TODO: copy also to dist folder
libs: {
files: [
{
expand: true,
flatten: true,
cwd: '<% yeoman.app %>',
- dest: '<% yeoman.app %>/images,',
+ dest: '.tmp/fonts',
src: [
+ '**/font-awesome/font/*'
]
},
{
expand: true,
flatten: true,
cwd: '<% yeoman.app %>',
- dest: '.tmp/fonts',
+ dest: '.tmp/vendor',
src: [
- '**/font-awesome/font/*'
+ '**/select2/select2.{js,png,css}',
+ '**/select2/select2-spinner.gif',
+ '**/select2/select2x2.png'
]
}
]
@@ -277,17 +331,33 @@ module.exports = function(grunt) {
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,txt}',
- '.htaccess',
'images/{,*/}*.{webp,gif}',
+ 'templates/**/*.html',
+ 'scripts/**/*.js',
'fonts/*'
]
},
{
expand: true,
- cwd: '.tmp/images',
- dest: '<%= yeoman.dist %>/images',
+ cwd: '.tmp/',
+ dest: '<%= yeoman.dist %>/',
src: [
- 'generated/*'
+ 'fonts/*',
+ '**/*.{css,gif,png,js,html}'
+ ]
+ }
+ ]
+ },
+
+ tmp: {
+ files: [
+ {
+ expand: true,
+ cwd: '.tmp/',
+ dest: '<%= yeoman.dist %>/',
+ src: [
+ 'fonts/*',
+ '**/*.{css,gif,png,js,html}'
]
}
]
@@ -306,15 +376,9 @@ module.exports = function(grunt) {
'imagemin',
'svgmin',
'htmlmin'
+// 'cssmin',
+// 'uglify'
]
- },
- bower: {
- options: {
- exclude: ['modernizr']
- },
- all: {
- rjsConfig: '<%= yeoman.app %>/scripts/config.js'
- }
}
});
@@ -348,7 +412,7 @@ module.exports = function(grunt) {
'cssmin',
'concat',
'uglify',
- 'copy',
+ 'copy:dist',
'rev',
'usemin'
]);
diff --git a/pyload/web/ServerThread.py b/pyload/web/ServerThread.py
index 95a09bd80..c55ddef0f 100644
--- a/pyload/web/ServerThread.py
+++ b/pyload/web/ServerThread.py
@@ -11,6 +11,7 @@ core = None
setup = None
log = logging.getLogger("log")
+
class WebServer(threading.Thread):
def __init__(self, pycore=None, pysetup=None):
global core, setup
@@ -40,6 +41,7 @@ class WebServer(threading.Thread):
def run(self):
self.running = True
import webinterface
+
global webinterface
if self.https:
@@ -47,6 +49,11 @@ class WebServer(threading.Thread):
log.warning(_("SSL certificates not found."))
self.https = False
+ if webinterface.UNAVAILALBE:
+ log.warning(_("WebUI built is not available"))
+ elif webinterface.APP_PATH == "app":
+ log.info(_("Running webUI in development mode"))
+
prefer = None
# These cases covers all settings
@@ -128,11 +135,11 @@ class WebServer(threading.Thread):
else: # server is just a string
name = server
- log.info(_("Starting %(name)s webserver: %(host)s:%(port)d") % {"name": name, "host": self.host, "port": self.port})
+ log.info(
+ _("Starting %(name)s webserver: %(host)s:%(port)d") % {"name": name, "host": self.host, "port": self.port})
webinterface.run_server(host=self.host, port=self.port, server=server)
-
# check if an error was raised for n seconds
def check_error(self, n=1):
t = time() + n
diff --git a/pyload/web/app/fonts/Abel-Regular.ttf b/pyload/web/app/fonts/Abel-Regular.ttf
new file mode 100755
index 000000000..e37beb972
--- /dev/null
+++ b/pyload/web/app/fonts/Abel-Regular.ttf
Binary files differ
diff --git a/pyload/web/app/fonts/Abel-Regular.woff b/pyload/web/app/fonts/Abel-Regular.woff
new file mode 100644
index 000000000..ab8954389
--- /dev/null
+++ b/pyload/web/app/fonts/Abel-Regular.woff
Binary files differ
diff --git a/pyload/web/app/index.html b/pyload/web/app/index.html
index 87fd6c612..8e231868f 100644
--- a/pyload/web/app/index.html
+++ b/pyload/web/app/index.html
@@ -8,16 +8,11 @@
<meta name="description" content="pyLoad WebUI">
<meta name="viewport" content="width=device-width">
- <!-- TODO Include this font -->
- <link href="http://fonts.googleapis.com/css?family=Abel" rel="stylesheet" type="text/css"/>
-
<!-- TODO: basepath and templates -->
- <link href="/styles/font.css" rel="stylesheet" type="text/css"/>
- <link href="/styles/default/main.css" rel="stylesheet" type="text/css">
+ <link href="styles/font.css" rel="stylesheet" type="text/css"/>
+ <link href="styles/default/main.css" rel="stylesheet" type="text/css">
+ <link href="vendor/select2.css" rel="stylesheet" type="text/css"/>
- <!-- build:css styles/vendor.css -->
- <link href="components/select2/select2.css" rel="stylesheet" type="text/css"/>
- <!-- endbuild -->
<!-- build:js scripts/default.js -->
<script data-main="scripts/config" src="components/requirejs/require.js"></script>
diff --git a/pyload/web/app/styles/font.css b/pyload/web/app/styles/font.css
index ee117d43b..fa2de514b 100644
--- a/pyload/web/app/styles/font.css
+++ b/pyload/web/app/styles/font.css
@@ -34,4 +34,12 @@
url('../fonts/Sansation_Bold-webfont.svg#SansationBold') format('svg');
font-weight: normal;
font-style: normal;
-} \ No newline at end of file
+}
+
+@font-face {
+ font-family: 'Abel';
+ font-style: normal;
+ font-weight: 400;
+ src: local('Abel'), local('Abel-Regular'), url(../fonts/Abel-Regular.woff) format('woff');
+ src: url(../fonts/Abel-Regular.ttf) format('truetype');
+}
diff --git a/pyload/web/package.json b/pyload/web/package.json
index aaf1c9a8d..7bd58f56b 100644
--- a/pyload/web/package.json
+++ b/pyload/web/package.json
@@ -6,14 +6,13 @@
"grunt": "~0.4.1",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "~0.1.3",
- "grunt-contrib-uglify": "~0.2.0",
+ "grunt-contrib-uglify": "~0.2.2",
"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-clean": "~0.4.0",
"grunt-contrib-htmlmin": "~0.1.3",
- "grunt-bower-requirejs": "~0.4.3",
"grunt-contrib-requirejs": "~0.4.0",
"grunt-contrib-imagemin": "~0.1.3",
"grunt-contrib-watch": "~0.4.0",
@@ -24,6 +23,7 @@
"grunt-svgmin": "~0.1.0",
"grunt-concurrent": "~0.1.0",
"matchdep": "~0.1.1",
+ "rjs-build-analysis": "0.0.3",
"connect-livereload": "~0.1.1"
},
"engines": {
diff --git a/pyload/web/pyload_app.py b/pyload/web/pyload_app.py
index 724fddec2..3d3f297a8 100644
--- a/pyload/web/pyload_app.py
+++ b/pyload/web/pyload_app.py
@@ -17,27 +17,14 @@
@author: RaNaN
"""
import time
-from os.path import join, exists
+from os.path import join
from bottle import route, static_file, response, redirect
-from webinterface import PROJECT_DIR, SETUP, DEVELOP
+from webinterface import PROJECT_DIR, SETUP, APP_PATH, UNAVAILALBE
from utils import login_required
-##########
-# Helper
-##########
-
-app_path = "app"
-UNAVAILALBE = False
-
-# webUI build is available
-if exists(join(PROJECT_DIR, "dist", "index.html")) and not DEVELOP:
- app_path = "dist"
-elif not exists(join(PROJECT_DIR, "app", "components")) or not exists(join(PROJECT_DIR, ".tmp")):
- UNAVAILALBE = True
-
@route('/icons/<path:path>')
def serve_icon(path):
@@ -70,9 +57,9 @@ def server_static(path):
response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT",
time.gmtime(time.time() + 60 * 60 * 24 * 7))
response.headers['Cache-control'] = "public"
- resp = static_file(path, root=join(PROJECT_DIR, app_path))
+ resp = static_file(path, root=join(PROJECT_DIR, APP_PATH))
# Also serve from .tmp folder in dev mode
- if resp.status_code == 404 and app_path == "app":
+ if resp.status_code == 404 and APP_PATH == "app":
return static_file(path, root=join(PROJECT_DIR, '.tmp'))
return resp \ No newline at end of file
diff --git a/pyload/web/webinterface.py b/pyload/web/webinterface.py
index cf73827b7..206603f27 100644
--- a/pyload/web/webinterface.py
+++ b/pyload/web/webinterface.py
@@ -1,25 +1,24 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-"""
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>.
-
- @author: RaNaN
-"""
+###############################################################################
+# Copyright(c) 2008-2013 pyLoad Team
+# http://www.pyload.org
+#
+# This file is part of pyLoad.
+# pyLoad is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# Subjected to the terms and conditions in LICENSE
+#
+# @author: RaNaN
+###############################################################################
import sys
-from os.path import join, abspath, dirname
+from os.path import join, abspath, dirname, exists
PROJECT_DIR = abspath(dirname(__file__))
PYLOAD_DIR = abspath(join(PROJECT_DIR, "..", ".."))
@@ -45,19 +44,26 @@ else:
config = ServerThread.core.config
from pyload.utils.JsEngine import JsEngine
-
JS = JsEngine()
TEMPLATE = config.get('webinterface', 'template')
DL_ROOT = config.get('general', 'download_folder')
PREFIX = config.get('webinterface', 'prefix')
-DEVELOP = config.get('webinterface', 'develop')
if PREFIX:
PREFIX = PREFIX.rstrip("/")
if PREFIX and not PREFIX.startswith("/"):
PREFIX = "/" + PREFIX
+APP_PATH = "dist"
+UNAVAILALBE = False
+
+# webUI build is available
+if exists(join(PROJECT_DIR, "app", "components")) and exists(join(PROJECT_DIR, ".tmp")) and config.get('webinterface', 'develop'):
+ APP_PATH = "app"
+elif not exists(join(PROJECT_DIR, "dist", "index.html")):
+ UNAVAILALBE = True
+
DEBUG = config.get("general", "debug_mode") or "-d" in sys.argv or "--debug" in sys.argv
bottle.debug(DEBUG)