From 0d5ea8520a2de05f9443e11f64a2776802ff6d63 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Mon, 15 Jan 2018 19:09:38 +0200 Subject: [PATCH] Use the bundled PDF tools --- chrome/content/zotero/downloadOverlay.js | 13 +- chrome/content/zotero/downloadOverlay.xul | 1 - .../zotero/preferences/preferences_search.js | 254 ------------- .../zotero/preferences/preferences_search.xul | 32 -- chrome/content/zotero/recognizePDF.js | 5 - chrome/content/zotero/xpcom/data/item.js | 5 - chrome/content/zotero/xpcom/fulltext.js | 359 ++---------------- chrome/content/zotero/xpcom/schema.js | 113 ------ chrome/content/zotero/xpcom/zotero.js | 4 +- chrome/content/zotero/zoteroPane.js | 46 +-- test/content/runtests.js | 41 -- test/content/support.js | 21 - test/tests/fulltextTest.js | 82 +--- test/tests/preferences_searchTest.js | 17 +- test/tests/recognizePDFTest.js | 3 +- 15 files changed, 42 insertions(+), 954 deletions(-) diff --git a/chrome/content/zotero/downloadOverlay.js b/chrome/content/zotero/downloadOverlay.js index 3767349d3f..e9846d9026 100644 --- a/chrome/content/zotero/downloadOverlay.js +++ b/chrome/content/zotero/downloadOverlay.js @@ -145,15 +145,7 @@ var Zotero_DownloadOverlay = new function() { // to happen automatically if(zoteroSelected) document.getElementById('rememberChoice').selected = false; document.getElementById('rememberChoice').disabled = zoteroSelected; - - // disable recognizePDF checkbox as necessary - if(!Zotero.Fulltext.pdfConverterIsRegistered()) { - document.getElementById('zotero-noPDFTools-description').hidden = !zoteroSelected; - document.getElementById('zotero-recognizePDF').disabled = true; - window.sizeToContent(); - } else { - document.getElementById('zotero-recognizePDF').disabled = !zoteroSelected; - } + document.getElementById('zotero-recognizePDF').disabled = !zoteroSelected; Zotero_DownloadOverlay.updateLibraryNote(); }; @@ -212,9 +204,6 @@ var Zotero_DownloadOverlay = new function() { recognizePDF.label = Zotero.getString("pane.items.menu.recognizePDF"); recognizePDF.hidden = false; recognizePDF.disabled = true; - if(!Zotero.Fulltext.pdfConverterIsRegistered()) { - recognizePDF.checked = false; - } } }; } diff --git a/chrome/content/zotero/downloadOverlay.xul b/chrome/content/zotero/downloadOverlay.xul index 2ad880493d..0fe6a95874 100644 --- a/chrome/content/zotero/downloadOverlay.xul +++ b/chrome/content/zotero/downloadOverlay.xul @@ -43,7 +43,6 @@ diff --git a/chrome/content/zotero/preferences/preferences_search.js b/chrome/content/zotero/preferences/preferences_search.js index c995a5e07f..ff5fa6a23c 100644 --- a/chrome/content/zotero/preferences/preferences_search.js +++ b/chrome/content/zotero/preferences/preferences_search.js @@ -33,264 +33,10 @@ Zotero_Preferences.Search = { document.getElementById('fulltext-clearIndex').setAttribute('label', Zotero.getString('zotero.preferences.search.clearIndex') + Zotero.getString('punctuation.ellipsis')); - this.updatePDFToolsStatus(); this.updateIndexStats(); - - // Quick hack to support install prompt from PDF recognize option - var io = window.arguments[0]; - if (io.action && io.action == 'pdftools-install') { - this.checkPDFToolsDownloadVersion(); - } }, - /* - * Update window according to installation status for PDF tools - * (e.g. status line, install/update button, etc.) - */ - updatePDFToolsStatus: function () { - var converterIsRegistered = Zotero.Fulltext.pdfConverterIsRegistered(); - var infoIsRegistered = Zotero.Fulltext.pdfInfoIsRegistered(); - - var converterStatusLabel = document.getElementById('pdfconverter-status'); - var infoStatusLabel = document.getElementById('pdfinfo-status'); - var requiredLabel = document.getElementById('pdftools-required'); - var updateButton = document.getElementById('pdftools-update-button'); - var documentationLink = document.getElementById('pdftools-documentation-link'); - var settingsBox = document.getElementById('pdftools-settings'); - - // If we haven't already generated the required and documentation messages - if (!converterIsRegistered && !requiredLabel.hasChildNodes()) { - - // Xpdf link - var str = Zotero.getString('zotero.preferences.search.pdf.toolsRequired', - [Zotero.Fulltext.pdfConverterName, Zotero.Fulltext.pdfInfoName, - '' - + Zotero.Fulltext.pdfToolsName + '']); - var parts = Zotero.Utilities.parseMarkup(str); - for (var i=0; i'; - var str = Zotero.getString('zotero.preferences.search.pdf.advancedUsers', link); - var parts = Zotero.Utilities.parseMarkup(str); - - for (var i=0; i Zotero.Fulltext.pdfConverterVersion - || (!latestVersion.startsWith('3.02') - && Zotero.Fulltext.pdfConverterVersion.startsWith('3.02')) - || (!latestVersion.startsWith('3.02') && latestVersion != '3.04' - && Zotero.Fulltext.pdfConverterVersion == '3.04')); - var infoVersionAvailable = (!infoIsRegistered || - Zotero.Fulltext.pdfInfoVersion == 'UNKNOWN' - || latestVersion > Zotero.Fulltext.pdfInfoVersion - || (!latestVersion.startsWith('3.02') - && Zotero.Fulltext.pdfInfoVersion.startsWith('3.02')) - || (!latestVersion.startsWith('3.02') && latestVersion != '3.04' - && Zotero.Fulltext.pdfInfoVersion == '3.04')); - var bothAvailable = converterVersionAvailable && infoVersionAvailable; - } - - // Up to date -- disable update button - if (!converterVersionAvailable && !infoVersionAvailable) { - var button = document.getElementById('pdftools-update-button'); - button.setAttribute('label', Zotero.getString('zotero.preferences.update.upToDate')); - button.setAttribute('disabled', true); - return; - } - - // New version available -- display update prompt - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]. - createInstance(Components.interfaces.nsIPromptService); - var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) - + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL); - - var msg = Zotero.getString('zotero.preferences.search.pdf.available' - + ((converterIsRegistered || infoIsRegistered) ? 'Updates' : 'Downloads'), - [Zotero.platform, 'zotero.org']) + '\n\n'; - - if (converterVersionAvailable) { - let tvp = Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform', - [Zotero.Fulltext.pdfConverterName, latestVersion]); - msg += '- ' + tvp + '\n'; - } - if (infoVersionAvailable) { - let tvp = Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform', - [Zotero.Fulltext.pdfInfoName, latestVersion]); - msg += '- ' + tvp + '\n'; - } - msg += '\n'; - msg += Zotero.getString('zotero.preferences.search.pdf.zoteroCanInstallVersion' - + (bothAvailable ? 's' : '')); - - var index = ps.confirmEx(null, - converterIsRegistered ? - Zotero.getString('general.updateAvailable') : '', - msg, - buttonFlags, - converterIsRegistered ? - Zotero.getString('general.upgrade') : - Zotero.getString('general.install'), - null, null, null, {}); - - if (index != 0) { - return; - } - - document.getElementById('pdftools-update-button').disabled = true; - var str = Zotero.getString('zotero.preferences.search.pdf.downloading'); - document.getElementById('pdftools-update-button').setAttribute('label', str); - - if (converterVersionAvailable) { - yield Zotero.Fulltext.downloadPDFTool('converter', latestVersion) - .catch(function (e) { - Zotero.logError(e); - throw new Error("Error downloading pdftotext"); - }); - } - if (infoVersionAvailable) { - yield Zotero.Fulltext.downloadPDFTool('info', latestVersion) - .catch(function (e) { - Zotero.logError(e); - throw new Error("Error downloading pdfinfo"); - }); - } - this.updatePDFToolsStatus(); - } - catch (e) { - this.onPDFToolsDownloadError(e); - } - }), - - - onPDFToolsDownloadError: function (e) { - if (e == 404) { - var str = Zotero.getString('zotero.preferences.search.pdf.toolDownloadsNotAvailable', - Zotero.Fulltext.pdfToolsName) + ' ' - + Zotero.getString('zotero.preferences.search.pdf.viewManualInstructions'); - } - else { - Components.utils.reportError(e); - var str = Zotero.getString('zotero.preferences.search.pdf.toolsDownloadError', Zotero.Fulltext.pdfToolsName) - + ' ' + Zotero.getString('zotero.preferences.search.pdf.tryAgainOrViewManualInstructions'); - } - - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .createInstance(Components.interfaces.nsIPromptService); - ps.alert( - null, - Zotero.getString('pane.item.attachments.PDF.installTools.title'), - str - ); - }, - - updateIndexStats: Zotero.Promise.coroutine(function* () { var stats = yield Zotero.Fulltext.getIndexStats(); document.getElementById('fulltext-stats-indexed'). diff --git a/chrome/content/zotero/preferences/preferences_search.xul b/chrome/content/zotero/preferences/preferences_search.xul index 280b8dc7f8..23fdd86fca 100644 --- a/chrome/content/zotero/preferences/preferences_search.xul +++ b/chrome/content/zotero/preferences/preferences_search.xul @@ -51,38 +51,6 @@ - - - -