Merge branch '3.0'

This commit is contained in:
Simon Kornblith 2012-11-11 17:15:30 -05:00
commit bd367dcd85
5 changed files with 924 additions and 550 deletions

File diff suppressed because it is too large Load diff

View file

@ -385,63 +385,51 @@ Zotero.Server.Connector.SaveSnapshot.prototype = {
*/
"init":function(url, data, sendResponseCallback) {
Zotero.Server.Connector.Data[data["url"]] = "<html>"+data["html"]+"</html>";
var browser = Zotero.Browser.createHiddenBrowser();
var pageShowCalled = false;
var cookieSandbox = new Zotero.CookieSandbox(browser, data["url"], data["cookie"], url.userAgent);
browser.addEventListener("pageshow", function() {
if(browser.contentDocument.location.href == "about:blank"
|| browser.contentDocument.readyState !== "complete") return;
if(pageShowCalled) return;
pageShowCalled = true;
delete Zotero.Server.Connector.Data[data["url"]];
// figure out where to save
var libraryID = null;
var collectionID = null;
var zp = Zotero.getActiveZoteroPane();
try {
var libraryID = zp.getSelectedLibraryID();
var collection = zp.getSelectedCollection();
} catch(e) {}
try {
var doc = browser.contentDocument;
Zotero.HTTP.processDocuments(["zotero://connector/"+encodeURIComponent(data["url"])],
function(doc) {
delete Zotero.Server.Connector.Data[data["url"]];
// create new webpage item
var item = new Zotero.Item("webpage");
item.libraryID = libraryID;
item.setField("title", doc.title);
item.setField("url", data.url);
item.setField("accessDate", "CURRENT_TIMESTAMP");
var itemID = item.save();
if(collection) collection.addItem(itemID);
// figure out where to save
var libraryID = null;
var collectionID = null;
var zp = Zotero.getActiveZoteroPane();
try {
var libraryID = zp.getSelectedLibraryID();
var collection = zp.getSelectedCollection();
} catch(e) {}
// determine whether snapshot can be saved
var filesEditable;
if (libraryID) {
var group = Zotero.Groups.getByLibraryID(libraryID);
filesEditable = group.filesEditable;
} else {
filesEditable = true;
try {
// create new webpage item
var item = new Zotero.Item("webpage");
item.libraryID = libraryID;
item.setField("title", doc.title);
item.setField("url", data.url);
item.setField("accessDate", "CURRENT_TIMESTAMP");
var itemID = item.save();
if(collection) collection.addItem(itemID);
// determine whether snapshot can be saved
var filesEditable;
if (libraryID) {
var group = Zotero.Groups.getByLibraryID(libraryID);
filesEditable = group.filesEditable;
} else {
filesEditable = true;
}
// save snapshot
if(filesEditable) {
Zotero.Attachments.importFromDocument(doc, itemID);
}
sendResponseCallback(201);
} catch(e) {
sendResponseCallback(500);
throw e;
}
// save snapshot
if(filesEditable) {
Zotero.Attachments.importFromDocument(doc, itemID);
}
// remove browser
Zotero.Browser.deleteHiddenBrowser(browser);
sendResponseCallback(201);
} catch(e) {
sendResponseCallback(500);
throw e;
}
}, false);
browser.loadURI("zotero://connector/"+encodeURIComponent(data["url"]));
},
null, null, false,
new Zotero.CookieSandbox(null, data["url"], data["cookie"], url.userAgent));
}
}

View file

@ -334,11 +334,13 @@ Zotero.Translate.ItemSaver.prototype = {
Zotero.debug("Translate: Not adding attachment: no URL specified", 2);
} else {
// Determine whether to save an attachment
if(attachment.document
|| (attachment.mimeType && attachment.mimeType == "text/html")) {
if(!Zotero.Prefs.get("automaticSnapshots")) return;
} else {
if(!Zotero.Prefs.get("downloadAssociatedFiles")) return;
if(attachment.snapshot !== false) {
if(attachment.document
|| (attachment.mimeType && attachment.mimeType == "text/html")) {
if(!Zotero.Prefs.get("automaticSnapshots")) return;
} else {
if(!Zotero.Prefs.get("downloadAssociatedFiles")) return;
}
}
if(attachment.document) {

View file

@ -963,7 +963,7 @@ function ChromeExtensionHandler() {
this.name = uri;
this.URI = ioService.newURI(uri, "UTF-8", null);
this.owner = secMan.getCodebasePrincipal(this.URI);
this.owner = (secMan.getCodebasePrincipal || secMan.getSimpleCodebasePrincipal)(this.URI);
this._isPending = true;
var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].

View file

@ -1 +1 @@
2012-11-05 20:05:00
2012-11-06 16:30:00