www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit c2e116a49a21d8988f6f1ce971d7e73a52428a4a
parent 1b370244394c7dd71079135343adf395b3382816
Author: Dan Stillman <dstillman@zotero.org>
Date:   Mon, 10 Sep 2012 17:18:08 -0400

Merge branch '3.0'

Conflicts:
	chrome/content/zotero/locale/csl
	chrome/content/zotero/xpcom/server_connector.js
	chrome/content/zotero/xpcom/storage.js

Diffstat:
Mchrome/content/zotero/xpcom/cookieSandbox.js | 9++++++++-
Mchrome/content/zotero/xpcom/integration.js | 4+++-
Mchrome/content/zotero/xpcom/search.js | 19+++++++++++++++++++
Mchrome/content/zotero/xpcom/server.js | 5++++-
Mchrome/content/zotero/xpcom/server_connector.js | 14+++++++-------
Mchrome/content/zotero/xpcom/sync.js | 40++++++++++++++++++++++------------------
Mchrome/content/zotero/xpcom/translation/translate.js | 2+-
Mchrome/locale/en-US/zotero/zotero.properties | 1+
Mchrome/skin/default/zotero/standalone.css | 2+-
9 files changed, 66 insertions(+), 30 deletions(-)

diff --git a/chrome/content/zotero/xpcom/cookieSandbox.js b/chrome/content/zotero/xpcom/cookieSandbox.js @@ -31,8 +31,9 @@ * @param {String|nsIURI} uri URI of page to manage cookies for (cookies for domains that are not * subdomains of this URI are ignored) * @param {String} cookieData Cookies with which to initiate the sandbox + * @param {String} userAgent User agent to use for sandboxed requests */ -Zotero.CookieSandbox = function(browser, uri, cookieData) { +Zotero.CookieSandbox = function(browser, uri, cookieData, userAgent) { this._observerService = Components.classes["@mozilla.org/observer-service;1"]. getService(Components.interfaces.nsIObserverService); @@ -54,6 +55,8 @@ Zotero.CookieSandbox = function(browser, uri, cookieData) { } } + if(userAgent) this.userAgent = userAgent; + Zotero.CookieSandbox.Observer.register(); if(browser) { this.attachToBrowser(browser); @@ -206,6 +209,10 @@ Zotero.CookieSandbox.Observer = new function() { return; } + if(trackedBy.userAgent) { + channel.setRequestHeader("User-Agent", trackedBy.userAgent, false); + } + // add cookies to be sent to this domain channel.setRequestHeader("Cookie", trackedBy.cookieString, false); Zotero.debug("CookieSandbox: Added cookies for request to "+channelURI, 5); diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js @@ -2167,7 +2167,7 @@ Zotero.Integration.Session.prototype.getCitationField = function(citation) { // add itemData only if requested if(this.data.prefs.storeReferences) { - serializeCitationItem.itemData = citationItem.item; + serializeCitationItem.itemData = Zotero.Cite.System.retrieveItem(citationItem.id); addSchema = true; } } @@ -2507,6 +2507,8 @@ Zotero.Integration.Session.prototype.deleteCitation = function(index) { Zotero.Integration.Session.prototype.getBibliography = function() { this.updateUncitedItems(); + if(Zotero.Utilities.isEmpty(this.citationsByItemID)) return false; + // generate bibliography var bib = this.style.makeBibliography(); diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js @@ -410,6 +410,12 @@ Zotero.Search.prototype.addCondition = function(condition, operator, value, requ for each(var part in parts) { this.addCondition('blockStart'); + + // If search string is 8 characters, see if this is a item key + if (operator == 'contains' && part.text.length == 8) { + this.addCondition('key', 'is', part.text, false); + } + if (condition == 'quicksearch-titleCreatorYear') { this.addCondition('title', operator, part.text, false); this.addCondition('year', operator, part.text, false); @@ -2181,6 +2187,19 @@ Zotero.SearchConditions = new function(){ }, { + name: 'key', + operators: { + is: true, + isNot: true, + beginsWith: true + }, + table: 'items', + field: 'key', + special: true, + noLoad: true + }, + + { name: 'annotation', operators: { contains: true, diff --git a/chrome/content/zotero/xpcom/server.js b/chrome/content/zotero/xpcom/server.js @@ -383,9 +383,12 @@ Zotero.Server.DataListener.prototype._processEndpoint = function(method, postDat // pass to endpoint if((endpoint.init.length ? endpoint.init.length : endpoint.init.arity) === 3) { + const uaRe = /[\r\n]User-Agent: +([^\r\n]+)/i; + var m = uaRe.exec(this.header); var url = { "pathname":this.pathname, - "query":this.query ? Zotero.Server.decodeQueryString(this.query.substr(1)) : {} + "query":this.query ? Zotero.Server.decodeQueryString(this.query.substr(1)) : {}, + "userAgent":m && m[1] }; endpoint.init(url, decodedData, sendResponseCallback); diff --git a/chrome/content/zotero/xpcom/server_connector.js b/chrome/content/zotero/xpcom/server_connector.js @@ -129,7 +129,7 @@ Zotero.Server.Connector.Detect.prototype = { * @param {Object} data POST data or GET query string * @param {Function} sendResponseCallback function to send HTTP response */ - "init":function(data, sendResponseCallback) { + "init":function(url, data, sendResponseCallback) { this.sendResponse = sendResponseCallback; this._parsedPostData = data; @@ -146,7 +146,7 @@ Zotero.Server.Connector.Detect.prototype = { var pageShowCalled = false; var me = this; this._translate.setCookieSandbox(new Zotero.CookieSandbox(this._browser, - this._parsedPostData["uri"], this._parsedPostData["cookie"])); + this._parsedPostData["uri"], this._parsedPostData["cookie"], url.userAgent)); this._browser.addEventListener("DOMContentLoaded", function() { try { if(me._browser.contentDocument.location.href == "about:blank") return; @@ -322,7 +322,7 @@ Zotero.Server.Connector.SaveItem.prototype = { * @param {Object} data POST data or GET query string * @param {Function} sendResponseCallback function to send HTTP response */ - "init":function(data, sendResponseCallback) { + "init":function(url, data, sendResponseCallback) { // figure out where to save var libraryID = null; var collectionID = null; @@ -332,8 +332,8 @@ Zotero.Server.Connector.SaveItem.prototype = { var collection = zp.getSelectedCollection(); } catch(e) {} - var cookieSandbox = data["uri"] && data["cookie"] ? new Zotero.CookieSandbox(null, data["uri"], - data["cookie"]) : null; + var cookieSandbox = data["uri"] ? new Zotero.CookieSandbox(null, data["uri"], + data["cookie"] || "", url.userAgent) : null; for(var i=0; i<data.items.length; i++) { Zotero.Server.Connector.AttachmentProgressManager.add(data.items[i].attachments); } @@ -383,12 +383,12 @@ Zotero.Server.Connector.SaveSnapshot.prototype = { * @param {String} data POST data or GET query string * @param {Function} sendResponseCallback function to send HTTP response */ - "init":function(data, sendResponseCallback) { + "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"]); + 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; diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js @@ -1256,20 +1256,20 @@ Zotero.Sync.Server = new function () { Zotero.Sync.Runner.setSyncStatus(Zotero.getString('sync.status.loggingIn')); Zotero.HTTP.doPost(url, body, function (xmlhttp) { - _checkResponse(xmlhttp); + _checkResponse(xmlhttp, true); var response = xmlhttp.responseXML.childNodes[0]; if (response.firstChild.tagName == 'error') { if (response.firstChild.getAttribute('code') == 'INVALID_LOGIN') { var e = new Zotero.Error(Zotero.getString('sync.error.invalidLogin'), "INVALID_SYNC_LOGIN"); - _error(e); + _error(e, true); } - _error(response.firstChild.firstChild.nodeValue); + _error(response.firstChild.firstChild.nodeValue, true); } if (_sessionID) { - _error("Session ID already set in Zotero.Sync.Server.login()") + _error("Session ID already set in Zotero.Sync.Server.login()", true) } // <response><sessionID>[abcdefg0-9]{32}</sessionID></response> @@ -1278,7 +1278,7 @@ Zotero.Sync.Server = new function () { var re = /^[abcdefg0-9]{32}$/; if (!re.test(_sessionID)) { _sessionID = null; - _error('Invalid session ID received from server'); + _error('Invalid session ID received from server', true); } @@ -1352,7 +1352,7 @@ Zotero.Sync.Server = new function () { Zotero.HTTP.doPost(url, body, function (xmlhttp) { Zotero.debug(xmlhttp.responseText); - _checkResponse(xmlhttp); + _checkResponse(xmlhttp, !restart); if (_invalidSession(xmlhttp)) { Zotero.debug("Invalid session ID -- logging in"); @@ -1772,13 +1772,10 @@ Zotero.Sync.Server = new function () { } - function _checkResponse(xmlhttp) { + function _checkResponse(xmlhttp, noReloadOnFailure) { if (!xmlhttp.responseText) { - // Check SSL cert var channel = xmlhttp.channel; - if (!channel instanceof Ci.nsIChannel) { - _error('No HTTPS channel available'); - } + // Check SSL cert var secInfo = channel.securityInfo; if (secInfo instanceof Ci.nsITransportSecurityInfo) { secInfo.QueryInterface(Ci.nsITransportSecurityInfo); @@ -1794,14 +1791,19 @@ Zotero.Sync.Server = new function () { Zotero.debug(e); } // TODO: localize - _error("SSL certificate error connecting to " + host + "\n\nSee http://zotero.org/support/kb/ssl_certificate_error for more information."); + _error("SSL certificate error connecting to " + host + + "\n\nSee http://zotero.org/support/kb/ssl_certificate_error for more information.", + false, noReloadOnFailure); } else if ((secInfo.securityState & Ci.nsIWebProgressListener.STATE_IS_BROKEN) == Ci.nsIWebProgressListener.STATE_IS_BROKEN) { - _error("SSL connection error"); + _error("SSL connection error", false, noReloadOnFailure); } } // TODO: localize - _error('Empty response from server. Please try again in a few minutes.'); + if (xmlhttp.status === 0) { + _error('Error connecting to server. Check your Internet connection.', false, noReloadOnFailure); + } + _error('Empty response from server. Please try again in a few minutes.', false, noReloadOnFailure); } if (!xmlhttp.responseXML || !xmlhttp.responseXML.childNodes[0] || @@ -1809,7 +1811,7 @@ Zotero.Sync.Server = new function () { !xmlhttp.responseXML.childNodes[0].firstChild) { Zotero.debug(xmlhttp.responseText); // TODO: localize - _error('Invalid response from server. Please try again in a few minutes.', xmlhttp.responseText); + _error('Invalid response from server. Please try again in a few minutes.', xmlhttp.responseText, noReloadOnFailure); } var firstChild = xmlhttp.responseXML.firstChild.firstChild; @@ -1828,7 +1830,7 @@ Zotero.Sync.Server = new function () { else { var timeStr = time.toLocaleString(); } - _error("Auto-syncing disabled until " + timeStr); + _error("Auto-syncing disabled until " + timeStr, false, noReloadOnFailure); } if (firstChild.localName == 'error') { @@ -2244,7 +2246,7 @@ Zotero.Sync.Server = new function () { } - function _error(e, extraInfo) { + function _error(e, extraInfo, skipReload) { if (e.name && e.name == 'ZOTERO_ERROR') { switch (e.error) { case Zotero.Error.ERROR_MISSING_OBJECT: @@ -2337,7 +2339,9 @@ Zotero.Sync.Server = new function () { _syncInProgress = false; Zotero.DB.rollbackAllTransactions(); - Zotero.reloadDataObjects(); + if (!skipReload) { + Zotero.reloadDataObjects(); + } Zotero.Sync.EventListener.resetIgnored(); _callbacks.onError(e); diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js @@ -1376,7 +1376,7 @@ Zotero.Translate.Base.prototype = { "for(var key in this) {"+ "if("+createArrays+".indexOf(key) !== -1) {"+ "for each(var item in this[key]) {"+ - "for(var key2 in item[key2]) {"+ + "for(var key2 in item) {"+ "if(typeof item[key2] === 'xml') {"+ "item[key2] = item[key2].toString();"+ "}"+ diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties @@ -553,6 +553,7 @@ fulltext.indexState.partial = Partial exportOptions.exportNotes = Export Notes exportOptions.exportFileData = Export Files +exportOptions.useJournalAbbreviation = Use Journal Abbreviation charset.UTF8withoutBOM = Unicode (UTF-8 without BOM) charset.autoDetect = (auto detect) diff --git a/chrome/skin/default/zotero/standalone.css b/chrome/skin/default/zotero/standalone.css @@ -1,4 +1,4 @@ #zotero-tb-item-from-page, #zotero-tb-snapshot-from-page, #zotero-tb-link-from-page, -#zotero-tb-fullscreen, #zotero-fullscreen-close-separator { +#zotero-tb-fullscreen, #zotero-fullscreen-close-separator, #zotero-close-button { display: none; } \ No newline at end of file