From: Maciej Tronowski Date: Mon, 20 Apr 2015 15:12:05 +0000 (+0200) Subject: gridftp: handle paths beginning with `~` X-Git-Tag: v1.0~60 X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=commitdiff_plain;h=dee5b1cbf07c44e308dbccea2e49bb484eb6f2f5;hp=1b85cda6547627731535b0b023adfda0e7d873a4;p=qcg-portal.git gridftp: handle paths beginning with `~` --- diff --git a/filex/forms.py b/filex/forms.py index 26ca737..e9b866f 100644 --- a/filex/forms.py +++ b/filex/forms.py @@ -12,12 +12,12 @@ from filex.models import Favorite msg = u'Invalid value' host_validator = RegexValidator(r'^(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+' r'(?:[a-zA-Z]{2,6}\.?|[a-zA-Z0-9-]{2,}(?', { href: '#', - text: this.model.get('text') + text: this.model.get('name') })); } this.$el.toggleClass('active', this.model.get('active')); @@ -261,13 +261,13 @@ $(function(){ lockOptgroupOrder: true, create: function(input, callback) { var $form = $('#favorite-form'), - parts = input.split('/', 1), + parts = input.split('/'), callback_called = false; - $form.find('#id_host').val(parts[0]); + $form.find('#id_host').val(parts.shift()); - if (parts.length > 1) - $form.find('#id_path').val(parts[1]); + if (parts.length) + $form.find('#id_path').val(parts.join('/')); $form.on('submit', function(e) { var $this = $(this), @@ -326,13 +326,15 @@ $(function(){ }, load: function(location) { - var path = location.replace(/(^\/+|\/+$)/g, '').split('/'), - host = path.shift(), - pathBits = [new Filex.PathBit({'text': '/', 'path': ''})].concat(_.map(path, function(name) { - return new Filex.PathBit({'text': name, 'path': name}); - })); - - this.host = host; + var hostRootPath = location.split(/\/(\/|~)(.*)/), + pathBits = [new Filex.PathBit({'name': hostRootPath[1]})].concat( + _.chain(hostRootPath[2].split('/')) + .filter(_.identity) + .map(function(name) { return new Filex.PathBit({'name': name}) }) + .value() + ); + + this.host = hostRootPath[0]; this.path.reset(pathBits); this.$host.text(this.host); @@ -393,7 +395,7 @@ $(function(){ }, selectedDir: function(dir) { - this.path.add({'text': dir.get('name'), 'path': dir.get('name')}); + this.path.add({'name': dir.get('name')}); }, selectedPath: function(bit) { @@ -459,20 +461,13 @@ $(function(){ $btn.button('loading'); - $.post(url, data, 'json').done(function () { + $.post(url, data, 'json').done(function (response) { $btn.button('reset'); - if (is_active) { - locations.removeOption(data.host + data.path); - } - else { - locations.addOption({ - group: 'usr', - host: data.host, - path: data.path, - value: data.host + data.path - }); - } + if (is_active) + locations.removeOption(data.host + '/' + data.path); + else + locations.addOption(response); }).fail(function() { $btn.button('reset'); $btn.button('toggle'); @@ -495,7 +490,7 @@ $(function(){ }, updateFavorites: function() { - var loc = this.host + this.path.full(), + var loc = this.host + '/' + this.path.full(), favorites = this.hostSelectize.options; if (favorites.hasOwnProperty(loc)) { diff --git a/filex/templates/filex/source.js.html b/filex/templates/filex/source.js.html index 311acb7..0623fde 100644 --- a/filex/templates/filex/source.js.html +++ b/filex/templates/filex/source.js.html @@ -12,10 +12,6 @@ }); - -