Use config URL for all repo requests, and move config to separate file

This commit is contained in:
Dan Stillman 2014-12-09 18:37:43 -05:00
parent c28ef6f2d6
commit 3a058c68ed
8 changed files with 31 additions and 25 deletions

View File

@ -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)

View File

@ -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')

View File

@ -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');

View File

@ -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) {

View File

@ -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;

View File

@ -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);
});
}
}

View File

@ -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");

19
resource/config.js Normal file
View File

@ -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"];