commit 9ea12d5561cae27093de32273ef2976424063718
parent d18b6ffcf0f960a7c802ce756b68ca4f1f819b77
Author: Simon Kornblith <simon@simonster.com>
Date: Wed, 10 Oct 2012 17:25:21 -0400
Merge branch '3.0'
Conflicts:
chrome/content/zotero/xpcom/translation/translate_item.js
Diffstat:
9 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/chrome/content/zotero/bindings/styled-textbox.xml b/chrome/content/zotero/bindings/styled-textbox.xml
@@ -231,10 +231,9 @@
output = output.replace(entry[0], entry[1], "g");
}
- output = Zotero.Utilities.unescapeHTML(
- output.replace(" ", " ", "g"))
- .replace(highcharRe,
- function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+"{}" });
+ output = Zotero.Utilities.unescapeHTML(output.replace(" ", " ", "g"))
+ .replace("\u00A0", " ", "g")
+ .replace(highcharRe, function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+"{}" });
output = Zotero.Utilities.trim(output);
}
diff --git a/chrome/content/zotero/xpcom/connector/translator.js b/chrome/content/zotero/xpcom/connector/translator.js
@@ -160,7 +160,7 @@ Zotero.Translators = new function() {
if(m) {
// First, drop the 0- if it exists (this is an III invention)
var host = m[2];
- if(host.substr(0, 2) === "0-") host = substr(2);
+ if(host.substr(0, 2) === "0-") host = host.substr(2);
var hostnames = host.split(".");
for(var i=1; i<hostnames.length-2; i++) {
if(TLDS[hostnames[i].toLowerCase()]) {
diff --git a/chrome/content/zotero/xpcom/mimeTypeHandler.js b/chrome/content/zotero/xpcom/mimeTypeHandler.js
@@ -70,7 +70,8 @@ Zotero.MIMETypeHandler = new function () {
// Not even trying
this.addHandler("ris", _importHandler, true);
}
- this.addHandler("text/x-csl", function(a1, a2) { Zotero.Styles.install(a1, a2) });
+ this.addHandler("application/vnd.citationstyles.style+xml", function(a1, a2) { Zotero.Styles.install(a1, a2) });
+ this.addHandler("text/x-csl", function(a1, a2) { Zotero.Styles.install(a1, a2) }); // deprecated
this.addHandler("application/x-zotero-schema", Zotero.Schema.importSchema);
this.addHandler("application/x-zotero-settings", Zotero.Prefs.importSettings);
}
diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js
@@ -752,7 +752,9 @@ Zotero.Schema = new function(){
}
}
- var fileName = Zotero.File.getValidFileName(entry.label) + fileExt;
+ var fileName = Zotero.Translators.getFileNameFromLabel(
+ entry.label, translatorID
+ );
var destFile = destDir.clone();
destFile.append(fileName);
@@ -876,7 +878,9 @@ Zotero.Schema = new function(){
}
if (mode == 'translator') {
- var fileName = Zotero.File.getValidFileName(newObj[titleField]) + fileExt
+ var fileName = Zotero.Translators.getFileNameFromLabel(
+ newObj[titleField], newObj.translatorID
+ );
}
else if (mode == 'style') {
var fileName = file.leafName;
diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js
@@ -1125,7 +1125,7 @@ Zotero.Sync.Server = new function () {
catch (e) {
Zotero.debug(e);
var msg = Zotero.getString('sync.error.loginManagerCorrupted1', Zotero.appName) + "\n\n"
- + Zotero.getString('sync.error.loginManagerCorrupted2', Zotero.appName);
+ + Zotero.getString('sync.error.loginManagerCorrupted2', [Zotero.appName, Zotero.appName]);
alert(msg);
return '';
}
diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js
@@ -217,7 +217,7 @@ Zotero.Translate.ItemSaver.prototype = {
},
"_saveAttachmentFile":function(attachment, parentID, attachmentCallback) {
- const urlRe = /(([A-Za-z]+):\/\/[^\s]*)/i;
+ const urlRe = /(([a-z][-+\.a-z0-9]*):\/\/[^\s]*)/i; //according to RFC3986
Zotero.debug("Translate: Adding attachment", 4);
if(!attachment.url && !attachment.path) {
@@ -228,7 +228,7 @@ Zotero.Translate.ItemSaver.prototype = {
if(!attachment.path) {
// see if this is actually a file URL
var m = urlRe.exec(attachment.url);
- var protocol = m ? m[2].toLowerCase() : "";
+ var protocol = m ? m[2].toLowerCase() : "file";
if(protocol == "file") {
attachment.path = attachment.url;
attachment.url = false;
@@ -294,7 +294,7 @@ Zotero.Translate.ItemSaver.prototype = {
var uri = IOService.newURI(path, "", this._baseURI);
}
catch (e) {
- var msg = "Error parsing attachment path: " + attachment.path;
+ var msg = "Error parsing attachment path: " + path;
Zotero.logError(msg);
Zotero.debug("Translate: " + msg, 2);
return false;
@@ -303,14 +303,14 @@ Zotero.Translate.ItemSaver.prototype = {
try {
var file = uri.QueryInterface(Components.interfaces.nsIFileURL).file;
if (file.path == '/') {
- var msg = "Error parsing attachment path: " + attachment.path;
+ var msg = "Error parsing attachment path: " + path;
Zotero.logError(msg);
Zotero.debug("Translate: " + msg, 2);
return false;
}
}
catch (e) {
- var msg = "Error getting file from attachment path: " + attachment.path;
+ var msg = "Error getting file from attachment path: " + path;
Zotero.logError(msg);
Zotero.debug("Translate: " + msg, 2);
return false;
@@ -439,8 +439,13 @@ Zotero.Translate.ItemSaver.prototype = {
// try to map from base field
if(Zotero.ItemFields.isBaseField(fieldID)) {
fieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(typeID, fieldID);
+
+ // Skip mapping if item field already exists
+ var fieldName = Zotero.ItemFields.getName(fieldID);
+ if(fieldName !== field && item[fieldName]) continue;
+
if(fieldID) {
- Zotero.debug("Translate: Mapping "+field+" to "+Zotero.ItemFields.getName(fieldID), 5);
+ Zotero.debug("Translate: Mapping "+field+" to "+fieldName, 5);
}
}
@@ -455,6 +460,7 @@ Zotero.Translate.ItemSaver.prototype = {
},
"_saveCreators":function(item, newItem) {
+ var creatorIndex = 0;
for(var i=0; i<item.creators.length; i++) {
var creator = item.creators[i];
@@ -505,7 +511,7 @@ Zotero.Translate.ItemSaver.prototype = {
var creatorID = creator.save();
}
- newItem.setCreator(i, creator, creatorTypeID);
+ newItem.setCreator(creatorIndex++, creator, creatorTypeID);
}
},
diff --git a/chrome/content/zotero/xpcom/translation/translator.js b/chrome/content/zotero/xpcom/translation/translator.js
@@ -305,8 +305,14 @@ Zotero.Translators = new function() {
* @param {String} label
* @return {String}
*/
- this.getFileNameFromLabel = function(label) {
- return Zotero.File.getValidFileName(label) + ".js";
+ this.getFileNameFromLabel = function(label, alternative) {
+ var fileName = Zotero.Utilities.removeDiacritics(
+ Zotero.File.getValidFileName(label)) + ".js";
+ // Use translatorID if name still isn't ASCII (e.g., Cyrillic)
+ if (alternative && !fileName.match(/^[\x00-\x7f]+$/)) {
+ fileName = alternative + ".js";
+ }
+ return fileName;
}
/**
@@ -361,7 +367,9 @@ Zotero.Translators = new function() {
throw ("code not provided in Zotero.Translators.save()");
}
- var fileName = Zotero.Translators.getFileNameFromLabel(metadata.label);
+ var fileName = Zotero.Translators.getFileNameFromLabel(
+ metadata.label, metadata.translatorID
+ );
var destFile = Zotero.getTranslatorsDirectory();
destFile.append(fileName);
diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js
@@ -1283,7 +1283,9 @@ Zotero.Utilities = {
// map from base field if possible
if((itemFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(typeID, fieldID))) {
- newItem[Zotero.ItemFields.getName(itemFieldID)] = val;
+ var fieldName = Zotero.ItemFields.getName(itemFieldID);
+ // Only map if item field does not exist
+ if(fieldName !== field && !newItem[fieldName]) newItem[fieldName] = val;
continue; // already know this is valid
}
diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties
@@ -663,7 +663,7 @@ sync.error.passwordNotSet = Password not set
sync.error.invalidLogin = Invalid username or password
sync.error.enterPassword = Please enter a password.
sync.error.loginManagerCorrupted1 = Zotero cannot access your login information, likely due to a corrupted %S login manager database.
-sync.error.loginManagerCorrupted2 = Close %S, back up and delete signons.* from your %S profile, and re-enter your Zotero login information in the Sync pane of the Zotero preferences.
+sync.error.loginManagerCorrupted2 = Close %1$S, back up and delete signons.* from your %2$S profile, and re-enter your Zotero login information in the Sync pane of the Zotero preferences.
sync.error.syncInProgress = A sync operation is already in progress.
sync.error.syncInProgress.wait = Wait for the previous sync to complete or restart %S.
sync.error.writeAccessLost = You no longer have write access to the Zotero group '%S', and files you've added or edited cannot be synced to the server.