Remove server side file manipulation extensions.
This commit is contained in:
parent
67bdb1515d
commit
c9d938934b
4 changed files with 1 additions and 230 deletions
|
@ -12,6 +12,7 @@
|
|||
* adds option to hide unreadable files
|
||||
* adds option where to place folders (top, inplace, bottom)
|
||||
* adds markdown support for custom header and footer files
|
||||
* removes server side file manipulation extensions `dropbox`, `delete` and `rename`
|
||||
* fixes QR code URI origin (issue [#287](https://github.com/lrsjng/h5ai/issues/287))
|
||||
* improves preview GUI
|
||||
* adds Google UA support
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
modulejs.define('ext/delete', ['_', '$', 'core/settings', 'core/event', 'core/resource', 'core/location', 'core/server'], function (_, $, allsettings, event, resource, location, server) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
}, allsettings['delete']),
|
||||
|
||||
deleteBtnTemplate = '<li id="delete">' +
|
||||
'<a href="#">' +
|
||||
'<img src="' + resource.image('delete') + '" alt="delete"/>' +
|
||||
'<span class="l10n-delete"/>' +
|
||||
'</a>' +
|
||||
'</li>',
|
||||
|
||||
selectedHrefsStr = '',
|
||||
$delete, $img,
|
||||
|
||||
failed = function () {
|
||||
|
||||
$delete.addClass('failed');
|
||||
setTimeout(function () {
|
||||
$delete.removeClass('failed');
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
handleResponse = function (json) {
|
||||
|
||||
$delete.removeClass('current');
|
||||
$img.attr('src', resource.image('delete'));
|
||||
|
||||
if (!json || json.code) {
|
||||
failed();
|
||||
}
|
||||
location.refresh();
|
||||
},
|
||||
|
||||
requestDeletion = function (hrefsStr) {
|
||||
|
||||
$delete.addClass('current');
|
||||
$img.attr('src', resource.image('loading'));
|
||||
server.request({action: 'delete', hrefs: hrefsStr}, handleResponse);
|
||||
},
|
||||
|
||||
onSelection = function (items) {
|
||||
|
||||
selectedHrefsStr = '';
|
||||
if (items.length) {
|
||||
selectedHrefsStr = _.map(items, function (item) {
|
||||
|
||||
return item.absHref;
|
||||
}).join('|:|');
|
||||
$delete.appendTo('#navbar').show();
|
||||
} else {
|
||||
$delete.hide();
|
||||
}
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled || !server.api) {
|
||||
return;
|
||||
}
|
||||
|
||||
$delete = $(deleteBtnTemplate)
|
||||
.find('a').on('click', function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
requestDeletion(selectedHrefsStr);
|
||||
}).end()
|
||||
.appendTo('#navbar');
|
||||
$img = $delete.find('img');
|
||||
|
||||
event.sub('selection', onSelection);
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
|
@ -1,125 +0,0 @@
|
|||
|
||||
modulejs.define('ext/dropbox', ['_', '$', 'core/settings', 'core/location', 'core/server', 'core/event'], function (_, $, allsettings, location, server, event) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false,
|
||||
maxfiles: 5,
|
||||
maxfilesize: 20
|
||||
}, allsettings.dropbox),
|
||||
|
||||
template = '<ul id="uploads"/>',
|
||||
|
||||
uploadTemplate = '<li class="upload clearfix">' +
|
||||
'<span class="name"/>' +
|
||||
'<span class="size"/>' +
|
||||
'<div class="progress"><div class="bar"/></div>' +
|
||||
'</li>',
|
||||
|
||||
data = {
|
||||
action: 'upload',
|
||||
href: ''
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
||||
if (!settings.enabled || !server.api) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $content = $('#content').append(template);
|
||||
|
||||
var uploads = {},
|
||||
afterUpload = function (err, file) {
|
||||
|
||||
if (file) {
|
||||
uploads[file.name]
|
||||
.addClass(err ? 'error' : 'finished')
|
||||
.find('.progress').replaceWith(err ? '<span class="error">' + err + '</span>' : '<span class="finished">okay</span>');
|
||||
|
||||
setTimeout(function () {
|
||||
uploads[file.name].slideUp(400, function () {
|
||||
|
||||
uploads[file.name].remove();
|
||||
delete uploads[file.name];
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
};
|
||||
|
||||
event.sub('ready', function () {
|
||||
|
||||
// $content.filedrop({
|
||||
$('html').filedrop({
|
||||
|
||||
paramname: 'userfile',
|
||||
|
||||
maxfiles: settings.maxfiles,
|
||||
maxfilesize: settings.maxfilesize,
|
||||
url: location.getAbsHref(),
|
||||
data: data,
|
||||
|
||||
docEnter: function () {
|
||||
|
||||
$content.addClass('hint');
|
||||
},
|
||||
|
||||
docLeave: function () {
|
||||
|
||||
$content.removeClass('hint');
|
||||
},
|
||||
|
||||
dragOver: function () {
|
||||
|
||||
$content.addClass('match');
|
||||
},
|
||||
|
||||
dragLeave: function () {
|
||||
|
||||
$content.removeClass('match');
|
||||
},
|
||||
|
||||
drop: function () {
|
||||
|
||||
$content.removeClass('hint match');
|
||||
},
|
||||
|
||||
|
||||
beforeEach: function (file) {
|
||||
|
||||
uploads[file.name] = $(uploadTemplate).appendTo('#uploads')
|
||||
.find('.name').text(file.name).end()
|
||||
.find('.size').text(file.size).end()
|
||||
.find('.progress .bar').css('width', 0).end();
|
||||
},
|
||||
|
||||
progressUpdated: function (i, file, progress) {
|
||||
|
||||
uploads[file.name].find('.progress .bar').css('width', '' + progress + '%');
|
||||
},
|
||||
|
||||
uploadFinished: function (i, file, response) {
|
||||
|
||||
afterUpload(response.code && response.msg, file);
|
||||
},
|
||||
|
||||
afterAll: function () {
|
||||
|
||||
location.refresh();
|
||||
},
|
||||
|
||||
error: function (err, file) {
|
||||
|
||||
afterUpload(err, file);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
event.sub('location.changed', function (item) {
|
||||
|
||||
// $('#uploads').empty();
|
||||
data.href = item.absHref;
|
||||
});
|
||||
};
|
||||
|
||||
init();
|
||||
});
|
|
@ -93,26 +93,6 @@ Options
|
|||
"enabled": true
|
||||
},
|
||||
|
||||
/* [EXPERIMENTAL]
|
||||
Allow file and folder deletion. Be careful with this option!
|
||||
*/
|
||||
"delete": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
/* [EXPERIMENTAL]
|
||||
File upload via drag'n'drop. Folders are not supported.
|
||||
The working file size seems to be very browser dependent.
|
||||
|
||||
- maxfiles: number, max number of files per upload
|
||||
- maxfilesize: number, file size is in MB
|
||||
*/
|
||||
"dropbox": {
|
||||
"enabled": false,
|
||||
"maxfiles": 10,
|
||||
"maxfilesize": 1000
|
||||
},
|
||||
|
||||
/*
|
||||
Enable packaged download of selected entries.
|
||||
|
||||
|
@ -279,14 +259,6 @@ Options
|
|||
"size": 150
|
||||
},
|
||||
|
||||
/* [EXPERIMENTAL]
|
||||
Allow to rename files.
|
||||
No GUI yet.
|
||||
*/
|
||||
"rename": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
/*
|
||||
Make entries selectable (first mouse button + drag).
|
||||
At the moment only needed for packaged download and delete.
|
||||
|
|
Loading…
Add table
Reference in a new issue