summaryrefslogtreecommitdiffstats
path: root/pyload/web
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-07-10 23:07:52 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-07-10 23:07:52 +0200
commitfc4e71d7809e6e9975d678ee388fc28c74e0e3af (patch)
treece9624f00ed5a8ab22781476ea1b8196bee53527 /pyload/web
parentnew hoster links, fixed manifest (diff)
downloadpyload-fc4e71d7809e6e9975d678ee388fc28c74e0e3af.tar.xz
several ui fixes
Diffstat (limited to 'pyload/web')
-rw-r--r--pyload/web/app/index.html17
-rw-r--r--pyload/web/app/scripts/utils/dialogs.js5
-rw-r--r--pyload/web/app/scripts/views/abstract/modalView.js3
-rw-r--r--pyload/web/app/scripts/views/dashboard/dashboardView.js4
-rw-r--r--pyload/web/app/scripts/views/dashboard/filterView.js13
-rw-r--r--pyload/web/app/scripts/views/dashboard/selectionView.js2
-rw-r--r--pyload/web/app/scripts/views/notificationView.js10
-rw-r--r--pyload/web/app/scripts/views/queryModal.js6
-rw-r--r--pyload/web/app/templates/default/notification.html15
-rw-r--r--pyload/web/pyload_app.py12
-rw-r--r--pyload/web/utils.py19
11 files changed, 63 insertions, 43 deletions
diff --git a/pyload/web/app/index.html b/pyload/web/app/index.html
index 28584587c..e8e28f4e1 100644
--- a/pyload/web/app/index.html
+++ b/pyload/web/app/index.html
@@ -19,6 +19,15 @@
<!-- endbuild -->
<script type="text/javascript">
+
+ // Use value set by templateEngine or default val
+ function configValue(string, defaultValue) {
+ if (string.indexOf('{{') > -1)
+ return defaultValue;
+
+ return string;
+ }
+
window.dates = {
weeks: ['week', 'weeks'],
days: ['day', 'days'],
@@ -27,13 +36,11 @@
seconds: ['second', 'seconds']
}; // TODO carefully when translating
- // TODO: use configured values
window.hostProtocol = window.location.protocol + '//';
window.hostAddress = window.location.hostname;
- window.hostPort = '8001';
- window.pathPrefix = "/";
-
- window.wsAddress = "ws://%s:7227"; // TODO
+ window.hostPort = configValue('{{web}}', '8001');
+ window.pathPrefix = '/';
+ window.wsAddress = configValue('{{ws}}', 'ws://%s:7227');
require(['config'], function(Config) {
require(['default'], function(App) {
diff --git a/pyload/web/app/scripts/utils/dialogs.js b/pyload/web/app/scripts/utils/dialogs.js
index 4933b7ed2..3ceffc9c3 100644
--- a/pyload/web/app/scripts/utils/dialogs.js
+++ b/pyload/web/app/scripts/utils/dialogs.js
@@ -5,10 +5,9 @@ define(['jquery', 'underscore', 'views/abstract/modalView'], function($, _, Moda
// Shows the confirm dialog for given context
// on success executes func with context
_.confirm = function(template, func, context) {
- template = 'text!tpl/' + template;
+ template = 'hbs!tpl/' + template;
_.requireOnce([template], function(html) {
- var template = _.compile(html);
- var dialog = new Modal(template, _.bind(func, context));
+ var dialog = new Modal(html, _.bind(func, context));
dialog.show();
});
diff --git a/pyload/web/app/scripts/views/abstract/modalView.js b/pyload/web/app/scripts/views/abstract/modalView.js
index 9d1d72869..65bc0a3c8 100644
--- a/pyload/web/app/scripts/views/abstract/modalView.js
+++ b/pyload/web/app/scripts/views/abstract/modalView.js
@@ -25,11 +25,10 @@ define(['jquery', 'backbone', 'underscore', 'omniwindow'], function($, Backbone,
this.onHideDestroy = true;
}
else
- require(['text!tpl/default/modal.html'], function(template) {
+ require(['hbs!tpl/dialogs/modal'], function(template) {
self.template = template;
});
}
-
},
// TODO: whole modal stuff is not very elegant
diff --git a/pyload/web/app/scripts/views/dashboard/dashboardView.js b/pyload/web/app/scripts/views/dashboard/dashboardView.js
index f305ac2f4..a7779230b 100644
--- a/pyload/web/app/scripts/views/dashboard/dashboardView.js
+++ b/pyload/web/app/scripts/views/dashboard/dashboardView.js
@@ -5,9 +5,6 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection',
// Renders whole dashboard
return Backbone.Marionette.ItemView.extend({
- // TODO: refactor
- active: $('.breadcrumb .active'),
-
template: template,
events: {
@@ -106,7 +103,6 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection',
pack.fetch({silent: true, success: function() {
console.log('Package ' + pack.get('pid') + ' loaded');
- self.active.text(pack.get('name'));
self.contentReady(pack.get('files'));
}, failure: function() {
self.failure();
diff --git a/pyload/web/app/scripts/views/dashboard/filterView.js b/pyload/web/app/scripts/views/dashboard/filterView.js
index ceb2a9a6e..79257547c 100644
--- a/pyload/web/app/scripts/views/dashboard/filterView.js
+++ b/pyload/web/app/scripts/views/dashboard/filterView.js
@@ -26,7 +26,8 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'models/Pac
ui: {
'search': '.search-query',
'stateMenu': '.dropdown-toggle .state',
- 'select': '.btn-check'
+ 'select': '.btn-check',
+ 'name': '.breadcrumb .active'
},
template: template,
@@ -36,11 +37,12 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'models/Pac
this.state = Api.DownloadState.All;
// Apply the filter before the content is shown
- App.vent.on('dashboard:contentReady', _.bind(this.apply_filter, this));
+ this.listenTo(App.vent, 'dashboard:contentReady', this.apply_filter);
+ this.listenTo(App.vent, 'dashboard:updated', this.updateName);
},
onRender: function() {
- // use our modified method
+ // use our modified method
$.fn.typeahead.Constructor.prototype.show = show;
this.ui.search.typeahead({
minLength: 2,
@@ -127,6 +129,11 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'models/Pac
return true;
},
+ updateName: function() {
+ // TODO
+// this.ui.name.text(App.dashboard.package.get('name'));
+ },
+
toggle_selection: function() {
App.vent.trigger('selection:toggle');
},
diff --git a/pyload/web/app/scripts/views/dashboard/selectionView.js b/pyload/web/app/scripts/views/dashboard/selectionView.js
index f25bf3cca..25b7998df 100644
--- a/pyload/web/app/scripts/views/dashboard/selectionView.js
+++ b/pyload/web/app/scripts/views/dashboard/selectionView.js
@@ -100,7 +100,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'hbs!tpl/dashboard/select'],
},
trash: function() {
- _.confirm('default/confirmDialog.html', function() {
+ _.confirm('dialogs/confirmDelete', function() {
var pids = [];
// TODO: delete many at once
diff --git a/pyload/web/app/scripts/views/notificationView.js b/pyload/web/app/scripts/views/notificationView.js
index abfcd8079..93d07a0f3 100644
--- a/pyload/web/app/scripts/views/notificationView.js
+++ b/pyload/web/app/scripts/views/notificationView.js
@@ -1,9 +1,9 @@
define(['jquery', 'backbone', 'underscore', 'app', 'collections/InteractionList', 'hbs!tpl/notification'],
- function($, Backbone, _, App, InteractionList, queryModal, template) {
+ function($, Backbone, _, App, InteractionList, template) {
'use strict';
// Renders context actions for selection packages and files
- return Backbone.View.extend({
+ return Backbone.Marionette.ItemView.extend({
// Only view for this area so it's hardcoded
el: '#notification-area',
@@ -23,8 +23,6 @@ define(['jquery', 'backbone', 'underscore', 'app', 'collections/InteractionList'
initialize: function() {
this.tasks = new InteractionList();
- this.$el.calculateHeight().height(0);
-
App.vent.on('interaction:added', _.bind(this.onAdd, this));
App.vent.on('interaction:deleted', _.bind(this.onDelete, this));
@@ -42,6 +40,10 @@ define(['jquery', 'backbone', 'underscore', 'app', 'collections/InteractionList'
this.tasks.remove(task);
},
+ onRender: function() {
+ this.$el.calculateHeight().height(0);
+ },
+
render: function() {
// only render when it will be visible
diff --git a/pyload/web/app/scripts/views/queryModal.js b/pyload/web/app/scripts/views/queryModal.js
index 7c6439b49..c748e1657 100644
--- a/pyload/web/app/scripts/views/queryModal.js
+++ b/pyload/web/app/scripts/views/queryModal.js
@@ -1,14 +1,13 @@
-define(['jquery', 'underscore', 'app', 'views/abstract/modalView', './input/inputLoader', 'text!tpl/default/queryDialog.html'],
+define(['jquery', 'underscore', 'app', 'views/abstract/modalView', './input/inputLoader', 'hbs!tpl/dialogs/interactionTask'],
function($, _, App, modalView, load_input, template) {
'use strict';
return modalView.extend({
- // TODO: submit on enter reloads the page sometimes
events: {
'click .btn-success': 'submit',
'submit form': 'submit'
},
- template: _.compile(template),
+ template: template,
// the notificationView
parent: null,
@@ -56,6 +55,7 @@ define(['jquery', 'underscore', 'app', 'views/abstract/modalView', './input/inpu
}});
this.input.clear();
+ return false;
},
onShow: function() {
diff --git a/pyload/web/app/templates/default/notification.html b/pyload/web/app/templates/default/notification.html
index 150b2800a..1b6d21e27 100644
--- a/pyload/web/app/templates/default/notification.html
+++ b/pyload/web/app/templates/default/notification.html
@@ -1,11 +1,10 @@
{{#if queries }}
-<span class="btn-query">
-Queries <span class="badge badge-info">{{ queries }}></span>
-</span>
+ <span class="btn-query">
+ Queries <span class="badge badge-info">{{ queries }}</span>
+ </span>
{{/if}}
{{#if notifications }}
-<span class="btn-notification">
-Notifications <span class="badge badge-success">{{ notifications }}</span>
-</span>
-{{/if}}
-</%if}} \ No newline at end of file
+ <span class="btn-notification">
+ Notifications <span class="badge badge-success">{{ notifications }}</span>
+ </span>
+{{/if}} \ No newline at end of file
diff --git a/pyload/web/pyload_app.py b/pyload/web/pyload_app.py
index 3d3f297a8..2f6211621 100644
--- a/pyload/web/pyload_app.py
+++ b/pyload/web/pyload_app.py
@@ -19,9 +19,9 @@
import time
from os.path import join
-from bottle import route, static_file, response, redirect
+from bottle import route, static_file, response, redirect, template
-from webinterface import PROJECT_DIR, SETUP, APP_PATH, UNAVAILALBE
+from webinterface import PYLOAD, PROJECT_DIR, SETUP, APP_PATH, UNAVAILALBE
from utils import login_required
@@ -32,6 +32,7 @@ def serve_icon(path):
return redirect('/images/icon.png')
# return static_file(path, root=join("tmp", "icons"))
+
@route("/download/:fid")
@login_required('Download')
def download(fid, api):
@@ -48,8 +49,11 @@ def index():
# TODO show different page
pass
- # TODO: render it as simple template with configuration
- return server_static('index.html')
+ f = server_static('index.html')
+ content = f.body.read()
+ f.body = template(content, ws=PYLOAD.getWSAddress(), web=PYLOAD.getConfigValue('webinterface', 'port'))
+
+ return f
# Very last route that is registered, could match all uris
@route('/<path:path>')
diff --git a/pyload/web/utils.py b/pyload/web/utils.py
index b5a933b26..dae987f84 100644
--- a/pyload/web/utils.py
+++ b/pyload/web/utils.py
@@ -13,6 +13,7 @@ def set_session(request, user):
s.save()
return s
+
def get_user_api(s):
if s:
uid = s.get("uid", None)
@@ -20,6 +21,7 @@ def get_user_api(s):
return PYLOAD.withUserContext(uid)
return None
+
def is_mobile():
if request.get_cookie("mobile"):
if request.get_cookie("mobile") == "True":
@@ -36,12 +38,17 @@ def is_mobile():
if re.search('(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)', mobile_ua) is not None:
return True
mobile_ua = mobile_ua[:4]
- mobile_agents = ['w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac','blaz','brew','cell','cldc','cmd-',
- 'dang','doco','eric','hipt','inno','ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
- 'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-','newt','noki','palm','pana','pant',
- 'phil','play','port','prox','qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar','sie-',
- 'siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-','tosh','tsm-','upg1','upsi','vk-v','voda',
- 'wap-','wapa','wapi','wapp','wapr','webc','winw','winw','xda ','xda-']
+ mobile_agents = ['w3c ', 'acs-', 'alav', 'alca', 'amoi', 'audi', 'avan', 'benq', 'bird', 'blac', 'blaz', 'brew',
+ 'cell', 'cldc', 'cmd-',
+ 'dang', 'doco', 'eric', 'hipt', 'inno', 'ipaq', 'java', 'jigs', 'kddi', 'keji', 'leno', 'lg-c',
+ 'lg-d', 'lg-g', 'lge-',
+ 'maui', 'maxo', 'midp', 'mits', 'mmef', 'mobi', 'mot-', 'moto', 'mwbp', 'nec-', 'newt', 'noki',
+ 'palm', 'pana', 'pant',
+ 'phil', 'play', 'port', 'prox', 'qwap', 'sage', 'sams', 'sany', 'sch-', 'sec-', 'send', 'seri',
+ 'sgh-', 'shar', 'sie-',
+ 'siem', 'smal', 'smar', 'sony', 'sph-', 'symb', 't-mo', 'teli', 'tim-', 'tosh', 'tsm-', 'upg1',
+ 'upsi', 'vk-v', 'voda',
+ 'wap-', 'wapa', 'wapi', 'wapp', 'wapr', 'webc', 'winw', 'winw', 'xda ', 'xda-']
if mobile_ua in mobile_agents:
return True
return False