diff --git a/CHANGELOG b/CHANGELOG index 7a45ce7..5cc120f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ Revision history for Lufi ?.??.? ????-??-?? + - LocalStorage key is now prefix-dependant (#154) + This allow to not mix up files in localStorage for two instances if they + are on the same domain 0.04.0 2019-08-04 - Allow to zip the files before upload diff --git a/themes/default/lib/Lufi/I18N/ar.po b/themes/default/lib/Lufi/I18N/ar.po index 4d2bd74..b444f3e 100644 --- a/themes/default/lib/Lufi/I18N/ar.po +++ b/themes/default/lib/Lufi/I18N/ar.po @@ -419,6 +419,14 @@ msgid "Lufi is a free (as in free speech) file hosting software." msgstr "" "لوفي أو Lufi برنامج حر (كما هو الحال في حرية التعبير) لاستضافة الملفات." +#: themes/default/templates/partial/files.js.ep:12 +msgid "" +"Lufi recently changed its way to store files information.\\n\\nNo files have " +"been found in the new localStorage location but we found files in the old " +"one.\\nDo you want to import those informations?\\n\\nPlease note that this " +"is the only time that we ask this question." +msgstr "" + #: themes/default/templates/files.html.ep:33 msgid "Mail" msgstr "البريد" diff --git a/themes/default/lib/Lufi/I18N/ca.po b/themes/default/lib/Lufi/I18N/ca.po index 0ee9db9..0ad192b 100644 --- a/themes/default/lib/Lufi/I18N/ca.po +++ b/themes/default/lib/Lufi/I18N/ca.po @@ -441,6 +441,14 @@ msgstr "Sortida" msgid "Lufi is a free (as in free speech) file hosting software." msgstr "Lufi és programari lliure d'allotjament de fitxers." +#: themes/default/templates/partial/files.js.ep:12 +msgid "" +"Lufi recently changed its way to store files information.\\n\\nNo files have " +"been found in the new localStorage location but we found files in the old " +"one.\\nDo you want to import those informations?\\n\\nPlease note that this " +"is the only time that we ask this question." +msgstr "" + #: themes/default/templates/files.html.ep:33 msgid "Mail" msgstr "Mail" diff --git a/themes/default/lib/Lufi/I18N/de.po b/themes/default/lib/Lufi/I18N/de.po index 9a8ecb1..74444d7 100644 --- a/themes/default/lib/Lufi/I18N/de.po +++ b/themes/default/lib/Lufi/I18N/de.po @@ -451,6 +451,14 @@ msgid "Lufi is a free (as in free speech) file hosting software." msgstr "" "Lufi ist eine kostenlose (wie in der Redefreiheit) Datei-Hosting-Software." +#: themes/default/templates/partial/files.js.ep:12 +msgid "" +"Lufi recently changed its way to store files information.\\n\\nNo files have " +"been found in the new localStorage location but we found files in the old " +"one.\\nDo you want to import those informations?\\n\\nPlease note that this " +"is the only time that we ask this question." +msgstr "" + #: themes/default/templates/files.html.ep:33 msgid "Mail" msgstr "E-Mail" diff --git a/themes/default/lib/Lufi/I18N/en.po b/themes/default/lib/Lufi/I18N/en.po index b29bf89..9755e91 100644 --- a/themes/default/lib/Lufi/I18N/en.po +++ b/themes/default/lib/Lufi/I18N/en.po @@ -8,7 +8,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2019-08-04 05:31+0000\n" +"PO-Revision-Date: 2019-08-09 05:28+0000\n" "Last-Translator: Luc Didry \n" "Language-Team: English\n" "Language: en\n" @@ -435,6 +435,18 @@ msgstr "Logout" msgid "Lufi is a free (as in free speech) file hosting software." msgstr "Lufi is a free (as in free speech) file hosting software." +#: themes/default/templates/partial/files.js.ep:12 +msgid "" +"Lufi recently changed its way to store files information.\\n\\nNo files have " +"been found in the new localStorage location but we found files in the old " +"one.\\nDo you want to import those informations?\\n\\nPlease note that this " +"is the only time that we ask this question." +msgstr "" +"Lufi recently changed its way to store files information.\\n\\nNo files have " +"been found in the new localStorage location but we found files in the old " +"one.\\nDo you want to import those informations?\\n\\nPlease note that this " +"is the only time that we ask this question." + #: themes/default/templates/files.html.ep:33 msgid "Mail" msgstr "Mail" diff --git a/themes/default/lib/Lufi/I18N/fr.po b/themes/default/lib/Lufi/I18N/fr.po index cbda1ec..facdbec 100644 --- a/themes/default/lib/Lufi/I18N/fr.po +++ b/themes/default/lib/Lufi/I18N/fr.po @@ -11,7 +11,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2019-08-04 05:33+0000\n" +"PO-Revision-Date: 2019-08-09 05:27+0000\n" "Language-Team: \n" "X-Generator: Zanata 4.6.2\n" "Last-Translator: Luc Didry \n" @@ -452,6 +452,19 @@ msgstr "Déconnexion" msgid "Lufi is a free (as in free speech) file hosting software." msgstr "Lufi est un logiciel libre d’hébergement de fichiers." +#: themes/default/templates/partial/files.js.ep:12 +msgid "" +"Lufi recently changed its way to store files information.\\n\\nNo files have " +"been found in the new localStorage location but we found files in the old " +"one.\\nDo you want to import those informations?\\n\\nPlease note that this " +"is the only time that we ask this question." +msgstr "" +"Lufi a récemment changé sa façon de stocker l'information des fichiers." +"\\n\\nAucun fichier n'a été trouvé dans le nouvel emplacement localStorage " +"mais nous avons trouvé des fichiers dans l'ancien.\\nVoulez-vous importer " +"ces informations ?\\n\\nVeuillez noter que c'est la seule fois que nous " +"posons cette question." + #: themes/default/templates/files.html.ep:33 msgid "Mail" msgstr "Mail" diff --git a/themes/default/lib/Lufi/I18N/fr_FR.po b/themes/default/lib/Lufi/I18N/fr_FR.po index 6bf9f89..3bf783b 100644 --- a/themes/default/lib/Lufi/I18N/fr_FR.po +++ b/themes/default/lib/Lufi/I18N/fr_FR.po @@ -11,7 +11,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2019-08-04 05:34+0000\n" +"PO-Revision-Date: 2019-08-09 05:27+0000\n" "Language-Team: \n" "X-Generator: Zanata 4.6.2\n" "Last-Translator: Luc Didry \n" @@ -452,6 +452,19 @@ msgstr "Déconnexion" msgid "Lufi is a free (as in free speech) file hosting software." msgstr "Lufi est un logiciel libre d’hébergement de fichiers." +#: themes/default/templates/partial/files.js.ep:12 +msgid "" +"Lufi recently changed its way to store files information.\\n\\nNo files have " +"been found in the new localStorage location but we found files in the old " +"one.\\nDo you want to import those informations?\\n\\nPlease note that this " +"is the only time that we ask this question." +msgstr "" +"Lufi a récemment changé sa façon de stocker l'information des fichiers." +"\\n\\nAucun fichier n'a été trouvé dans le nouvel emplacement localStorage " +"mais nous avons trouvé des fichiers dans l'ancien.\\nVoulez-vous importer " +"ces informations ?\\n\\nVeuillez noter que c'est la seule fois que nous " +"posons cette question." + #: themes/default/templates/files.html.ep:33 msgid "Mail" msgstr "Mail" diff --git a/themes/default/lib/Lufi/I18N/it.po b/themes/default/lib/Lufi/I18N/it.po index 436c980..e137f67 100644 --- a/themes/default/lib/Lufi/I18N/it.po +++ b/themes/default/lib/Lufi/I18N/it.po @@ -435,6 +435,14 @@ msgstr "Logout" msgid "Lufi is a free (as in free speech) file hosting software." msgstr "Lufi è un software libero di file hosting." +#: themes/default/templates/partial/files.js.ep:12 +msgid "" +"Lufi recently changed its way to store files information.\\n\\nNo files have " +"been found in the new localStorage location but we found files in the old " +"one.\\nDo you want to import those informations?\\n\\nPlease note that this " +"is the only time that we ask this question." +msgstr "" + #: themes/default/templates/files.html.ep:33 msgid "Mail" msgstr "" diff --git a/themes/default/lib/Lufi/I18N/lufi.pot b/themes/default/lib/Lufi/I18N/lufi.pot index c1c09fb..1a55e1b 100644 --- a/themes/default/lib/Lufi/I18N/lufi.pot +++ b/themes/default/lib/Lufi/I18N/lufi.pot @@ -393,6 +393,10 @@ msgstr "" msgid "Lufi is a free (as in free speech) file hosting software." msgstr "" +#: themes/default/templates/partial/files.js.ep:12 +msgid "Lufi recently changed its way to store files information.\\n\\nNo files have been found in the new localStorage location but we found files in the old one.\\nDo you want to import those informations?\\n\\nPlease note that this is the only time that we ask this question." +msgstr "" + #: themes/default/templates/files.html.ep:33 msgid "Mail" msgstr "" diff --git a/themes/default/lib/Lufi/I18N/nl.po b/themes/default/lib/Lufi/I18N/nl.po index 8801b88..fa6645a 100644 --- a/themes/default/lib/Lufi/I18N/nl.po +++ b/themes/default/lib/Lufi/I18N/nl.po @@ -433,6 +433,14 @@ msgstr "Logout" msgid "Lufi is a free (as in free speech) file hosting software." msgstr "Lufi is een gratis bestand hosting software." +#: themes/default/templates/partial/files.js.ep:12 +msgid "" +"Lufi recently changed its way to store files information.\\n\\nNo files have " +"been found in the new localStorage location but we found files in the old " +"one.\\nDo you want to import those informations?\\n\\nPlease note that this " +"is the only time that we ask this question." +msgstr "" + #: themes/default/templates/files.html.ep:33 msgid "Mail" msgstr "" diff --git a/themes/default/lib/Lufi/I18N/oc.po b/themes/default/lib/Lufi/I18N/oc.po index fda28df..156a6d4 100644 --- a/themes/default/lib/Lufi/I18N/oc.po +++ b/themes/default/lib/Lufi/I18N/oc.po @@ -450,6 +450,14 @@ msgstr "Desconnexion" msgid "Lufi is a free (as in free speech) file hosting software." msgstr "Lufi es un logicial liure d’albèrgament de fichièrs." +#: themes/default/templates/partial/files.js.ep:12 +msgid "" +"Lufi recently changed its way to store files information.\\n\\nNo files have " +"been found in the new localStorage location but we found files in the old " +"one.\\nDo you want to import those informations?\\n\\nPlease note that this " +"is the only time that we ask this question." +msgstr "" + #: themes/default/templates/files.html.ep:33 msgid "Mail" msgstr "Corrièl" diff --git a/themes/default/lib/Lufi/I18N/pt.po b/themes/default/lib/Lufi/I18N/pt.po index 291baa4..7d86848 100644 --- a/themes/default/lib/Lufi/I18N/pt.po +++ b/themes/default/lib/Lufi/I18N/pt.po @@ -443,6 +443,14 @@ msgstr "" "Lufi é um programa de reserva gratuita (como na liberdade de expressão) de " "ficheiros." +#: themes/default/templates/partial/files.js.ep:12 +msgid "" +"Lufi recently changed its way to store files information.\\n\\nNo files have " +"been found in the new localStorage location but we found files in the old " +"one.\\nDo you want to import those informations?\\n\\nPlease note that this " +"is the only time that we ask this question." +msgstr "" + #: themes/default/templates/files.html.ep:33 msgid "Mail" msgstr "" diff --git a/themes/default/public/js/lufi-files.js b/themes/default/public/js/lufi-files.js index 0910f1d..18ce122 100644 --- a/themes/default/public/js/lufi-files.js +++ b/themes/default/public/js/lufi-files.js @@ -1,18 +1,18 @@ // vim:set sw=4 ts=4 sts=4 ft=javascript expandtab: // Add item to localStorage function addItem(item) { - var files = localStorage.getItem('files'); + var files = localStorage.getItem(window.prefix + 'files'); if (files === null) { files = new Array(); } else { files = JSON.parse(files); } files.push(item); - localStorage.setItem('files', JSON.stringify(files)); + localStorage.setItem(window.prefix + 'files', JSON.stringify(files)); } function delItem(name) { - var files = localStorage.getItem('files'); + var files = localStorage.getItem(window.prefix + 'files'); if (files === null) { files = new Array(); } else { @@ -24,11 +24,11 @@ function delItem(name) { files.splice(i, 1); } } - localStorage.setItem('files', JSON.stringify(files)); + localStorage.setItem(window.prefix + 'files', JSON.stringify(files)); } function itemExists(name) { - var files = localStorage.getItem('files'); + var files = localStorage.getItem(window.prefix + 'files'); if (files === null) { return false; } else { @@ -45,7 +45,7 @@ function itemExists(name) { function purgeExpired(event) { event.preventDefault(); - var files = JSON.parse(localStorage.getItem('files')); + var files = JSON.parse(localStorage.getItem(window.prefix + 'files')); files.forEach(function(element, index, array) { $.ajax({ @@ -74,7 +74,7 @@ function exportStorage(event) { a.hide(); $('body').append(a); - var storageData = [localStorage.getItem('files')]; + var storageData = [localStorage.getItem(window.prefix + 'files')]; var exportFile = new Blob(storageData, {type : 'application/json'}); var url = window.URL.createObjectURL(exportFile); @@ -164,9 +164,20 @@ function massDelete(event) { function populateFilesTable() { $('#myfiles').empty(); - var files = localStorage.getItem('files'); + var files = localStorage.getItem(window.prefix + 'files'); if (files === null) { - files = new Array(); + var filesWithoutPrefix = localStorage.getItem('files'); + if (filesWithoutPrefix !== null) { + if (window.confirm(i18n.importFilesWithoutPrefix)) { + localStorage.setItem(window.prefix + 'files', filesWithoutPrefix); + files = JSON.parse(filesWithoutPrefix); + } else { + localStorage.setItem(window.prefix + 'files', JSON.stringify([])); + files = new Array(); + } + } else { + files = new Array(); + } } else { files = JSON.parse(files); } diff --git a/themes/default/public/js/lufi-up.js b/themes/default/public/js/lufi-up.js index 42a6352..caca705 100644 --- a/themes/default/public/js/lufi-up.js +++ b/themes/default/public/js/lufi-up.js @@ -68,14 +68,14 @@ function copyAllToClipboard(event) { // Add item to localStorage function addItem(name, url, size, del_at_first_view, created_at, delay, short, token) { - var files = localStorage.getItem('files'); + var files = localStorage.getItem(window.prefix + 'files'); if (files === null) { files = new Array(); } else { files = JSON.parse(files); } files.push({ name: name, short: short, url: url, size: size, del_at_first_view: del_at_first_view, created_at: created_at, delay: delay, token: token }); - localStorage.setItem('files', JSON.stringify(files)); + localStorage.setItem(window.prefix + 'files', JSON.stringify(files)); } // Remove a file block diff --git a/themes/default/templates/partial/files.js.ep b/themes/default/templates/partial/files.js.ep index f06186d..b60aeaa 100644 --- a/themes/default/templates/partial/files.js.ep +++ b/themes/default/templates/partial/files.js.ep @@ -7,8 +7,9 @@ var actionURL = '<%= url_for('/')->to_abs() %>'; var counterURL = '<%== url_for('counter') %>'; var i18n = { - noExpiration: '<%= l('No expiration delay') %>', - importProcessed: '<%= l('The data has been successfully imported.') %>', + noExpiration: '<%= l('No expiration delay') %>', + importProcessed: '<%= l('The data has been successfully imported.') %>', + importFilesWithoutPrefix: "<%= l('Lufi recently changed its way to store files information.\n\nNo files have been found in the new localStorage location but we found files in the old one.\nDo you want to import those informations?\n\nPlease note that this is the only time that we ask this question.') %>", }; $(document).ready(function() { populateFilesTable(); diff --git a/themes/default/templates/partial/layout.js.ep b/themes/default/templates/partial/layout.js.ep index 5d811cb..a15c36b 100644 --- a/themes/default/templates/partial/layout.js.ep +++ b/themes/default/templates/partial/layout.js.ep @@ -1,2 +1,3 @@ % # vim:set sts=4 sw=4 ts=4 ft=javascript expandtab: var langUrl = '<%= url_for('lang') %>'; +var prefix = '<%= substr(config('prefix'), 1) %>'; diff --git a/themes/default/templates/partial/mail.js.ep b/themes/default/templates/partial/mail.js.ep index d54351f..92e5c94 100644 --- a/themes/default/templates/partial/mail.js.ep +++ b/themes/default/templates/partial/mail.js.ep @@ -1,6 +1,6 @@ % # vim:set sts=4 sw=4 ts=4 ft=javascript expandtab: function findItem(name) { - var files = localStorage.getItem('files'); + var files = localStorage.getItem(window.prefix + 'files'); if (files === null) { files = new Array(); } else {