diff options
Diffstat (limited to 'pyload')
-rw-r--r-- | pyload/InitHomeDir.py | 4 | ||||
-rw-r--r-- | pyload/__init__.py | 3 | ||||
-rw-r--r-- | pyload/web/app/scripts/models/CollectorPackage.js | 8 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/dashboard/dashboardView.js | 4 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/linkgrabber/collectorView.js | 9 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/linkgrabber/modalView.js | 23 | ||||
-rw-r--r-- | pyload/web/app/styles/default/linkgrabber.less | 11 | ||||
-rwxr-xr-x | pyload/web/app/templates/default/linkgrabber/modal.html | 39 | ||||
-rw-r--r-- | pyload/web/middlewares.py | 2 |
9 files changed, 70 insertions, 33 deletions
diff --git a/pyload/InitHomeDir.py b/pyload/InitHomeDir.py index 91603e104..4c7fce2eb 100644 --- a/pyload/InitHomeDir.py +++ b/pyload/InitHomeDir.py @@ -24,7 +24,7 @@ from os.path import join import sys from sys import argv, platform -from . import __version__ +from . import __dev__ import __builtin__ @@ -83,7 +83,7 @@ elif path.exists(path.join(pypath, "pyload", "config", "configdir")): # default config dir if not configdir: # suffix when running dev version - dev = "-dev" if __version__.endswith("-dev") else "" + dev = "-dev" if __dev__ else "" configname = ".pyload" if platform in ("posix", "linux2", "darwin") else "pyload" configdir = path.join(homedir, configname + dev) diff --git a/pyload/__init__.py b/pyload/__init__.py index b72ac12e9..0fb52399b 100644 --- a/pyload/__init__.py +++ b/pyload/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +__dev__ = True __version_info__ = ('0', '4', '9', '9') -__version__ = '.'.join(__version_info__) + "-dev"
\ No newline at end of file +__version__ = '.'.join(__version_info__) + ("-dev" if __dev__ else "")
\ No newline at end of file diff --git a/pyload/web/app/scripts/models/CollectorPackage.js b/pyload/web/app/scripts/models/CollectorPackage.js index e5625d7bd..b608b8e18 100644 --- a/pyload/web/app/scripts/models/CollectorPackage.js +++ b/pyload/web/app/scripts/models/CollectorPackage.js @@ -54,6 +54,14 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection this.trigger('change'); }, + // Returns true if pack is empty now + removeLinks: function(links) { + this.get('links').remove(_.map(links, function(link) { + return link.url; + })); + return this.get('links').length === 0; + }, + toJSON: function() { var data = { name: this.getName(), diff --git a/pyload/web/app/scripts/views/dashboard/dashboardView.js b/pyload/web/app/scripts/views/dashboard/dashboardView.js index 8a0446203..d98e28fe3 100644 --- a/pyload/web/app/scripts/views/dashboard/dashboardView.js +++ b/pyload/web/app/scripts/views/dashboard/dashboardView.js @@ -28,12 +28,12 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', 'col var self = this; // When package is added we reload the data - App.vent.on('package:added', function() { + this.listenTo(App.vent, 'package:added', function() { console.log('Package tree caught, package:added event'); self.tree.fetch(); }); - App.vent.on('file:updated', _.bind(this.fileUpdated, this)); + this.listenTo(App.vent, 'file:updated', _.bind(this.fileUpdated, this)); // TODO: merge? this.init(); diff --git a/pyload/web/app/scripts/views/linkgrabber/collectorView.js b/pyload/web/app/scripts/views/linkgrabber/collectorView.js index a02023a30..08b426aff 100644 --- a/pyload/web/app/scripts/views/linkgrabber/collectorView.js +++ b/pyload/web/app/scripts/views/linkgrabber/collectorView.js @@ -21,7 +21,14 @@ define(['jquery', 'underscore', 'backbone', 'app', './packageView'], self.collection.add(pack); } - // TODO: remove links from all other packages than pack + // Remove links from other packages and delete empty ones + self.collection.each(function(pack2) { + console.log(pack2, links); + if (pack2 !== pack) + if (pack2.removeLinks(links)) + self.collection.remove(pack2); + }); + pack.updateLinks(links); }); } diff --git a/pyload/web/app/scripts/views/linkgrabber/modalView.js b/pyload/web/app/scripts/views/linkgrabber/modalView.js index 32730658c..808d67f59 100644 --- a/pyload/web/app/scripts/views/linkgrabber/modalView.js +++ b/pyload/web/app/scripts/views/linkgrabber/modalView.js @@ -6,7 +6,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v className: 'modal linkgrabber', events: { - 'keypress #inputLinks': 'addOnEnter' + 'keyup #inputLinks': 'addOnKeyUp' }, template: template, @@ -14,18 +14,30 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v // Holds the view that display the packages collectorView: null, + inputSize: 0, + initialize: function() { // Inherit parent events this.events = _.extend({}, modalView.prototype.events, this.events); this.listenTo(App.vent, 'package:added', _.bind(this.onAdded, this)); }, - addOnEnter: function(e) { - if (e.keyCode !== 13) return; - this.addPackage(e); + addOnKeyUp: function(e) { + // Enter adds the links + if (e.keyCode === 13) + this.parseLinks(); + + var inputSize = this.$('#inputLinks').val().length; + + // TODO: checkbox to disable this + // add links when several characters was pasted into box + if (inputSize > this.inputSize + 4) + this.parseLinks(); + else + this.inputSize = inputSize; }, - addPackage: function(e) { + parseLinks: function() { var self = this; // split, trim and remove empty links var links = _.filter(_.map(this.$('#inputLinks').val().split('\n'), function(link) { @@ -44,6 +56,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v $.ajax(options); this.$('#inputLinks').val(''); + this.inputSize = 0; }, // Hide when there are no more packages diff --git a/pyload/web/app/styles/default/linkgrabber.less b/pyload/web/app/styles/default/linkgrabber.less index 8ed6d1dc5..c2e3642ef 100644 --- a/pyload/web/app/styles/default/linkgrabber.less +++ b/pyload/web/app/styles/default/linkgrabber.less @@ -1,5 +1,14 @@ .linkgrabber { - width: 700px !important; + width: 800px !important; + + .pull-left { + padding-right: 20px; + } + + input, textarea { + width: 130px; + } + } .prepared-packages { diff --git a/pyload/web/app/templates/default/linkgrabber/modal.html b/pyload/web/app/templates/default/linkgrabber/modal.html index 67e2e4fe3..750613663 100755 --- a/pyload/web/app/templates/default/linkgrabber/modal.html +++ b/pyload/web/app/templates/default/linkgrabber/modal.html @@ -7,32 +7,29 @@ </div> <div class="modal-body"> - <div class="alert alert-error hidden"> - {{_ "Upload files container failed. Please try again." }} - </div> - <form class="form-horizontal"> - <div class="control-group"> - <label class="control-label" for="inputLinks">{{ _ "Links" }}</label> - - <div class="controls"> - <textarea id="inputLinks" class="span4" rows="2" placeholder="{{_ " Paste your links here..."}}"></textarea> + <div class="container-fluid"> + <div class="row-fluid"> + <div class="span4"> + <h3 class="pull-left">Links</h3> + <textarea id="inputLinks" rows="1" placeholder="{{_ " Paste your links here..."}}"></textarea> </div> - </div> - <div class="control-group"> - <label class="control-label" for="inputContainer">{{_ "Upload container file" }}</label> - <div class="controls controls-row"> - <input type="text" id="inputContainer" class="span3" readonly> - <button id="inputContainer-btn" class="btn span1" type="button">{{_ "Browse" }}…</button> + <div class="span4"> + <h3 class="pull-left">{{_ "Container" }}</h3> + <button class="btn btn-blue">{{_ "Upload" }}</button> + </div> + <div class="span4"> + <h3 class="pull-left">{{_ "URL" }}</h3> + <input type="text" placeholder="{{ _ "Link to Website"}}"> </div> </div> + </div> - <legend> - {{_ "Packages" }} - </legend> - <div class="container-fluid prepared-packages"> + <legend> + {{_ "Packages" }} + </legend> + <div class="container-fluid prepared-packages"> - </div> - </form> + </div> </div> <div class="modal-footer"> diff --git a/pyload/web/middlewares.py b/pyload/web/middlewares.py index ae0911cc3..913e714bb 100644 --- a/pyload/web/middlewares.py +++ b/pyload/web/middlewares.py @@ -111,6 +111,8 @@ class GzipResponse(object): out.close() return [s] + # TODO: also writes large files to stringbuffer + # avoids optimized send_file and causes memory shortage def finish_response(self, app_iter): if self.compressible: output = gzip.GzipFile(mode='wb', compresslevel=self.compress_level, |