Merge branch '3.0'

Conflicts:
	chrome/content/zotero/xpcom/storage/webdav.js
	chrome/content/zotero/xpcom/storage/zfs.js
This commit is contained in:
Simon Kornblith 2012-11-12 16:04:39 -05:00
commit 585e5981f6
11 changed files with 1425 additions and 1417 deletions

View file

@ -1205,7 +1205,13 @@ function downloadPDFTool(tool, version, callback) {
wbp.progressListener = progressListener;
Zotero.debug("Saving " + uri.spec + " to " + fileURL.spec);
wbp.saveURI(uri, null, null, null, null, fileURL);
try {
wbp.saveURI(uri, null, null, null, null, fileURL);
} catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
// https://bugzilla.mozilla.org/show_bug.cgi?id=794602
// XXX Always use when we no longer support Firefox < 18
wbp.saveURI(uri, null, null, null, null, fileURL, null);
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -965,7 +965,13 @@ Zotero.Sync.Storage.WebDAV = (function () {
.createInstance(nsIWBP);
wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;
wbp.progressListener = listener;
wbp.saveURI(uri, null, null, null, null, destFile);
try {
wbp.saveURI(uri, null, null, null, null, destFile);
} catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
// https://bugzilla.mozilla.org/show_bug.cgi?id=794602
// XXX Always use when we no longer support Firefox < 18
wbp.saveURI(uri, null, null, null, null, destFile, null);
}
}
catch (e) {
request.error(e);

View file

@ -861,7 +861,13 @@ Zotero.Sync.Storage.ZFS = (function () {
.createInstance(nsIWBP);
wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;
wbp.progressListener = listener;
wbp.saveURI(uri, null, null, null, null, destFile);
try {
wbp.saveURI(uri, null, null, null, null, destFile);
} catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
// https://bugzilla.mozilla.org/show_bug.cgi?id=794602
// XXX Always use when we no longer support Firefox < 18
wbp.saveURI(uri, null, null, null, null, destFile, null);
}
}
catch (e) {
Zotero.Sync.Storage.EventManager.error(e);

View file

@ -595,6 +595,17 @@ Zotero.Translate.Sandbox = {
}
}
}
// Remap attachment (but not link) URLs
var properToProxy = translate.translator[0].properToProxy;
if(properToProxy && item.attachments) {
for(var i=0; i<item.attachments.length; i++) {
var attachment = item.attachments[i];
if(attachment.snapshot !== false && attachment.url) {
attachment.url = properToProxy(attachment.url);
}
}
}
}
// call super

View file

@ -35,6 +35,7 @@ const BOMs = {
}
Components.utils.import("resource://gre/modules/NetUtil.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Zotero.Translate.DOMWrapper = new function() {
/*

View file

@ -272,6 +272,45 @@ Zotero.Utilities = {
return doi ? doi[0] : null;
},
/**
* Clean and validate ISBN.
* Return isbn if valid, otherwise return false
*/
"cleanISBN":function(/**String*/ isbn) {
isbn = isbn.replace(/[^x\d]+/ig, '').toUpperCase();
if(isbn.length == 10) {
// Verify ISBN-10 checksum
var sum = 0;
for (var i = 0; i < 9; i++) {
if(isbn[i] == 'X') return false; //X can only be a check digit
sum += isbn[i] * (10-i);
}
//check digit might be 'X'
sum += (isbn[9] == 'X')? 10 : isbn[9]*1;
return (sum % 11 == 0) ? isbn : false;
}
isbn = isbn.replace(/X/g, ''); //get rid of Xs
if(isbn.length == 13) {
// ISBN-13 should start with 978 or 979 i.e. GS1 for book publishing industry
var prefix = isbn.slice(0,3);
if (prefix != "978" && prefix != "979") return false;
// Verify checksum
var sum = 0;
for (var i = 0; i < 12; i+=2) sum += isbn[i]*1; //to make sure it's int
for (i = 1; i < 12; i+=2) sum += isbn[i]*3;
sum += isbn[12]*1; //add the check digit
return (sum % 10 == 0 )? isbn : false;
}
return false;
},
/**
* Convert plain text to HTML by replacing special characters and replacing newlines with BRs or
* P tags

View file

@ -1253,6 +1253,10 @@ Components.utils.import("resource://gre/modules/Services.jsm");
*/
this.getInstalledExtensions = function(callback) {
function onHaveInstalledAddons(installed) {
installed.sort(function(a, b) {
return ((a.appDisabled || a.userDisabled) ? 1 : 0) -
((b.appDisabled || b.userDisabled) ? 1 : 0);
});
var addons = [];
for each(var addon in installed) {
switch (addon.id) {
@ -1262,7 +1266,9 @@ Components.utils.import("resource://gre/modules/Services.jsm");
}
addons.push(addon.name + " (" + addon.version
+ (addon.type != 2 ? ", " + addon.type : "") + ")");
+ (addon.type != 2 ? ", " + addon.type : "")
+ ((addon.appDisabled || addon.userDisabled) ? ", disabled" : "")
+ ")");
}
callback(addons);
}

View file

@ -819,6 +819,11 @@ function ChromeExtensionHandler() {
var fileURI = ph.newFileURI(file);
}
var channel = ioService.newChannelFromURI(fileURI);
//set originalURI so that it seems like we're serving from zotero:// protocol
//this is necessary to allow url() links to work from within css files
//otherwise they try to link to files on the file:// protocol, which is not allowed
channel.originalURI = uri;
return channel;
}
catch (e) {

View file

@ -17,7 +17,7 @@
"alias": "Google Scholar",
"_urlTemplate": "http://scholar.google.com/scholar?as_q=&as_epq={z:title}&as_occt=title&as_sauthors={rft:aufirst?}+{rft:aulast?}&as_ylo={z:year?}&as_yhi={z:year?}&as_sdt=1.&as_sdtp=on&as_sdtf=&as_sdts=22&",
"description": "Google Scholar Search",
"hidden": true,
"hidden": false,
"_urlParams": [],
"_urlNamespaces": {
"rft": "info:ofi/fmt:kev:mtx:journal",
@ -25,19 +25,5 @@
"": "http://a9.com/-/spec/opensearch/1.1/"
},
"_iconSourceURI": "http://scholar.google.com/favicon.ico"
},
{
"name": "Pubget Lookup",
"alias": "Pubget",
"_urlTemplate": "http://pubget.com/openurl?rft.title={rft:title}&rft.issue={rft:issue?}&rft.spage={rft:spage?}&rft.epage={rft:epage?}&rft.issn={rft:issn?}&rft.jtitle={rft:stitle?}&doi={z:DOI?}",
"description": "Pubget Article Lookup",
"hidden": true,
"_urlParams": [],
"_urlNamespaces": {
"rft": "info:ofi/fmt:kev:mtx:journal",
"z": "http://www.zotero.org/namespaces/openSearch#",
"": "http://a9.com/-/spec/opensearch/1.1/"
},
"_iconSourceURI": "http://pubget.com/favicon.ico"
}
]