✉️🗜 Restore zip option for guests + 🐛 fix bugs

The bugs were:
- bad hiding/showing parts when ending/cancelling uploads
- bad behavior when mixing zip and regular uploads
This commit is contained in:
Luc Didry 2019-08-01 00:57:15 +02:00
parent a201060e69
commit d1627ea997
No known key found for this signature in database
GPG Key ID: EA868E12D0257E3C
4 changed files with 65 additions and 40 deletions

View File

@ -45,7 +45,7 @@ msgstr ""
msgid "%A %d %B %Y at %T"
msgstr ""
#: themes/default/templates/partial/index.js.ep:26
#: themes/default/templates/partial/index.js.ep:27
msgid "(max size: XXX)"
msgstr ""
@ -65,7 +65,7 @@ msgstr ""
msgid "Abort"
msgstr ""
#: themes/default/templates/layouts/default.html.ep:53 themes/default/templates/layouts/default.html.ep:82
#: themes/default/templates/layouts/default.html.ep:53 themes/default/templates/layouts/default.html.ep:86
msgid "About"
msgstr ""
@ -114,7 +114,7 @@ msgstr ""
msgid "Click on the following URL to upload files on Lufi:"
msgstr ""
#: themes/default/templates/index.html.ep:128
#: themes/default/templates/index.html.ep:125
msgid "Click to open the file browser"
msgstr ""
@ -126,15 +126,15 @@ msgstr ""
msgid "Comma-separated email addresses"
msgstr ""
#: themes/default/templates/index.html.ep:142
#: themes/default/templates/index.html.ep:139
msgid "Compressing zip file…"
msgstr ""
#: themes/default/templates/partial/index.js.ep:14
#: themes/default/templates/partial/index.js.ep:15
msgid "Copy all links to clipboard"
msgstr ""
#: themes/default/templates/partial/index.js.ep:17
#: themes/default/templates/partial/index.js.ep:18
msgid "Copy to clipboard"
msgstr ""
@ -174,7 +174,7 @@ msgstr ""
msgid "Delete selected files"
msgstr ""
#: themes/default/templates/files.html.ep:32 themes/default/templates/partial/index.js.ep:18
#: themes/default/templates/files.html.ep:32 themes/default/templates/partial/index.js.ep:19
msgid "Deletion link"
msgstr ""
@ -182,7 +182,7 @@ msgstr ""
msgid "Don't worry: if a user begins to download the file before the expiration and the download ends after the expiration, he will be able to get the file."
msgstr ""
#: themes/default/templates/partial/index.js.ep:20 themes/default/templates/render.html.ep:28
#: themes/default/templates/partial/index.js.ep:21 themes/default/templates/render.html.ep:28
msgid "Download"
msgstr ""
@ -190,7 +190,7 @@ msgstr ""
msgid "Download aborted."
msgstr ""
#: themes/default/templates/files.html.ep:27 themes/default/templates/partial/index.js.ep:19
#: themes/default/templates/files.html.ep:27 themes/default/templates/partial/index.js.ep:20
msgid "Download link"
msgstr ""
@ -198,7 +198,7 @@ msgstr ""
msgid "Drag and drop files in the appropriate area or use the traditional way to send files and the files will be chunked, encrypted and sent to the server. You will get two links per file: a download link, that you give to the people you want to share the file with and a deletion link, allowing you to delete the file whenever you want."
msgstr ""
#: themes/default/templates/index.html.ep:124
#: themes/default/templates/index.html.ep:121
msgid "Drop files here"
msgstr ""
@ -218,7 +218,7 @@ msgstr ""
msgid "Emails"
msgstr ""
#: themes/default/templates/partial/index.js.ep:21
#: themes/default/templates/partial/index.js.ep:22
msgid "Encrypting part XX1 of XX2"
msgstr ""
@ -234,7 +234,7 @@ msgstr ""
msgid "Error: unable to find the file. Are you sure of your URL?"
msgstr ""
#: themes/default/templates/partial/index.js.ep:22
#: themes/default/templates/partial/index.js.ep:23
msgid "Expiration:"
msgstr ""
@ -307,11 +307,11 @@ msgstr ""
msgid "Hide hidden invitations"
msgstr ""
#: themes/default/templates/partial/index.js.ep:24
#: themes/default/templates/partial/index.js.ep:25
msgid "Hit Enter, then Ctrl+C to copy all the download links"
msgstr ""
#: themes/default/templates/partial/index.js.ep:23
#: themes/default/templates/partial/index.js.ep:24
msgid "Hit Enter, then Ctrl+C to copy the download link"
msgstr ""
@ -365,7 +365,7 @@ msgstr ""
msgid "Invitation sent to %1.<br> URL: %2"
msgstr ""
#: themes/default/templates/invitations/invite.html.ep:27 themes/default/templates/layouts/default.html.ep:36
#: themes/default/templates/invitations/invite.html.ep:27 themes/default/templates/layouts/default.html.ep:36 themes/default/templates/layouts/default.html.ep:69
msgid "Invite a guest"
msgstr ""
@ -377,7 +377,7 @@ msgstr ""
msgid "Javascript is disabled. You won't be able to use Lufi."
msgstr ""
#: themes/default/templates/layouts/default.html.ep:44 themes/default/templates/layouts/default.html.ep:46 themes/default/templates/layouts/default.html.ep:73 themes/default/templates/layouts/default.html.ep:75
#: themes/default/templates/layouts/default.html.ep:44 themes/default/templates/layouts/default.html.ep:46 themes/default/templates/layouts/default.html.ep:77 themes/default/templates/layouts/default.html.ep:79
msgid "Language"
msgstr ""
@ -385,7 +385,7 @@ msgstr ""
msgid "Login"
msgstr ""
#: themes/default/templates/layouts/default.html.ep:58 themes/default/templates/layouts/default.html.ep:84
#: themes/default/templates/layouts/default.html.ep:58 themes/default/templates/layouts/default.html.ep:91
msgid "Logout"
msgstr ""
@ -401,7 +401,7 @@ msgstr ""
msgid "My files"
msgstr ""
#: themes/default/templates/invitations/my_invitations.html.ep:5 themes/default/templates/layouts/default.html.ep:37
#: themes/default/templates/invitations/my_invitations.html.ep:5 themes/default/templates/layouts/default.html.ep:37 themes/default/templates/layouts/default.html.ep:70
msgid "My invitations"
msgstr ""
@ -418,7 +418,7 @@ msgstr ""
msgid "No enough space available on the server for this file (size: %1)."
msgstr ""
#: themes/default/templates/partial/files.js.ep:10 themes/default/templates/partial/index.js.ep:27
#: themes/default/templates/partial/files.js.ep:10 themes/default/templates/partial/index.js.ep:28
msgid "No expiration delay"
msgstr ""
@ -475,7 +475,7 @@ msgstr ""
msgid "Rows in red mean that the files have expired and are no longer available."
msgstr ""
#: themes/default/templates/partial/index.js.ep:25
#: themes/default/templates/partial/index.js.ep:26
msgid "Send all links by email"
msgstr ""
@ -491,7 +491,7 @@ msgstr ""
msgid "Send with your own mail software"
msgstr ""
#: themes/default/templates/partial/index.js.ep:28
#: themes/default/templates/partial/index.js.ep:29
msgid "Sending part XX1 of XX2. Please, be patient, the progress bar can take a while to move."
msgstr ""
@ -508,7 +508,7 @@ msgstr ""
msgid "Show zip content"
msgstr ""
#: themes/default/templates/layouts/default.html.ep:40 themes/default/templates/layouts/default.html.ep:69 themes/default/templates/login.html.ep:28 themes/default/templates/logout.html.ep:17
#: themes/default/templates/layouts/default.html.ep:40 themes/default/templates/layouts/default.html.ep:73 themes/default/templates/login.html.ep:28 themes/default/templates/logout.html.ep:17
msgid "Signin"
msgstr ""
@ -596,7 +596,7 @@ msgstr ""
msgid "The invitation mail will be send from your email address (%1)."
msgstr ""
#: themes/default/templates/partial/index.js.ep:15
#: themes/default/templates/partial/index.js.ep:16
msgid "The link(s) has been copied to your clipboard"
msgstr ""
@ -647,7 +647,7 @@ msgstr ""
msgid "URL"
msgstr ""
#: themes/default/templates/partial/index.js.ep:16
#: themes/default/templates/partial/index.js.ep:17
msgid "Unable to copy the link(s) to your clipboard"
msgstr ""
@ -670,7 +670,7 @@ msgstr ""
msgid "Upload files"
msgstr ""
#: themes/default/templates/index.html.ep:119
#: themes/default/templates/index.html.ep:142
msgid "Upload generated zip file"
msgstr ""
@ -682,7 +682,7 @@ msgstr ""
msgid "Uploaded files"
msgstr ""
#: themes/default/templates/partial/index.js.ep:29
#: themes/default/templates/partial/index.js.ep:30
msgid "Websocket communication error"
msgstr ""
@ -694,6 +694,10 @@ msgstr ""
msgid "Who wrote this software?"
msgstr ""
#: themes/default/templates/partial/index.js.ep:13
msgid "XXX file has been added to upload queue."
msgstr ""
#: themes/default/templates/invitations/invite.html.ep:30
msgid "You can invite someone to send you files through this Lufi instance even if they dont have an account on it."
msgstr ""
@ -718,7 +722,7 @@ msgstr ""
msgid "You have attempted to leave this page. The download will be canceled. Are you sure?"
msgstr ""
#: themes/default/templates/partial/index.js.ep:13
#: themes/default/templates/partial/index.js.ep:14
msgid "You have attempted to leave this page. The upload will be canceled. Are you sure?"
msgstr ""
@ -775,7 +779,7 @@ msgstr ""
msgid "no time limit"
msgstr ""
#: themes/default/templates/index.html.ep:126
#: themes/default/templates/index.html.ep:123
msgid "or"
msgstr ""

View File

@ -82,11 +82,9 @@ function addItem(name, url, size, del_at_first_view, created_at, delay, short, t
function destroyBlock(el) {
$(el).parents('li').remove();
var a = $('.link-input');
var l = $('#results li');
if (a.length === 0) {
if ($('.link-input').length === 0) {
$('#misc').empty();
if (l.length === 0 && window.fileList === null) {
if ($('#results li').length === 0 && window.fileList === null) {
$('#results').hide();
}
} else {
@ -136,7 +134,7 @@ function getZipname() {
}
}
return zipname;
return escapeHtml(zipname);
}
// Update the zip name
@ -150,20 +148,28 @@ function uploadZip(e) {
var delay = $('#delete-day');
var del_at_first_view = $('#first-view');
$('#zip-files').attr('disabled', 'disabled');
$('#file-browser-button').attr('disabled', 'disabled');
$('#file-browser-span').addClass('disabled');
$('#uploadZip').addClass('hide');
$('#zip-parts').text('');
$('#zip-compressing').removeClass('hide');
window.zip.generateAsync({type:"blob"})
.then(function(zipFile) {
// if $('#zipping') is hidden, the zipping has been aborted
if (!$('#zipping').hasClass('hide')) {
window.zip = null;
$('#zipping').addClass('hide');
$('#zipname-input').addClass('hide');
$('#zip-compressing').addClass('hide');
$('#uploadZip').removeClass('hide');
$('#results').show();
$('#zip-files').attr('disabled', null);
var zipname = getZipname();
var file = new File([zipFile], zipname, {type: 'application/zip'});
Materialize.toast(i18n.enqueued.replace('XXX', zipname), 3000, 'teal accent-3');
if (window.fileList === undefined || window.fileList === null) {
window.fileList = [file];
uploadFile(0, delay.val(), del_at_first_view.is(':checked'));
@ -171,6 +177,8 @@ function uploadZip(e) {
window.fileList.push(file);
}
}
$('#file-browser-button').attr('disabled', null);
$('#file-browser-span').removeClass('disabled');
});
}
@ -245,6 +253,10 @@ function handleFiles(f) {
} else {
if (window.fileList === undefined || window.fileList === null) {
window.fileList = Array.prototype.slice.call(f);
for (var i = 0; i < window.fileList.length; i++) {
var file = window.fileList[i];
Materialize.toast(i18n.enqueued.replace('XXX', escapeHtml(file.name)), 3000, 'teal accent-3');
}
window.nbFiles = window.fileList.length;
$('#results').show();
uploadFile(0, delay.val(), del_at_first_view.is(':checked'));
@ -430,10 +442,13 @@ function updateProgressBar(data) {
window.onbeforeunload = null;
$('#delete-day').attr('disabled', null);
$('#first-view').attr('disabled', null);
if ($('#zip-files').is(':checked')) {
if ($('#zip-files').is(':checked') && window.zip === null) {
$('label[for="zip-files"]').click();
}
}
if ($('#results li').length === 0 && window.fileList === null) {
$('#results').hide();
}
} else {
var i = data.i;
var sent_delay = data.sent_delay;
@ -537,13 +552,16 @@ function updateProgressBar(data) {
window.onbeforeunload = null;
$('#delete-day').attr('disabled', null);
$('#first-view').attr('disabled', null);
if ($('#zip-files').is(':checked')) {
if ($('#zip-files').is(':checked') && window.zip === null) {
$('label[for="zip-files"]').click();
}
if (isGuest) {
sendFilesURLs();
}
}
if ($('#results li').length === 0 && window.fileList === null) {
$('#results').hide();
}
} else {
j++;
// Update progress bar
@ -677,5 +695,9 @@ $(document).ready(function() {
$('#reset-zipping').on('click', function() {
window.zip = null;
$('label[for="zip-files"]').click();
$('#zip-files').attr('disabled', null);
$('#zip-compressing').addClass('hide');
$('#file-browser-button').attr('disabled', null);
$('#file-browser-span').removeClass('disabled');
});
});

View File

@ -90,7 +90,6 @@
<label for="first-view"><%= l('Delete at first download?') %></label>
</p>
</div>
% if (!stash('invitation')) {
<div class="input-field">
<p class="col s12 m6 text-left">
<input
@ -101,7 +100,6 @@
<label for="zip-files"><%= l('Create a zip archive with the files before uploading?') %></label>
</p>
</div>
% }
% if (config('allow_pwd_on_files') && (!stash('invitation'))) {
<div class="col s12 m6">
<div class="input-field">
@ -117,9 +115,6 @@
<label for="zipname"><%= l('Name of the zip file') %></label>
</div>
</div>
<div class="col s12 m6 text-left input-field">
<a href="#" id="uploadZip" class="btn waves-effect waves-light"><%= l('Upload generated zip file') %></a>
</div>
</div>
</form>
<div id="files">
@ -143,6 +138,9 @@
<button class="btn-floating pulse"><i class="mdi-content-archive"></i></button>
<%= l('Compressing zip file…') %>
</p>
<div class="col s12 m6 text-left input-field right">
<a href="#" id="uploadZip" class="btn waves-effect waves-light"><%= l('Upload generated zip file') %></a>
</div>
<ul id="zip-parts">
</ul>
</div>

View File

@ -10,6 +10,7 @@ var baseURL = '<%= url_for('/')->to_abs() %>';
% }
var actionURL = '<%= url_for('/')->to_abs() %>';
var i18n = {
enqueued: '<%= l('XXX file has been added to upload queue.') %>',
confirmExit: '<%= l('You have attempted to leave this page. The upload will be canceled. Are you sure?') %>',
copyAll: '<%= l('Copy all links to clipboard') %>',
copySuccess: '<%= l('The link(s) has been copied to your clipboard') %>',