attachmentRenameFormatString
→ attachmentRenameTemplate
(#3249)
This commit is contained in:
parent
e44e3edef9
commit
9b0ce9558c
4 changed files with 24 additions and 9 deletions
|
@ -2239,7 +2239,7 @@ Zotero.Attachments = new function () {
|
||||||
* based on the metadata of the specified item and a format string
|
* based on the metadata of the specified item and a format string
|
||||||
*
|
*
|
||||||
* (Optional) |formatString| specifies the format string -- otherwise
|
* (Optional) |formatString| specifies the format string -- otherwise
|
||||||
* the 'attachmentRenameFormatString' pref is used
|
* the 'attachmentRenameTemplate' pref is used
|
||||||
*
|
*
|
||||||
* @param {Zotero.Item} item
|
* @param {Zotero.Item} item
|
||||||
* @param {String} formatString
|
* @param {String} formatString
|
||||||
|
@ -2250,7 +2250,7 @@ Zotero.Attachments = new function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!formatString) {
|
if (!formatString) {
|
||||||
formatString = Zotero.Prefs.get('attachmentRenameFormatString');
|
formatString = Zotero.Prefs.get('attachmentRenameTemplate');
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSlicedCreatorsOfType = (creatorType, slice) => {
|
const getSlicedCreatorsOfType = (creatorType, slice) => {
|
||||||
|
|
|
@ -47,7 +47,7 @@ Zotero.Prefs = new function() {
|
||||||
if (!fromVersion) {
|
if (!fromVersion) {
|
||||||
fromVersion = 0;
|
fromVersion = 0;
|
||||||
}
|
}
|
||||||
var toVersion = 8;
|
var toVersion = 9;
|
||||||
if (fromVersion < toVersion) {
|
if (fromVersion < toVersion) {
|
||||||
for (var i = fromVersion + 1; i <= toVersion; i++) {
|
for (var i = fromVersion + 1; i <= toVersion; i++) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
|
@ -107,14 +107,29 @@ Zotero.Prefs = new function() {
|
||||||
case 7:
|
case 7:
|
||||||
this.clear('layers.acceleration.disabled', true);
|
this.clear('layers.acceleration.disabled', true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Convert "attachment rename format string" from old format (e.g. {%c - }{%y - }{%t{50}})
|
// Convert "attachment rename format string" from old format (e.g. {%c - }{%y - }{%t{50}})
|
||||||
// to a new format that uses the template engine
|
// to a new format that uses the template engine
|
||||||
case 8:
|
case 9:
|
||||||
if (this.prefHasUserValue('attachmentRenameFormatString')) {
|
if (this.prefHasUserValue('attachmentRenameFormatString')) {
|
||||||
this.set('attachmentRenameFormatString', this.convertLegacyAttachmentRenameFormatString(
|
let oldVal = this.get('attachmentRenameFormatString');
|
||||||
this.get('attachmentRenameFormatString') || ''
|
let newVal;
|
||||||
));
|
if (oldVal) {
|
||||||
|
if (oldVal.includes('{%')) {
|
||||||
|
newVal = this.convertLegacyAttachmentRenameFormatString(oldVal);
|
||||||
|
}
|
||||||
|
// User already modified new template from the Z7 beta before we
|
||||||
|
// renamed this pref, so just transfer over
|
||||||
|
else {
|
||||||
|
newVal = oldVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newVal) {
|
||||||
|
this.set('attachmentRenameTemplate', newVal);
|
||||||
|
}
|
||||||
|
this.clear('attachmentRenameFormatString');
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.set('prefVersion', toVersion);
|
this.set('prefVersion', toVersion);
|
||||||
|
|
|
@ -36,7 +36,7 @@ pref("extensions.zotero.autoRecognizeFiles", true);
|
||||||
pref("extensions.zotero.autoRenameFiles", true);
|
pref("extensions.zotero.autoRenameFiles", true);
|
||||||
pref("extensions.zotero.autoRenameFiles.linked", false);
|
pref("extensions.zotero.autoRenameFiles.linked", false);
|
||||||
pref("extensions.zotero.autoRenameFiles.fileTypes", "application/pdf");
|
pref("extensions.zotero.autoRenameFiles.fileTypes", "application/pdf");
|
||||||
pref("extensions.zotero.attachmentRenameFormatString", "{{ firstCreator suffix=\" - \" }}{{ year suffix=\" - \" }}{{ title truncate=\"100\" }}");
|
pref("extensions.zotero.attachmentRenameTemplate", "{{ firstCreator suffix=\" - \" }}{{ year suffix=\" - \" }}{{ title truncate=\"100\" }}");
|
||||||
pref("extensions.zotero.capitalizeTitles", false);
|
pref("extensions.zotero.capitalizeTitles", false);
|
||||||
pref("extensions.zotero.launchNonNativeFiles", false);
|
pref("extensions.zotero.launchNonNativeFiles", false);
|
||||||
pref("extensions.zotero.sortNotesChronologically", false);
|
pref("extensions.zotero.sortNotesChronologically", false);
|
||||||
|
|
|
@ -1551,7 +1551,7 @@ describe("Zotero.Attachments", function() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should convert formatString attachmentRenameFormatString to use template syntax", function () {
|
it("should convert old attachmentRenameFormatString to use new attachmentRenameTemplate syntax", function () {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
Zotero.Prefs.convertLegacyAttachmentRenameFormatString('{%c - }{%y - }{%t{50}}'),
|
Zotero.Prefs.convertLegacyAttachmentRenameFormatString('{%c - }{%y - }{%t{50}}'),
|
||||||
'{{ firstCreator suffix=" - " }}{{ year suffix=" - " }}{{ title truncate="50" }}'
|
'{{ firstCreator suffix=" - " }}{{ year suffix=" - " }}{{ title truncate="50" }}'
|
||||||
|
|
Loading…
Reference in a new issue