commit 3a058c68ed8a4584c7de6724e7dcdf44b319148d
parent c28ef6f2d61031e517004fc9730d7d103a2673a8
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 9 Dec 2014 18:37:43 -0500
Use config URL for all repo requests, and move config to separate file
Diffstat:
8 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/chrome/content/zotero/errorReport.xul b/chrome/content/zotero/errorReport.xul
@@ -11,6 +11,8 @@
<script>
<![CDATA[
+ Components.utils.import("resource://zotero/config.js");
+
var Zotero_Error_Report = new function() {
this.init = init;
this.sendErrorReport = sendErrorReport;
@@ -74,7 +76,7 @@
body += key + '=' + encodeURIComponent(parts[key]) + '&';
}
body = body.substr(0, body.length - 1);
- var url = 'https://repo.zotero.org/repo/report';
+ var url = ZOTERO_CONFIG.REPOSITORY_URL + "report";
Zotero.HTTP.promise('POST', url,
{ body: body, successCodes: false, foreground: true })
.then(_sendErrorReportCallback)
diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js
@@ -624,7 +624,9 @@ Zotero_Preferences.Debug_Output = {
document.getElementById('debug-output-submit').disabled = true;
document.getElementById('debug-output-submit-progress').hidden = false;
- var url = "https://repo.zotero.org/repo/report?debug=1";
+ Components.utils.import("resource://zotero/config.js");
+
+ var url = ZOTERO_CONFIG.REPOSITORY_URL + "report?debug=1";
var output = Zotero.Debug.get(
Zotero.Prefs.get('debug.store.submitSize'),
Zotero.Prefs.get('debug.store.submitLineLength')
diff --git a/chrome/content/zotero/xpcom/connector/connector.js b/chrome/content/zotero/xpcom/connector/connector.js
@@ -245,7 +245,7 @@ Zotero.Connector_Debug = new function() {
* Submit data to the sserver
*/
this.submitReport = function(callback) {
- Zotero.HTTP.doPost("http://www.zotero.org/repo/report?debug=1", Zotero.Debug.get(),
+ Zotero.HTTP.doPost(ZOTERO_CONFIG.REPOSITORY_URL + "report?debug=1", Zotero.Debug.get(),
function(xmlhttp) {
if (!xmlhttp.responseXML) {
callback(false, 'Invalid response from server');
diff --git a/chrome/content/zotero/xpcom/connector/repo.js b/chrome/content/zotero/xpcom/connector/repo.js
@@ -66,7 +66,7 @@ Zotero.Repo = new function() {
}
// then try repo
- Zotero.HTTP.doGet(ZOTERO_CONFIG.REPOSITORY_URL+"/code/"+translatorID+"?version="+Zotero.version,
+ Zotero.HTTP.doGet(ZOTERO_CONFIG.REPOSITORY_URL + "code/" + translatorID + "?version=" + Zotero.version,
function(xmlhttp) {
_haveCode(xmlhttp.status === 200 ? xmlhttp.responseText : false, translatorID,
Zotero.Repo.SOURCE_REPO, callback);
@@ -137,7 +137,7 @@ Zotero.Repo = new function() {
* Retrieve metadata from repository
*/
function _updateFromRepo(reset, callback) {
- var url = ZOTERO_CONFIG.REPOSITORY_URL+"/metadata?version="+Zotero.version+"&last="+
+ var url = ZOTERO_CONFIG.REPOSITORY_URL + "metadata?version=" + Zotero.version + "&last="+
(reset ? "0" : Zotero.Prefs.get("connector.repo.lastCheck.repoTime"));
Zotero.HTTP.doGet(url, function(xmlhttp) {
diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js
@@ -1023,7 +1023,7 @@ Zotero.Schema = new function(){
// Get the last timestamp we got from the server
var lastUpdated = this.getDBVersion('repository');
- var url = ZOTERO_CONFIG['REPOSITORY_URL'] + '/updated?'
+ var url = ZOTERO_CONFIG.REPOSITORY_URL + 'updated?'
+ (lastUpdated ? 'last=' + lastUpdated + '&' : '')
+ 'version=' + Zotero.version;
diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js
@@ -1877,7 +1877,7 @@ Zotero.Translate.Web.prototype.complete = function(returnValue, error) {
"&lastUpdated=" + encodeURIComponent(translator.lastUpdated) +
"&diagnostic=" + encodeURIComponent(info) +
"&errorData=" + encodeURIComponent(errorString);
- Zotero.HTTP.doPost("http://www.zotero.org/repo/report", postBody);
+ Zotero.HTTP.doPost(ZOTERO_CONFIG.REPOSITORY_URL + "report", postBody);
});
}
}
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -23,25 +23,8 @@
***** END LICENSE BLOCK *****
*/
-const ZOTERO_CONFIG = {
- GUID: 'zotero@chnm.gmu.edu',
- REPOSITORY_URL: 'https://repo.zotero.org/repo',
- REPOSITORY_CHECK_INTERVAL: 86400, // 24 hours
- REPOSITORY_RETRY_INTERVAL: 3600, // 1 hour
- BASE_URI: 'http://zotero.org/',
- WWW_BASE_URL: 'http://www.zotero.org/',
- PROXY_AUTH_URL: 'https://s3.amazonaws.com/zotero.org/proxy-auth',
- SYNC_URL: 'https://sync.zotero.org/',
- API_URL: 'https://api.zotero.org/',
- API_VERSION: 2,
- PREF_BRANCH: 'extensions.zotero.',
- BOOKMARKLET_ORIGIN : 'https://www.zotero.org',
- HTTP_BOOKMARKLET_ORIGIN : 'http://www.zotero.org',
- BOOKMARKLET_URL: 'https://www.zotero.org/bookmarklet/',
- VERSION: "4.0.24.1.SOURCE"
-};
-
// Commonly used imports accessible anywhere
+Components.utils.import("resource://zotero/config.js");
Components.utils.import("resource://zotero/q.js");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
diff --git a/resource/config.js b/resource/config.js
@@ -0,0 +1,19 @@
+var ZOTERO_CONFIG = {
+ GUID: 'zotero@chnm.gmu.edu',
+ REPOSITORY_URL: 'https://repo.zotero.org/repo/',
+ REPOSITORY_CHECK_INTERVAL: 86400, // 24 hours
+ REPOSITORY_RETRY_INTERVAL: 3600, // 1 hour
+ BASE_URI: 'http://zotero.org/',
+ WWW_BASE_URL: 'http://www.zotero.org/',
+ PROXY_AUTH_URL: 'https://s3.amazonaws.com/zotero.org/proxy-auth',
+ SYNC_URL: 'https://sync.zotero.org/',
+ API_URL: 'https://api.zotero.org/',
+ API_VERSION: 2,
+ PREF_BRANCH: 'extensions.zotero.',
+ BOOKMARKLET_ORIGIN: 'https://www.zotero.org',
+ HTTP_BOOKMARKLET_ORIGIN: 'http://www.zotero.org',
+ BOOKMARKLET_URL: 'https://www.zotero.org/bookmarklet/',
+ VERSION: '4.0.24.1.SOURCE'
+};
+
+EXPORTED_SYMBOLS = ["ZOTERO_CONFIG"];