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

View file

@ -39,7 +39,7 @@ const Zotero_Lookup = new function () {
if(doi) {
var item = {itemType:"journalArticle", DOI:doi};
} else {
identifier = identifier.replace("-", "", "g");
identifier = identifier.trim().replace("-", "", "g");
if(identifier.length == 10 || identifier.length == 13) {
// ISBN
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) {
me._checkResult(test, obj, returnValue, errorReturned, testDoneCallback);
});
var selectCalled = false;
translate.setHandler("select", function(obj, items, callback) {
if(test.items !== "multiple" && test.items.length <= 1) {
testDoneCallback(me, test, "failed", "Zotero.selectItems() called, but only one item defined in test");
callback({});
return;
} else if(selectCalled) {
testDoneCallback(me, test, "failed", "Zotero.selectItems() called multiple times");
callback({});
return;
}
selectCalled = true;
var newItems = {};
var haveItems = false;
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";
} else if(coParts.indexOf("rft.genre=report") !== -1) {
item.itemType = "report";
} else if(coParts.indexOf("rft.genre=document") !== -1) {
item.itemType = "document";
} else {
item.itemType = "book";
}
@ -296,20 +298,20 @@ Zotero.OpenURL = new function() {
item.accessDate = "";
}
} 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;
} else if(item.itemType == "bookSection") {
} else if(item.itemType == "bookSection" || item.itemType == "conferencePaper") {
item.publicationTitle = value;
}
} else if(key == "rft.atitle" && (item.itemType == "journalArticle" ||
item.itemType == "bookSection")) {
} else if(key == "rft.atitle"
&& ["journalArticle", "bookSection", "conferencePaper"].indexOf(item.itemType) !== -1) {
item.title = value;
} else if(key == "rft.jtitle" && item.itemType == "journalArticle") {
item.publicationTitle = value;
} else if(key == "rft.stitle" && item.itemType == "journalArticle") {
item.journalAbbreviation = value;
} else if(key == "rft.title") {
if(item.itemType == "journalArticle" || item.itemType == "bookSection") {
if(["journalArticle", "bookSection", "conferencePaper"].indexOf(item.itemType) !== -1) {
item.publicationTitle = value;
} else {
item.title = value;

View file

@ -1446,7 +1446,7 @@ Zotero.Translate.Web.prototype._getParameters = function() { return [this.docume
Zotero.Translate.Web.prototype._prepareTranslation = function() {
this._itemSaver = new Zotero.Translate.ItemSaver(this._libraryID,
Zotero.Translate.ItemSaver[(this._saveAttachments ? "ATTACHMENT_MODE_DOWNLOAD" : "ATTACHMENT_MODE_IGNORE")], 1,
this.document, this._cookieSandbox);
this.document, this._cookieSandbox, this.location);
this.newItems = [];
}
@ -1668,8 +1668,18 @@ Zotero.Translate.Import.prototype._loadTranslatorPrepareIO = function(translator
*/
Zotero.Translate.Import.prototype._prepareTranslation = function() {
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,
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.newCollections = [];
}

View file

@ -24,7 +24,7 @@
*/
Zotero.Translate.ItemSaver = function(libraryID, attachmentMode, forceTagType, document,
cookieSandbox) {
cookieSandbox, baseURI) {
// initialize constants
this.newItems = [];
this.newCollections = [];
@ -66,7 +66,20 @@ Zotero.Translate.ItemSaver = function(libraryID, attachmentMode, forceTagType, d
// force tag types if requested
this._forceTagType = forceTagType;
// to set cookies on downloaded files
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;
@ -231,7 +244,7 @@ Zotero.Translate.ItemSaver.prototype = {
var IOService = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
try {
var uri = IOService.newURI(attachment.path, "", null);
var uri = IOService.newURI(attachment.path, "", this._baseURI);
}
catch (e) {
var msg = "Error parsing attachment path: " + attachment.path;

View file

@ -112,7 +112,7 @@ const CSL_TYPE_MAPPINGS = {
'case':"legal_case",
'hearing':"bill", // ??
'patent':"patent",
'statute':"bill", // ??
'statute':"legislation", // ??
'email':"personal_communication",
'map':"map",
'blogPost':"post-weblog",
@ -628,7 +628,7 @@ Zotero.Utilities = {
"down", "as"];
// this may only match a single character
const delimiterRegexp = /([ \/\-–—])/;
const delimiterRegexp = /([ \/\u002D\u00AD\u2010-\u2015\u2212\u2E3A\u2E3B])/;
string = this.trimInternal(string);
string = string.replace(/ : /g, ": ");
@ -1014,7 +1014,7 @@ Zotero.Utilities = {
*
* 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 = "";
if (!level){
level = 0;
@ -1023,7 +1023,7 @@ Zotero.Utilities = {
if (!maxLevel) {
maxLevel = 4;
}
// The padding given at the beginning of the line.
var level_padding = "";
for (var j=0;j<level+1;j++){
@ -1031,16 +1031,43 @@ Zotero.Utilities = {
}
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
//array for checking recursion
//initialise at first itteration
if(!parentObjects) {
parentObjects = [arr];
path = ['ROOT'];
}
for (var item in arr) {
var value = arr[item];
if (typeof(value) == 'object') { // If it is an array,
dumped_text += level_padding + "'" + item + "' ...\n";
dumped_text += arguments.callee(value,level+1,maxLevel);
if (typeof(value) == 'object') { // If it is an array
//check for recursion
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 {
if (typeof value == 'function'){
@ -1173,6 +1200,8 @@ Zotero.Utilities = {
Zotero.debug("itemToServerJSON: Discarded invalid tag");
continue;
}
} else if(tag === "") {
continue;
}
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++) {
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]) {
// Document is attempting to reload itself
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.recursiveCollections", false);
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.sortNotesChronologically", false);
pref("extensions.zotero.sortAttachmentsChronologically", false);

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