Use "PDF" attachment title for all individual PDFs from Mendeley import
https://forums.zotero.org/discussion/comment/327390/#Comment_327390
This commit is contained in:
parent
88f39cba80
commit
e2c4e3e86a
2 changed files with 13 additions and 5 deletions
|
@ -111,6 +111,11 @@ Zotero_Import_Mendeley.prototype.translate = async function (options = {}) {
|
|||
let docURLs = urls.get(document.id);
|
||||
let docFiles = files.get(document.id);
|
||||
|
||||
// If there's a single PDF file, use "PDF" for the attachment title
|
||||
if (docFiles && docFiles.length == 1 && docFiles[0].fileURL.endsWith('.pdf')) {
|
||||
docFiles[0].title = 'PDF';
|
||||
}
|
||||
|
||||
// If there's a single PDF file and a single PDF URL and the file exists, make an
|
||||
// imported_url attachment instead of separate file and linked_url attachments
|
||||
if (docURLs && docFiles) {
|
||||
|
@ -124,7 +129,6 @@ Zotero_Import_Mendeley.prototype.translate = async function (options = {}) {
|
|||
if (x.fileURL.endsWith('.pdf')) {
|
||||
x.title = 'PDF';
|
||||
x.url = pdfURLs[0];
|
||||
x.contentType = 'application/pdf';
|
||||
}
|
||||
});
|
||||
// Remove PDF URL from URLs array
|
||||
|
@ -988,7 +992,8 @@ Zotero_Import_Mendeley.prototype._saveFilesAndAnnotations = async function (file
|
|||
let options = {
|
||||
libraryID,
|
||||
parentItemID,
|
||||
file: realPath
|
||||
file: realPath,
|
||||
title: file.title
|
||||
};
|
||||
// If we're not set to link files or file is in Mendeley downloads folder, import it
|
||||
if (!this._linkFiles || this._isDownloadedFile(path)) {
|
||||
|
|
|
@ -42,6 +42,7 @@ Zotero.Attachments = new function(){
|
|||
* @param {nsIFile|String} [options.file] - File to add
|
||||
* @param {Integer} [options.libraryID]
|
||||
* @param {Integer[]|String[]} [options.parentItemID] - Parent item to add item to
|
||||
* @param {String} [options.title]
|
||||
* @param {Integer[]} [options.collections] - Collection keys or ids to add new item to
|
||||
* @param {String} [options.fileBaseName]
|
||||
* @param {String} [options.contentType]
|
||||
|
@ -57,6 +58,7 @@ Zotero.Attachments = new function(){
|
|||
var path = file.path;
|
||||
var leafName = file.leafName;
|
||||
var parentItemID = options.parentItemID;
|
||||
var title = options.title;
|
||||
var collections = options.collections;
|
||||
var fileBaseName = options.fileBaseName;
|
||||
var contentType = options.contentType;
|
||||
|
@ -91,7 +93,7 @@ Zotero.Attachments = new function(){
|
|||
else if (libraryID) {
|
||||
attachmentItem.libraryID = libraryID;
|
||||
}
|
||||
attachmentItem.setField('title', newName);
|
||||
attachmentItem.setField('title', title != undefined ? title : newName);
|
||||
attachmentItem.parentID = parentItemID;
|
||||
attachmentItem.attachmentLinkMode = this.LINK_MODE_IMPORTED_FILE;
|
||||
if (collections) {
|
||||
|
@ -151,6 +153,7 @@ Zotero.Attachments = new function(){
|
|||
/**
|
||||
* @param {nsIFile|String} options.file - File to add
|
||||
* @param {Integer[]|String[]} [options.parentItemID] - Parent item to add item to
|
||||
* @param {String} [options.title]
|
||||
* @param {Integer[]} [options.collections] - Collection keys or ids to add new item to
|
||||
* @param {String} [options.contentType] - Content type
|
||||
* @param {String} [options.charset] - Character set
|
||||
|
@ -162,6 +165,7 @@ Zotero.Attachments = new function(){
|
|||
|
||||
var file = Zotero.File.pathToFile(options.file);
|
||||
var parentItemID = options.parentItemID;
|
||||
var title = options.title;
|
||||
var collections = options.collections;
|
||||
var contentType = options.contentType || (yield Zotero.MIME.getMIMETypeFromFile(file));
|
||||
var charset = options.charset;
|
||||
|
@ -171,10 +175,9 @@ Zotero.Attachments = new function(){
|
|||
throw new Error("parentItemID and collections cannot both be provided");
|
||||
}
|
||||
|
||||
var title = file.leafName;
|
||||
var item = yield _addToDB({
|
||||
file,
|
||||
title,
|
||||
title: title != undefined ? title : file.leafName,
|
||||
linkMode: this.LINK_MODE_LINKED_FILE,
|
||||
contentType,
|
||||
charset,
|
||||
|
|
Loading…
Reference in a new issue