mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 20:44:53 -04:00
Adds support for tarred downloads.
This commit is contained in:
parent
e67c854cb5
commit
de92767e5a
22 changed files with 160 additions and 162 deletions
|
@ -1,11 +1,14 @@
|
|||
|
||||
module.define('ext/zipped-download', [jQuery, 'core/settings', 'core/resource', 'core/event'], function ($, allsettings, resource, event) {
|
||||
module.define('ext/download', [jQuery, 'core/settings', 'core/resource', 'core/event'], function ($, allsettings, resource, event) {
|
||||
|
||||
var defaults = {
|
||||
enabled: false
|
||||
enabled: false,
|
||||
format: 'tar'
|
||||
},
|
||||
|
||||
settings = _.extend({}, defaults, allsettings['zipped-download']),
|
||||
settings = _.extend({}, defaults, allsettings['download']),
|
||||
|
||||
formats = ['tar', 'zip'],
|
||||
|
||||
downloadBtnTemplate = '<li id="download">' +
|
||||
'<a href="#">' +
|
||||
|
@ -38,7 +41,7 @@ module.define('ext/zipped-download', [jQuery, 'core/settings', 'core/resource',
|
|||
if (response.status === 'ok') {
|
||||
setTimeout(function () { // wait here so the img above can be updated in time
|
||||
|
||||
window.location = resource.api() + '?action=getzip&id=' + response.id;
|
||||
window.location = resource.api() + '?action=getarchive&id=' + response.id + '&as=h5ai-selection.' + settings.format;
|
||||
}, 200);
|
||||
} else {
|
||||
if (response.code === 401) {
|
||||
|
@ -57,14 +60,15 @@ module.define('ext/zipped-download', [jQuery, 'core/settings', 'core/resource',
|
|||
}
|
||||
},
|
||||
|
||||
requestZipping = function (hrefsStr) {
|
||||
requestArchive = function (hrefsStr) {
|
||||
|
||||
$download.addClass('current');
|
||||
$img.attr('src', resource.image('loading.gif', true));
|
||||
$.ajax({
|
||||
url: resource.api(),
|
||||
data: {
|
||||
action: 'zip',
|
||||
action: 'archive',
|
||||
format: settings.format,
|
||||
hrefs: hrefsStr
|
||||
},
|
||||
type: 'POST',
|
||||
|
@ -91,7 +95,7 @@ module.define('ext/zipped-download', [jQuery, 'core/settings', 'core/resource',
|
|||
|
||||
onSelection = function (entries) {
|
||||
|
||||
var $downloadBtn = $('#download');
|
||||
var $download = $('#download').appendTo('#navbar');
|
||||
|
||||
selectedHrefsStr = '';
|
||||
if (entries.length) {
|
||||
|
@ -99,9 +103,9 @@ module.define('ext/zipped-download', [jQuery, 'core/settings', 'core/resource',
|
|||
|
||||
return entry.absHref;
|
||||
}).join(':');
|
||||
$downloadBtn.show();
|
||||
$download.show();
|
||||
} else {
|
||||
$downloadBtn.hide();
|
||||
$download.hide();
|
||||
$downloadAuth.hide();
|
||||
}
|
||||
},
|
||||
|
@ -113,16 +117,16 @@ module.define('ext/zipped-download', [jQuery, 'core/settings', 'core/resource',
|
|||
}
|
||||
|
||||
$download = $(downloadBtnTemplate)
|
||||
.appendTo($('#navbar'))
|
||||
.appendTo('#navbar')
|
||||
.find('a').on('click', function (event) {
|
||||
|
||||
event.preventDefault();
|
||||
$downloadAuth.hide();
|
||||
requestZipping(selectedHrefsStr);
|
||||
requestArchive(selectedHrefsStr);
|
||||
});
|
||||
$img = $download.find('img');
|
||||
|
||||
$downloadAuth = $(authTemplate).appendTo($('body'));
|
||||
$downloadAuth = $(authTemplate).appendTo('body');
|
||||
$downloadUser = $downloadAuth.find('#download-auth-user');
|
||||
$downloadPassword = $downloadAuth.find('#download-auth-password');
|
||||
|
|
@ -98,14 +98,14 @@ module.define('ext/filter', [jQuery, 'core/settings', 'core/resource'], function
|
|||
|
||||
$filter = $(template);
|
||||
$input = $filter.find('input');
|
||||
$noMatch = $(noMatchTemplate).appendTo($('#extended'));
|
||||
$noMatch = $(noMatchTemplate).appendTo('#extended');
|
||||
|
||||
$filter
|
||||
.on('click', function () {
|
||||
|
||||
$input.focus();
|
||||
})
|
||||
.appendTo($('#navbar'));
|
||||
.appendTo('#navbar');
|
||||
|
||||
$input
|
||||
.on('focus', function () {
|
||||
|
|
|
@ -3,7 +3,7 @@ module.define('ext/l10n', [jQuery, 'core/settings', 'core/langs', 'core/format',
|
|||
|
||||
var defaults = {
|
||||
enabled: true,
|
||||
lang: "en",
|
||||
lang: 'en',
|
||||
useBrowserLang: true,
|
||||
defaultDateFormat: 'YYYY-MM-DD HH:mm'
|
||||
},
|
||||
|
|
|
@ -98,7 +98,7 @@ module.define('ext/select', [jQuery, 'core/settings', 'core/event'], function ($
|
|||
return;
|
||||
}
|
||||
|
||||
$selectionRect.hide().appendTo($('body'));
|
||||
$selectionRect.hide().appendTo('body');
|
||||
|
||||
$document
|
||||
.on('mousedown', '.noSelection', noSelection)
|
||||
|
|
|
@ -67,7 +67,7 @@ module.define('ext/sort', [jQuery, 'core/settings', 'core/resource', 'core/store
|
|||
|
||||
$all.removeClass('ascending').removeClass('descending');
|
||||
order.head.addClass(order.clas);
|
||||
$('#extended .entry').detach().sort(order.fn).appendTo($('#extended > ul'));
|
||||
$('#extended .entry').detach().sort(order.fn).appendTo('#extended > ul');
|
||||
},
|
||||
|
||||
init = function () {
|
||||
|
|
|
@ -197,7 +197,7 @@ module.define('ext/tree', [jQuery, 'core/settings', 'core/resource', 'core/event
|
|||
return;
|
||||
}
|
||||
|
||||
var $tree = $('<div id="tree" />').appendTo($('body'));
|
||||
var $tree = $('<div id="tree" />').appendTo('body');
|
||||
|
||||
fetchTree(entry, parser, function (root) {
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ module.define('h5ai-info', [jQuery, 'core/resource'], function ($, resource) {
|
|||
|
||||
handleChecksResponse = function (response) {
|
||||
|
||||
_.each(['php', 'cache', 'thumbs', 'temp', 'zips'], function (test) {
|
||||
_.each(['php', 'cache', 'thumbs', 'temp', 'download'], function (test) {
|
||||
|
||||
setCheckResult('#test-' + test, response && response[test]);
|
||||
})
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
// @include "ext/crumb.js"
|
||||
// @include "ext/custom.js"
|
||||
// @include "ext/download.js"
|
||||
// @include "ext/filter.js"
|
||||
// @include "ext/folderstatus.js"
|
||||
// @include "ext/l10n.js"
|
||||
|
@ -34,7 +35,6 @@
|
|||
// @include "ext/thumbnails.js"
|
||||
// @include "ext/title.js"
|
||||
// @include "ext/tree.js"
|
||||
// @include "ext/zipped-download.js"
|
||||
|
||||
// @include "h5ai-info.js"
|
||||
// @include "h5ai-main.js"
|
||||
|
|
|
@ -10,17 +10,17 @@ module.define('parser/generic-json', [jQuery, 'core/settings', 'model/entry'], f
|
|||
|
||||
var parseJson = function (absHref, json) {
|
||||
|
||||
_.each(json.entries, function (jsonEntry) {
|
||||
|
||||
Entry.get(jsonEntry.absHref, jsonEntry.time, jsonEntry.size, jsonEntry.status);
|
||||
});
|
||||
|
||||
if (json.hasOwnProperty('customHeader')) {
|
||||
settings.custom.header = json.customHeader;
|
||||
}
|
||||
if (json.hasOwnProperty('customFooter')) {
|
||||
settings.custom.footer = json.customFooter;
|
||||
}
|
||||
|
||||
return _.map(json.entries, function (jsonEntry) {
|
||||
|
||||
return Entry.get(jsonEntry.absHref, jsonEntry.time, jsonEntry.size, jsonEntry.status);
|
||||
});
|
||||
},
|
||||
|
||||
parseJsonStr = function (absHref, jsonStr) {
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
|
||||
// jQuery and plugins
|
||||
// ------------------
|
||||
// libs
|
||||
// ----
|
||||
// @include "inc/lib/modernizr-2.5.3.min.js"
|
||||
// @include "inc/lib/moment-1.5.0.min.js"
|
||||
// @include "inc/lib/json2.js"
|
||||
// @include "inc/lib/base64.js"
|
||||
|
||||
// underscore libs
|
||||
// ---------------
|
||||
// @include "inc/lib/underscore-1.3.1.min.js"
|
||||
// @include "inc/lib/module.js"
|
||||
|
||||
// jQuery libs
|
||||
// -----------
|
||||
// @include "inc/lib/jquery-1.7.1.min.js"
|
||||
// @include "inc/lib/jquery.fracs-0.11.min.js"
|
||||
// @include "inc/lib/jquery.mousewheel-3.0.6.js"
|
||||
// @include "inc/lib/jquery.qrcode.js"
|
||||
// @include "inc/lib/jquery.scrollpanel.js"
|
||||
|
||||
// non jQuery libs
|
||||
// ---------------
|
||||
// @include "inc/lib/amplify-1.1.0.min.js"
|
||||
// @include "inc/lib/base64.js"
|
||||
// @include "inc/lib/json2.js"
|
||||
// @include "inc/lib/moment-1.5.0.min.js"
|
||||
// @include "inc/lib/underscore-1.3.1.min.js"
|
||||
// @include "inc/lib/module.js"
|
||||
|
||||
// h5ai
|
||||
// ----
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue