Merge branch '3.0'

This commit is contained in:
Simon Kornblith 2012-04-02 18:55:37 -04:00
commit 7c297f73ee
11 changed files with 498 additions and 275 deletions

View File

@ -626,7 +626,12 @@ var Zotero_File_Interface = new function() {
if(window.zoteroLastRepaint && (now - window.zoteroLastRepaint) < 100) return if(window.zoteroLastRepaint && (now - window.zoteroLastRepaint) < 100) return
// Start a nested event queue // Start a nested event queue
// TODO Remove when Fx > 14
var eventQueuePushed = "pushEventQueue" in Zotero.mainThread;
if(eventQueuePushed) {
Zotero.mainThread.pushEventQueue(null); Zotero.mainThread.pushEventQueue(null);
}
try { try {
// Add the redraw event onto event queue // Add the redraw event onto event queue
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
@ -637,7 +642,7 @@ var Zotero_File_Interface = new function() {
Zotero.mainThread.processNextEvent(false); Zotero.mainThread.processNextEvent(false);
} finally { } finally {
// Close nested event queue // Close nested event queue
Zotero.mainThread.popEventQueue(); if(eventQueuePushed) Zotero.mainThread.popEventQueue();
} }
window.zoteroLastRepaint = now; window.zoteroLastRepaint = now;

View File

@ -39,7 +39,7 @@ const Zotero_Lookup = new function () {
if(doi) { if(doi) {
var item = {itemType:"journalArticle", DOI:doi}; var item = {itemType:"journalArticle", DOI:doi};
} else { } else {
identifier = identifier.replace("-", "", "g"); identifier = identifier.trim().replace("-", "", "g");
if(identifier.length == 10 || identifier.length == 13) { if(identifier.length == 10 || identifier.length == 13) {
// ISBN // ISBN
var item = {itemType:"book", ISBN:identifier}; var item = {itemType:"book", ISBN:identifier};

View File

@ -404,12 +404,19 @@ Zotero_TranslatorTester.prototype.runTest = function(test, doc, testDoneCallback
translate.setHandler("done", function(obj, returnValue) { translate.setHandler("done", function(obj, returnValue) {
me._checkResult(test, obj, returnValue, errorReturned, testDoneCallback); me._checkResult(test, obj, returnValue, errorReturned, testDoneCallback);
}); });
var selectCalled = false;
translate.setHandler("select", function(obj, items, callback) { translate.setHandler("select", function(obj, items, callback) {
if(test.items !== "multiple" && test.items.length <= 1) { if(test.items !== "multiple" && test.items.length <= 1) {
testDoneCallback(me, test, "failed", "Zotero.selectItems() called, but only one item defined in test"); testDoneCallback(me, test, "failed", "Zotero.selectItems() called, but only one item defined in test");
callback({}); callback({});
return;
} else if(selectCalled) {
testDoneCallback(me, test, "failed", "Zotero.selectItems() called multiple times");
callback({});
return;
} }
selectCalled = true;
var newItems = {}; var newItems = {};
var haveItems = false; var haveItems = false;
for(var i in items) { for(var i in items) {

File diff suppressed because it is too large Load Diff

View File

@ -252,6 +252,8 @@ Zotero.OpenURL = new function() {
item.itemType = "conferencePaper"; item.itemType = "conferencePaper";
} else if(coParts.indexOf("rft.genre=report") !== -1) { } else if(coParts.indexOf("rft.genre=report") !== -1) {
item.itemType = "report"; item.itemType = "report";
} else if(coParts.indexOf("rft.genre=document") !== -1) {
item.itemType = "document";
} else { } else {
item.itemType = "book"; item.itemType = "book";
} }
@ -296,20 +298,20 @@ Zotero.OpenURL = new function() {
item.accessDate = ""; item.accessDate = "";
} }
} else if(key == "rft.btitle") { } else if(key == "rft.btitle") {
if(item.itemType == "book" || item.itemType == "conferencePaper" || item.itemType == "report") { if(item.itemType == "book" || item.itemType == "report") {
item.title = value; item.title = value;
} else if(item.itemType == "bookSection") { } else if(item.itemType == "bookSection" || item.itemType == "conferencePaper") {
item.publicationTitle = value; item.publicationTitle = value;
} }
} else if(key == "rft.atitle" && (item.itemType == "journalArticle" || } else if(key == "rft.atitle"
item.itemType == "bookSection")) { && ["journalArticle", "bookSection", "conferencePaper"].indexOf(item.itemType) !== -1) {
item.title = value; item.title = value;
} else if(key == "rft.jtitle" && item.itemType == "journalArticle") { } else if(key == "rft.jtitle" && item.itemType == "journalArticle") {
item.publicationTitle = value; item.publicationTitle = value;
} else if(key == "rft.stitle" && item.itemType == "journalArticle") { } else if(key == "rft.stitle" && item.itemType == "journalArticle") {
item.journalAbbreviation = value; item.journalAbbreviation = value;
} else if(key == "rft.title") { } else if(key == "rft.title") {
if(item.itemType == "journalArticle" || item.itemType == "bookSection") { if(["journalArticle", "bookSection", "conferencePaper"].indexOf(item.itemType) !== -1) {
item.publicationTitle = value; item.publicationTitle = value;
} else { } else {
item.title = value; item.title = value;

View File

@ -1446,7 +1446,7 @@ Zotero.Translate.Web.prototype._getParameters = function() { return [this.docume
Zotero.Translate.Web.prototype._prepareTranslation = function() { Zotero.Translate.Web.prototype._prepareTranslation = function() {
this._itemSaver = new Zotero.Translate.ItemSaver(this._libraryID, this._itemSaver = new Zotero.Translate.ItemSaver(this._libraryID,
Zotero.Translate.ItemSaver[(this._saveAttachments ? "ATTACHMENT_MODE_DOWNLOAD" : "ATTACHMENT_MODE_IGNORE")], 1, Zotero.Translate.ItemSaver[(this._saveAttachments ? "ATTACHMENT_MODE_DOWNLOAD" : "ATTACHMENT_MODE_IGNORE")], 1,
this.document, this._cookieSandbox); this.document, this._cookieSandbox, this.location);
this.newItems = []; this.newItems = [];
} }
@ -1668,8 +1668,18 @@ Zotero.Translate.Import.prototype._loadTranslatorPrepareIO = function(translator
*/ */
Zotero.Translate.Import.prototype._prepareTranslation = function() { Zotero.Translate.Import.prototype._prepareTranslation = function() {
this._progress = undefined; this._progress = undefined;
var baseURI = null;
if(this.location) {
try {
baseURI = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService).newFileURI(this.location);
} catch(e) {}
}
this._itemSaver = new Zotero.Translate.ItemSaver(this._libraryID, this._itemSaver = new Zotero.Translate.ItemSaver(this._libraryID,
Zotero.Translate.ItemSaver[(this._saveAttachments ? "ATTACHMENT_MODE_FILE" : "ATTACHMENT_MODE_IGNORE")]); Zotero.Translate.ItemSaver[(this._saveAttachments ? "ATTACHMENT_MODE_FILE" : "ATTACHMENT_MODE_IGNORE")],
undefined, undefined, undefined, baseURI);
this.newItems = []; this.newItems = [];
this.newCollections = []; this.newCollections = [];
} }

View File

@ -24,7 +24,7 @@
*/ */
Zotero.Translate.ItemSaver = function(libraryID, attachmentMode, forceTagType, document, Zotero.Translate.ItemSaver = function(libraryID, attachmentMode, forceTagType, document,
cookieSandbox) { cookieSandbox, baseURI) {
// initialize constants // initialize constants
this.newItems = []; this.newItems = [];
this.newCollections = []; this.newCollections = [];
@ -66,7 +66,20 @@ Zotero.Translate.ItemSaver = function(libraryID, attachmentMode, forceTagType, d
// force tag types if requested // force tag types if requested
this._forceTagType = forceTagType; this._forceTagType = forceTagType;
// to set cookies on downloaded files
this._cookieSandbox = cookieSandbox; this._cookieSandbox = cookieSandbox;
// the URI to which other URIs are assumed to be relative
if(typeof baseURI === "object" && baseURI instanceof Components.interfaces.nsIURI) {
this._baseURI = baseURI;
} else {
// try to convert to a URI
this._baseURI = null;
try {
this._baseURI = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService).newURI(baseURI, null, null);
} catch(e) {};
}
}; };
Zotero.Translate.ItemSaver.ATTACHMENT_MODE_IGNORE = 0; Zotero.Translate.ItemSaver.ATTACHMENT_MODE_IGNORE = 0;
@ -231,7 +244,7 @@ Zotero.Translate.ItemSaver.prototype = {
var IOService = Components.classes["@mozilla.org/network/io-service;1"]. var IOService = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService); getService(Components.interfaces.nsIIOService);
try { try {
var uri = IOService.newURI(attachment.path, "", null); var uri = IOService.newURI(attachment.path, "", this._baseURI);
} }
catch (e) { catch (e) {
var msg = "Error parsing attachment path: " + attachment.path; var msg = "Error parsing attachment path: " + attachment.path;

View File

@ -112,7 +112,7 @@ const CSL_TYPE_MAPPINGS = {
'case':"legal_case", 'case':"legal_case",
'hearing':"bill", // ?? 'hearing':"bill", // ??
'patent':"patent", 'patent':"patent",
'statute':"bill", // ?? 'statute':"legislation", // ??
'email':"personal_communication", 'email':"personal_communication",
'map':"map", 'map':"map",
'blogPost':"post-weblog", 'blogPost':"post-weblog",
@ -628,7 +628,7 @@ Zotero.Utilities = {
"down", "as"]; "down", "as"];
// this may only match a single character // this may only match a single character
const delimiterRegexp = /([ \/\-–—])/; const delimiterRegexp = /([ \/\u002D\u00AD\u2010-\u2015\u2212\u2E3A\u2E3B])/;
string = this.trimInternal(string); string = this.trimInternal(string);
string = string.replace(/ : /g, ": "); string = string.replace(/ : /g, ": ");
@ -1014,7 +1014,7 @@ Zotero.Utilities = {
* *
* Adapted from http://binnyva.blogspot.com/2005/10/dump-function-javascript-equivalent-of.html * Adapted from http://binnyva.blogspot.com/2005/10/dump-function-javascript-equivalent-of.html
*/ */
"varDump":function(arr,level,maxLevel) { "varDump":function(arr,level,maxLevel,parentObjects,path) {
var dumped_text = ""; var dumped_text = "";
if (!level){ if (!level){
level = 0; level = 0;
@ -1031,16 +1031,43 @@ Zotero.Utilities = {
} }
if (level > maxLevel){ if (level > maxLevel){
return dumped_text + level_padding + "...\n"; return dumped_text + level_padding + "<<Maximum depth reached>>...\n";
} }
if (typeof(arr) == 'object') { // Array/Hashes/Objects if (typeof(arr) == 'object') { // Array/Hashes/Objects
//array for checking recursion
//initialise at first itteration
if(!parentObjects) {
parentObjects = [arr];
path = ['ROOT'];
}
for (var item in arr) { for (var item in arr) {
var value = arr[item]; var value = arr[item];
if (typeof(value) == 'object') { // If it is an array, if (typeof(value) == 'object') { // If it is an array
dumped_text += level_padding + "'" + item + "' ...\n"; //check for recursion
dumped_text += arguments.callee(value,level+1,maxLevel); var i = parentObjects.indexOf(value);
if(i != -1) {
var parentName = path.slice(0,i+1).join('->');
dumped_text += level_padding + "'" + item + "' => <<Reference to parent object " + parentName + " >>\n";
continue;
}
var openBrace = '{', closeBrace = '}';
var type = Object.prototype.toString.call(value);
if(type == '[object Array]') {
openBrace = '[';
closeBrace = ']';
}
dumped_text += level_padding + "'" + item + "' => " + openBrace;
//only recurse if there's anything in the object, purely cosmetical
for(var i in value) {
dumped_text += "\n" + Zotero.Utilities.varDump(value,level+1,maxLevel,parentObjects.concat([value]),path.concat([item])) + level_padding;
break;
}
dumped_text += closeBrace + "\n";
} }
else { else {
if (typeof value == 'function'){ if (typeof value == 'function'){
@ -1173,6 +1200,8 @@ Zotero.Utilities = {
Zotero.debug("itemToServerJSON: Discarded invalid tag"); Zotero.debug("itemToServerJSON: Discarded invalid tag");
continue; continue;
} }
} else if(tag === "") {
continue;
} }
newTags[j] = {"tag":tag.toString(), "type":1}; newTags[j] = {"tag":tag.toString(), "type":1};
} }

View File

@ -242,7 +242,7 @@ Zotero.Utilities.Translate.prototype.processDocuments = function(urls, processor
} }
for(var i=0; i<urls.length; i++) { for(var i=0; i<urls.length; i++) {
if("document" in this._translate && "location" in this._translate.document if(this._translate.document && this._translate.document.location
&& this._translate.document.location.toString() === urls[i]) { && this._translate.document.location.toString() === urls[i]) {
// Document is attempting to reload itself // Document is attempting to reload itself
Zotero.debug("Translate: Attempted to load the current document using processDocuments; using loaded document instead"); Zotero.debug("Translate: Attempted to load the current document using processDocuments; using loaded document instead");

View File

@ -33,7 +33,7 @@ pref("extensions.zotero.automaticTags",true);
pref("extensions.zotero.fontSize", "1.0"); pref("extensions.zotero.fontSize", "1.0");
pref("extensions.zotero.recursiveCollections", false); pref("extensions.zotero.recursiveCollections", false);
pref("extensions.zotero.attachmentRenameFormatString", '{%c - }{%y - }{%t{50}}'); pref("extensions.zotero.attachmentRenameFormatString", '{%c - }{%y - }{%t{50}}');
pref("extensions.zotero.capitalizeTitles", true); 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);
pref("extensions.zotero.sortAttachmentsChronologically", false); pref("extensions.zotero.sortAttachmentsChronologically", false);

@ -1 +1 @@
Subproject commit 6791c19618a281a19a9d4254b97e77afac414846 Subproject commit afb3b9397b907c78f16694c589553fb767fb40fd