diff --git a/i18n/en.jsonp.js b/i18n/en.jsonp.js index d0f03d992..4663f7ba9 100644 --- a/i18n/en.jsonp.js +++ b/i18n/en.jsonp.js @@ -167,6 +167,11 @@ document.localeJson = { "dialog-launchpwa-unsupported-message": "

Unfortunately, your browser does not appear to support ServiceWorker mode, which is now the default for this app.

You can continue to use the app in Safe mode, but note that this mode only works well with ZIM archives that have static content, such as Wikipedia / Wikimedia ZIMs or Stackexchange.

If you can, we recommend that you update your browser to a version that supports ServiceWorker mode.

", "dialog-messagechannel-unsupported-title": "MessageChannel API not available", "dialog-messagechannel-unsupported-message": "The MessageChannel API is not available on your device. Falling back to Safe mode...", + "dialog-metadata-warning": "Warning: above data can be spoofed!", + "dialog-metadata-name": "Name: ", + "dialog-metadata-creator": "Creator: ", + "dialog-metadata-publisher": "Publisher: ", + "dialog-metadata-scraper": "Scraper: ", "dialog-old-android": "You seem to be using an Android device with DeviceStorage API. That must be a quite old Firefox version because this API has been removed in 2016. Be aware that there was a bug on Firefox, that prevents finding Wikipedia archives in a SD-card (at least on some devices). Please put the archive in the internal storage if the application can't find it.", "dialog-other-language-message": "We are working hard to bring you more languages! If you are interested in helping to translate the interface to your language, please create an issue on our GitHub. Thank you!", "dialog-open-externalurl-message": "

Do you want to open this external link?", diff --git a/i18n/es.jsonp.js b/i18n/es.jsonp.js index b33edca4d..739a6e079 100644 --- a/i18n/es.jsonp.js +++ b/i18n/es.jsonp.js @@ -167,6 +167,11 @@ document.localeJson = { "dialog-launchpwa-unsupported-message": "

Desafortunadamente, su navegador no parece soportar el modo ServiceWorker, que ahora es el modo predeterminado para esta aplicación.

Puede continuar usando la aplicación en el modo Seguro, pero tenga en cuenta que este modo sólo funciona bien con los archivos ZIM que tienen contenido estático, tales como los archivos de Wikipedia / WikiMedia o Stackexchange.

Si puede, le recomendamos que actualice su navegador a una versión que soporte el modo ServiceWorker.

", "dialog-messagechannel-unsupported-title": "API MessageChannel no disponible", "dialog-messagechannel-unsupported-message": "La API MessageChannel no está disponible en su dispositivo. Reactivando el modo Seguro...", + "dialog-metadata-warning": "¡Atención! Estos datos pueden ser falsificados.", + "dialog-metadata-name": "Nombre: ", + "dialog-metadata-creator": "Creador: ", + "dialog-metadata-publisher": "Editor: ", + "dialog-metadata-scraper": "Raspador: ", "dialog-old-android": "Parece que está usando un dispositivo Android con la API DeviceStorage. Debe ser una versión bastante antigua de Firefox, ya que esta API se eliminó en 2016. Tenga en cuenta que había un error en Firefox que impedía encontrar los archivos de Wikipedia en una tarjeta SD (al menos en algunos dispositivos). Por favor, ponga el archivo en el almacenamiento interno si la aplicación no puede encontrarlo.", "dialog-open-externalurl-message": "

¿Quiere abrir este enlace externo?", "dialog-open-externalurl-newtab": "(en una nueva pestaña)", diff --git a/i18n/fr.jsonp.js b/i18n/fr.jsonp.js index 87c3b3e0f..ac0d10d52 100644 --- a/i18n/fr.jsonp.js +++ b/i18n/fr.jsonp.js @@ -167,6 +167,11 @@ document.localeJson = { "dialog-launchpwa-unsupported-message": "

Malheureusement, votre navigateur ne semble pas prendre en charge le mode ServiceWorker, qui est maintenant le mode par défaut pour cette application.

Vous pouvez continuer à utiliser l'application en mode Sécurisé, mais veuillez noter que ce mode ne fonctionne bien qu'avec les fichiers ZIM qui ont un contenu statique, comme les fichiers ZIM de Wikipédia / WikiMédia ou Stackexchange.

Si possible, nous vous recommandons de mettre à jour votre navigateur vers une version prenant en charge le mode ServiceWorker.

", "dialog-messagechannel-unsupported-title": "API MessageChannel non disponible", "dialog-messagechannel-unsupported-message": "L'API MessageChannel n'est pas disponible sur votre appareil. Redémarrage en mode Sécurisé...", + "dialog-metadata-warning": "Attention : les données ci-dessus peuvent être falsifiées !", + "dialog-metadata-name": "Nom : ", + "dialog-metadata-creator": "Créateur : ", + "dialog-metadata-publisher": "Éditeur : ", + "dialog-metadata-scraper": "Grattoir : ", "dialog-old-android": "Il paraît que vous utilisez un appareil Android avec l'API DeviceStorage. Il doit s'agir d'une version assez ancienne de Firefox, car cette API a été supprimée en 2016. Veuillez noter qu'il y avait un bogue dans Firefox qui empêchait de trouver les fichiers de Wikipédia sur une carte SD (du moins sur certains appareils). Veuillez donc placer le fichier dans le stockage interne si l'application ne peut pas le trouver.", "dialog-open-externalurl-message": "

Voulez-vous ouvrir ce lien externe ?

", "dialog-open-externalurl-newtab": "(dans un nouvel onglet)", diff --git a/www/css/app.css b/www/css/app.css index bcdce2250..3c7e365ca 100644 --- a/www/css/app.css +++ b/www/css/app.css @@ -250,6 +250,23 @@ iframe._invert, iframe._mwInvert { animation-duration: 0.1s; } +#modal-archive-metadata-container { + border: solid 1px lightgrey; + padding: 10px; + margin-top: 1em; + margin-bottom: 1em; +} + +.archive-metadata { + margin: 0; + padding: 0; +} + +#modal-archive-metadata-warning { + font-style: italic; + font-weight: bold; +} + .container { margin-bottom: 1.5em; } diff --git a/www/js/app.js b/www/js/app.js index 885016ef8..03ab1aea9 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -640,15 +640,64 @@ function focusPrefixOnHomeKey (event) { }, 0); } } + /** * Verifies the given archive and switches contentInjectionMode accourdingly - * @param {archive} the archive that needs verification + * @param {ZIMArchive} archive The archive that needs verification * */ async function verifyLoadedArchive (archive) { - const response = await uiUtil.systemAlert(translateUI.t('dialog-sourceverification-alert') || - 'Is this ZIM archive from a trusted source?\n If not, you can still read the ZIM file in Safe Mode. Closing this window also opens the file in Safe Mode. This option can be disabled in Expert Settings', - translateUI.t('dialog-sourceverification-title') || 'Security alert!', true, translateUI.t('dialog-sourceverification-safe-mode-button') || 'Open in Safe Mode', - translateUI.t('dialog-sourceverification-trust-button') || 'Trust Source'); + // We construct an HTML element to show the user the alert with the metadata contained in it + const metadataLabels = { + name: translateUI.t('dialog-metadata-name') || 'Name: ', + creator: translateUI.t('dialog-metadata-creator') || 'Creator: ', + publisher: translateUI.t('dialog-metadata-publisher') || 'Publisher: ', + scraper: translateUI.t('dialog-metadata-scraper') || 'Scraper: ' + } + + const verificationBody = document.createElement('div'); + + // Text & metadata box + const verificationText = document.createElement('p'); + verificationText.innerHTML = translateUI.t('dialog-sourceverification-alert') || 'Is this ZIM archive from a trusted source?\n If not, you can still read the ZIM file in Safe Mode. Closing this window also opens the file in Safe Mode. This option can be disabled in Expert Settings.'; + + const metadataBox = document.createElement('div'); + metadataBox.id = 'modal-archive-metadata-container'; + + const verifyName = document.createElement('p'); + verifyName.id = 'confirm-archive-name'; + verifyName.classList.add('archive-metadata'); + verifyName.innerText = metadataLabels.name + (archive.name || '-'); + + const verifyCreator = document.createElement('p'); + verifyCreator.id = 'confirm-archive-creator'; + verifyCreator.classList.add('archive-metadata') + verifyCreator.innerText = metadataLabels.creator + (archive.creator || '-'); + + const verifyPublisher = document.createElement('p'); + verifyPublisher.id = 'confirm-archive-publisher'; + verifyPublisher.classList.add('archive-metadata'); + verifyPublisher.innerText = metadataLabels.publisher + (archive.publisher || '-'); + + const verifyScraper = document.createElement('p'); + verifyScraper.id = 'confirm-archive-scraper'; + verifyScraper.classList.add('archive-metadata'); + verifyScraper.innerText = metadataLabels.scraper + (archive.scraper || '-'); + + const verifyWarning = document.createElement('p'); + verifyWarning.id = 'modal-archive-metadata-warning'; + verifyWarning.innerHTML = translateUI.t('dialog-metadata-warning') || 'Warning: above data can be spoofed!'; + + metadataBox.append(verifyName, verifyCreator, verifyPublisher, verifyScraper); + verificationBody.append(verificationText, metadataBox, verifyWarning); + + const response = await uiUtil.systemAlert( + verificationBody.outerHTML, + translateUI.t('dialog-sourceverification-title') || 'Security alert!', + true, + translateUI.t('dialog-sourceverification-safe-mode-button') || 'Open in Safe Mode', + translateUI.t('dialog-sourceverification-trust-button') || 'Trust Source' + ); + if (response) { params.contentInjectionMode = 'serviceworker'; var trustedZimFiles = settingsStore.getItem('trustedZimFiles'); @@ -1630,7 +1679,7 @@ document.getElementById('archiveFilesLbl').addEventListener('keydown', function /** Drag and Drop handling for ZIM files */ -// Keep track of entrance event so we only fire the correct leave event +// Keep track of entrance event so we only fire the correct leave event var enteredElement; function handleGlobalDragenter (e) { @@ -1682,7 +1731,7 @@ function hasInvalidType (typesList) { for (var i = 0; i < typesList.length; i++) { // Use indexOf() instead of startsWith() for IE11 support. Also, IE11 uses Text instead of text (and so does Opera). // This is not comprehensive, but should cover most cases. - if (typesList[i].indexOf('image') === 0 || typesList[i].indexOf('text') === 0 || typesList[i].indexOf('Text') === 0|| typesList[i].indexOf('video') === 0) { + if (typesList[i].indexOf('image') === 0 || typesList[i].indexOf('text') === 0 || typesList[i].indexOf('Text') === 0 || typesList[i].indexOf('video') === 0) { return true; } } diff --git a/www/js/lib/zimArchive.js b/www/js/lib/zimArchive.js index 2aa84a816..ca7e59fcc 100644 --- a/www/js/lib/zimArchive.js +++ b/www/js/lib/zimArchive.js @@ -80,19 +80,20 @@ function ZIMArchive (storage, path, callbackReady, callbackError) { // Further metadata are added in the background below, and can be accessed later return Promise.all([ that.addMetadataToZIMFile('Creator'), + that.addMetadataToZIMFile('Publisher'), + that.addMetadataToZIMFile('Scraper'), + that.addMetadataToZIMFile('Name'), that.addMetadataToZIMFile('Language') ]).then(function () { console.debug('ZIMArchive ready, metadata will be added in the background'); // Add non-time-critical metadata to archive in background so as not to delay opening of the archive // DEV: Note that it does not make sense to extract illustration (icon) metadata here. Instead, if you implement use of the illustration - // metadata as icons for the loaded ZIM [kiwix-js #886], you should simply use the ZIMArdhive.getMetadata() function when needed + // metadata as icons for the loaded ZIM [kiwix-js #886], you should simply use the ZIMArchive.getMetadata() function when needed setTimeout(function () { Promise.all([ that.addMetadataToZIMFile('Counter'), that.addMetadataToZIMFile('Date'), that.addMetadataToZIMFile('Description'), - that.addMetadataToZIMFile('Name'), - that.addMetadataToZIMFile('Publisher'), that.addMetadataToZIMFile('Source'), that.addMetadataToZIMFile('Title') ]).then(function () {