Fix PDF tools usage in tests
This commit is contained in:
parent
5d39221afe
commit
5815088586
|
@ -26,8 +26,6 @@
|
||||||
Zotero.Fulltext = Zotero.FullText = new function(){
|
Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
this.isCachedMIMEType = isCachedMIMEType;
|
this.isCachedMIMEType = isCachedMIMEType;
|
||||||
|
|
||||||
this.__defineGetter__("pdfConverterName", function() { return 'pdftotext'; });
|
|
||||||
this.__defineGetter__("pdfInfoName", function() { return 'pdfinfo'; });
|
|
||||||
this.__defineGetter__("pdfConverterCacheFile", function () { return '.zotero-ft-cache'; });
|
this.__defineGetter__("pdfConverterCacheFile", function () { return '.zotero-ft-cache'; });
|
||||||
this.__defineGetter__("pdfInfoCacheFile", function () { return '.zotero-ft-info'; });
|
this.__defineGetter__("pdfInfoCacheFile", function () { return '.zotero-ft-info'; });
|
||||||
|
|
||||||
|
@ -54,11 +52,9 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
const kWbClassHWKatakanaLetter = 6;
|
const kWbClassHWKatakanaLetter = 6;
|
||||||
const kWbClassThaiLetter = 7;
|
const kWbClassThaiLetter = 7;
|
||||||
|
|
||||||
var _pdfConverterFileName = null;
|
|
||||||
var _pdfConverter = null; // nsIFile to executable
|
var _pdfConverter = null; // nsIFile to executable
|
||||||
var _pdfInfoFileName = null;
|
|
||||||
var _pdfInfo = null; // nsIFile to executable
|
var _pdfInfo = null; // nsIFile to executable
|
||||||
var _popplerDatadir = null;
|
var _pdfData = null;
|
||||||
|
|
||||||
var _idleObserverIsRegistered = false;
|
var _idleObserverIsRegistered = false;
|
||||||
var _idleObserverDelay = 30;
|
var _idleObserverDelay = 30;
|
||||||
|
@ -74,19 +70,19 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
this.decoder = Components.classes["@mozilla.org/intl/utf8converterservice;1"].
|
this.decoder = Components.classes["@mozilla.org/intl/utf8converterservice;1"].
|
||||||
getService(Components.interfaces.nsIUTF8ConverterService);
|
getService(Components.interfaces.nsIUTF8ConverterService);
|
||||||
|
|
||||||
_pdfConverterFileName = this.pdfConverterName;
|
let pdfConverterFileName = "pdftotext";
|
||||||
_pdfInfoFileName = this.pdfInfoName;
|
let pdfInfoFileName = "pdfinfo";
|
||||||
|
|
||||||
if (Zotero.isWin) {
|
if (Zotero.isWin) {
|
||||||
_pdfConverterFileName += '.exe';
|
pdfConverterFileName += '.exe';
|
||||||
_pdfInfoFileName += '.exe';
|
pdfInfoFileName += '.exe';
|
||||||
}
|
}
|
||||||
|
|
||||||
let dir = FileUtils.getFile('AChrom', []).parent;
|
let dir = FileUtils.getFile('AChrom', []).parent;
|
||||||
|
|
||||||
_popplerDatadir = dir.clone();
|
_pdfData = dir.clone();
|
||||||
_popplerDatadir.append('poppler-data');
|
_pdfData.append('poppler-data');
|
||||||
_popplerDatadir = _popplerDatadir.path;
|
_pdfData = _pdfData.path;
|
||||||
|
|
||||||
_pdfConverter = dir.clone();
|
_pdfConverter = dir.clone();
|
||||||
_pdfInfo = dir.clone();
|
_pdfInfo = dir.clone();
|
||||||
|
@ -99,8 +95,8 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
_pdfInfo.append('MacOS');
|
_pdfInfo.append('MacOS');
|
||||||
}
|
}
|
||||||
|
|
||||||
_pdfConverter.append(_pdfConverterFileName);
|
_pdfConverter.append(pdfConverterFileName);
|
||||||
_pdfInfo.append(_pdfInfoFileName);
|
_pdfInfo.append(pdfInfoFileName);
|
||||||
|
|
||||||
Zotero.uiReadyPromise.delay(30000).then(() => {
|
Zotero.uiReadyPromise.delay(30000).then(() => {
|
||||||
this.registerContentProcessor();
|
this.registerContentProcessor();
|
||||||
|
@ -135,6 +131,22 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
this.setPDFConverterPath = function(path) {
|
||||||
|
_pdfConverter = Zotero.File.pathToFile(path);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.setPDFInfoPath = function(path) {
|
||||||
|
_pdfInfo = Zotero.File.pathToFile(path);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.setPDFDataPath = function(path) {
|
||||||
|
_pdfData = path;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
this.getLibraryVersion = function (libraryID) {
|
this.getLibraryVersion = function (libraryID) {
|
||||||
if (!libraryID) throw new Error("libraryID not provided");
|
if (!libraryID) throw new Error("libraryID not provided");
|
||||||
return Zotero.DB.valueQueryAsync(
|
return Zotero.DB.valueQueryAsync(
|
||||||
|
@ -201,7 +213,7 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
this.getPDFConverterExecAndArgs = function () {
|
this.getPDFConverterExecAndArgs = function () {
|
||||||
return {
|
return {
|
||||||
exec: _pdfConverter,
|
exec: _pdfConverter,
|
||||||
args: ['-datadir', _popplerDatadir]
|
args: ['-datadir', _pdfData]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -293,6 +293,34 @@ if(run) {
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
Zotero.spawn(function* () {
|
Zotero.spawn(function* () {
|
||||||
yield Zotero.Schema.schemaUpdatePromise;
|
yield Zotero.Schema.schemaUpdatePromise;
|
||||||
|
|
||||||
|
// Init paths for PDF tools and data
|
||||||
|
let pdfConvertedFileName = 'pdftotext';
|
||||||
|
let pdfInfoFileName = 'pdfinfo';
|
||||||
|
|
||||||
|
if (Zotero.isWin) {
|
||||||
|
pdfConvertedFileName += '-win.exe';
|
||||||
|
pdfInfoFileName += '-win.exe';
|
||||||
|
}
|
||||||
|
else if (Zotero.isMac) {
|
||||||
|
pdfConvertedFileName += '-mac';
|
||||||
|
pdfInfoFileName += '-mac';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let cpu = Zotero.platform.split(' ')[1];
|
||||||
|
pdfConvertedFileName += '-linux-' + cpu;
|
||||||
|
pdfInfoFileName += '-linux-' + cpu;
|
||||||
|
}
|
||||||
|
|
||||||
|
let pdfToolsPath = OS.Path.join(Zotero.Profile.dir, 'pdftools');
|
||||||
|
let pdfConverterPath = OS.Path.join(pdfToolsPath, pdfConvertedFileName);
|
||||||
|
let pdfInfoPath = OS.Path.join(pdfToolsPath, pdfInfoFileName);
|
||||||
|
let pdfDataPath = OS.Path.join(pdfToolsPath, 'poppler-data');
|
||||||
|
|
||||||
|
Zotero.FullText.setPDFConverterPath(pdfConverterPath);
|
||||||
|
Zotero.FullText.setPDFInfoPath(pdfInfoPath);
|
||||||
|
Zotero.FullText.setPDFDataPath(pdfDataPath);
|
||||||
|
|
||||||
return mocha.run();
|
return mocha.run();
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
|
@ -125,6 +125,15 @@ echo "$ZOTERO_UNIT_PATH" > "$PROFILE/extensions/zotero-unit@zotero.org"
|
||||||
# Create data directory
|
# Create data directory
|
||||||
mkdir "$TEMPDIR/Zotero"
|
mkdir "$TEMPDIR/Zotero"
|
||||||
|
|
||||||
|
# Download PDF tools
|
||||||
|
PDF_TOOLS_VERSION="0.0.1"
|
||||||
|
PDF_TOOLS_URL="https://zotero-download.s3.amazonaws.com/pdftools/pdftools-$PDF_TOOLS_VERSION.tar.gz"
|
||||||
|
|
||||||
|
PDF_TOOLS_DIR="$PROFILE/pdftools"
|
||||||
|
mkdir $PDF_TOOLS_DIR
|
||||||
|
curl -o "$PDF_TOOLS_DIR/pdftools.tar.gz" $PDF_TOOLS_URL
|
||||||
|
tar -zxf "$PDF_TOOLS_DIR/pdftools.tar.gz" -C $PDF_TOOLS_DIR
|
||||||
|
|
||||||
cat <<EOF > "$PROFILE/prefs.js"
|
cat <<EOF > "$PROFILE/prefs.js"
|
||||||
user_pref("app.update.enabled", false);
|
user_pref("app.update.enabled", false);
|
||||||
user_pref("extensions.autoDisableScopes", 0);
|
user_pref("extensions.autoDisableScopes", 0);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user