Mendeley import: Add link to support page on encrypted DB
Also localize the name of the collection created during import
This commit is contained in:
parent
cfbb3d3d47
commit
e67db436c6
5 changed files with 55 additions and 21 deletions
|
@ -330,27 +330,27 @@ var Zotero_File_Interface = new function() {
|
|||
var translation;
|
||||
// Check if the file is an SQLite database
|
||||
var sample = yield Zotero.File.getSample(file.path);
|
||||
if (Zotero.MIME.sniffForMIMEType(sample) == 'application/x-sqlite3'
|
||||
if (file.path == Zotero.DataDirectory.getDatabase()) {
|
||||
// Blacklist the current Zotero database, which would cause a hang
|
||||
&& file.path != Zotero.DataDirectory.getDatabase()) {
|
||||
}
|
||||
else if (Zotero.MIME.sniffForMIMEType(sample) == 'application/x-sqlite3') {
|
||||
// Mendeley import doesn't use the real translation architecture, but we create a
|
||||
// translation object with the same interface
|
||||
translation = yield _getMendeleyTranslation();
|
||||
translation.createNewCollection = createNewCollection;
|
||||
defaultNewCollectionPrefix = "Mendeley Import";
|
||||
defaultNewCollectionPrefix = Zotero.getString(
|
||||
'fileInterface.appImportCollection', 'Mendeley'
|
||||
);
|
||||
}
|
||||
else {
|
||||
// TEMP
|
||||
if (file.path.endsWith('.sqlite')) {
|
||||
let codes = [];
|
||||
for (let i = 0; i < sample.length; i++) {
|
||||
codes.push(sample.charCodeAt(i));
|
||||
}
|
||||
Zotero.debug(codes.join(' '));
|
||||
}
|
||||
translation = new Zotero.Translate.Import();
|
||||
else if (file.path.endsWith('@www.mendeley.com.sqlite')
|
||||
|| file.path.endsWith('online.sqlite')) {
|
||||
// Keep in sync with importWizard.js
|
||||
throw new Error('Encrypted Mendeley database');
|
||||
}
|
||||
|
||||
if (!translation) {
|
||||
translation = new Zotero.Translate.Import();
|
||||
}
|
||||
translation.setLocation(file);
|
||||
return _finishImport({
|
||||
translation,
|
||||
|
|
|
@ -217,11 +217,23 @@ var Zotero_Import_Wizard = {
|
|||
);
|
||||
}
|
||||
catch (e) {
|
||||
if (e.message == 'Encrypted Mendeley database') {
|
||||
let url = 'https://www.zotero.org/support/kb/mendeley_import';
|
||||
this._onDone(
|
||||
Zotero.getString('general.error'),
|
||||
// TODO: Localize
|
||||
`The selected Mendeley database cannot be read, likely because it is encrypted. `
|
||||
+ `See <a href="${url}" class="text-link">How do I import a Mendeley library `
|
||||
+ `into Zotero?</a> for more information.`
|
||||
);
|
||||
}
|
||||
else {
|
||||
this._onDone(
|
||||
Zotero.getString('general.error'),
|
||||
Zotero.getString('fileInterface.importError'),
|
||||
true
|
||||
);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
},
|
||||
|
@ -289,7 +301,22 @@ var Zotero_Import_Wizard = {
|
|||
_onDone: function (label, description, showReportErrorButton) {
|
||||
var wizard = this._wizard;
|
||||
wizard.getPageById('page-done').setAttribute('label', label);
|
||||
document.getElementById('result-description').textContent = description;
|
||||
|
||||
var xulElem = document.getElementById('result-description');
|
||||
var htmlElem = document.getElementById('result-description-html');
|
||||
|
||||
if (description.includes('href')) {
|
||||
htmlElem.innerHTML = description;
|
||||
Zotero.Utilities.Internal.updateHTMLInXUL(htmlElem);
|
||||
xulElem.hidden = true;
|
||||
htmlElem.setAttribute('display', 'block');
|
||||
}
|
||||
else {
|
||||
xulElem.textContent = description;
|
||||
xulElem.hidden = false;
|
||||
htmlElem.setAttribute('display', 'none');
|
||||
}
|
||||
document.getElementById('result-description')
|
||||
|
||||
if (showReportErrorButton) {
|
||||
let button = document.getElementById('result-report-error');
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
<wizard id="import-wizard"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
title="&zotero.import;"
|
||||
onload="Zotero_Import_Wizard.init()">
|
||||
|
||||
|
@ -64,6 +65,7 @@
|
|||
|
||||
<wizardpage pageid="page-done">
|
||||
<description id="result-description"/>
|
||||
<html:div id="result-description-html"/>
|
||||
<hbox>
|
||||
<button id="result-report-error"
|
||||
oncommand="Zotero_Import_Wizard.reportError()"
|
||||
|
|
|
@ -695,6 +695,7 @@ fileInterface.exportedItems = Exported Items
|
|||
fileInterface.imported = Imported
|
||||
fileInterface.unsupportedFormat = The selected file is not in a supported format.
|
||||
fileInterface.appDatabase = %S Database
|
||||
fileInterface.appImportCollection = %S Import
|
||||
fileInterface.viewSupportedFormats = View Supported Formats…
|
||||
fileInterface.untitledBibliography = Untitled Bibliography
|
||||
fileInterface.bibliographyHTMLTitle = Bibliography
|
||||
|
|
|
@ -33,10 +33,14 @@ wizard[currentpageid="page-file-list"] .wizard-header {
|
|||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
listbox, #result-description {
|
||||
listbox, #result-description, #result-description-html {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
#result-description-html a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
button, checkbox {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue