Set retrieved OA PDF title to reflect version

"Full Text", "Accepted Version", or "Submitted Version"
This commit is contained in:
Dan Stillman 2018-08-24 19:41:23 -04:00
parent 1860b57802
commit e7e681c113
3 changed files with 31 additions and 4 deletions

View file

@ -1132,10 +1132,10 @@ Zotero.Attachments = new function(){
directory: tmpDir,
libraryID: item.libraryID,
filename: OS.Path.basename(tmpFile),
title: _getPDFTitleFromVersion(props.articleVersion),
url,
contentType: 'application/pdf',
parentItemID: item.id,
articleVersion: props.articleVersion
parentItemID: item.id
});
}
else {
@ -1153,6 +1153,29 @@ Zotero.Attachments = new function(){
};
function _getPDFTitleFromVersion(version) {
var str;
switch (version) {
case 'acceptedVersion':
case 'accepted':
str = 'acceptedVersion';
break;
case 'submittedVersion':
case 'submitted':
str = 'submittedVersion';
break;
// 'publishedVersion' or unspecified
default:
str = 'fullText';
}
return Zotero.getString('attachment.' + str);
}
/**
* Try to download a file from a list of URLs, keeping the first one that succeeds
*

View file

@ -599,6 +599,10 @@ findPDF.openAccessPDF = Open-Access PDF
findPDF.pdfWithMethod = PDF (%S)
findPDF.noPDFsFound = No PDFs found
attachment.fullText = Full Text
attachment.acceptedVersion = Accepted Version
attachment.submittedVersion = Submitted Version
db.dbCorrupted = The Zotero database '%S' appears to have become corrupted.
db.dbCorrupted.restart = Please restart %S to attempt an automatic restore from the last backup.
db.dbCorruptedNoBackup = The Zotero database '%S' appears to have become corrupted, and no automatic backup is available.\n\nA new database has been created. The damaged file was saved to your Zotero data directory.

View file

@ -588,7 +588,7 @@ describe("Connector Server", function () {
assert.lengthOf(ids, 1);
item = Zotero.Items.get(ids[0]);
assert.isTrue(item.isImportedAttachment());
assert.equal(item.getField('title'), 'Title.pdf');
assert.equal(item.getField('title'), Zotero.getString('attachment.submittedVersion'));
});
@ -742,7 +742,7 @@ describe("Connector Server", function () {
assert.lengthOf(ids, 1);
item = Zotero.Items.get(ids[0]);
assert.isTrue(item.isImportedAttachment());
assert.equal(item.getField('title'), 'Title.pdf');
assert.equal(item.getField('title'), Zotero.getString('attachment.submittedVersion'));
});
});
});