From a21cb49476c0d106e4e683ef14d6576699234ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Gr=C3=BCneberg?= Date: Sun, 25 Jan 2015 00:31:22 -0600 Subject: [PATCH] Add support for URL prefixes. --- _attachments/script/AcralyzerControllers.js | 2 +- _attachments/script/config.js | 1 + _attachments/script/service.reportsstore.js | 16 ++++++++-------- _attachments/script/service.user.js | 10 +++++----- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/_attachments/script/AcralyzerControllers.js b/_attachments/script/AcralyzerControllers.js index f08607a..24a897c 100644 --- a/_attachments/script/AcralyzerControllers.js +++ b/_attachments/script/AcralyzerControllers.js @@ -131,7 +131,7 @@ }; // Check if hosting is Cloudant or older CouchDB version - $http({method : 'GET', url: '/'}).success(function(data){ + $http({method : 'GET', url: acralyzerConfig.urlPrefix + '/'}).success(function(data){ if(data.cloudant_build) { $scope.acralyzer.cloudant = true; acralyzer.cloudant = true; diff --git a/_attachments/script/config.js b/_attachments/script/config.js index c6692d0..48cab4e 100644 --- a/_attachments/script/config.js +++ b/_attachments/script/config.js @@ -5,6 +5,7 @@ acralyzerConfig.backgroundPollingOnStartup = true; acralyzerConfig.appDBPrefix = "acra-"; + acralyzerConfig.urlPrefix = ""; // Helper functions diff --git a/_attachments/script/service.reportsstore.js b/_attachments/script/service.reportsstore.js index fa172d5..3a4b1e3 100644 --- a/_attachments/script/service.reportsstore.js +++ b/_attachments/script/service.reportsstore.js @@ -46,11 +46,11 @@ */ ReportsStore.setApp = function (newAppName, cb) { ReportsStore.dbName = acralyzerConfig.appDBPrefix + newAppName; - ReportsStore.views = $resource('/' + ReportsStore.dbName + '/_design/acra-storage/_view/:view'); - ReportsStore.details = $resource('/' + ReportsStore.dbName + '/:reportid'); - ReportsStore.bug = $resource('/' + ReportsStore.dbName + '/:bugid', { bugid: '@_id' }, { save: {method: 'PUT'}}); - ReportsStore.dbstate = $resource('/' + ReportsStore.dbName + '/'); - ReportsStore.changes = $resource('/' + ReportsStore.dbName + '/_changes'); + ReportsStore.views = $resource(acralyzerConfig.urlPrefix + '/' + ReportsStore.dbName + '/_design/acra-storage/_view/:view'); + ReportsStore.details = $resource(acralyzerConfig.urlPrefix + '/' + ReportsStore.dbName + '/:reportid'); + ReportsStore.bug = $resource(acralyzerConfig.urlPrefix + '/' + ReportsStore.dbName + '/:bugid', { bugid: '@_id' }, { save: {method: 'PUT'}}); + ReportsStore.dbstate = $resource(acralyzerConfig.urlPrefix + '/' + ReportsStore.dbName + '/'); + ReportsStore.changes = $resource(acralyzerConfig.urlPrefix + '/' + ReportsStore.dbName + '/_changes'); ReportsStore.lastseq = -1; cb(); }; @@ -71,7 +71,7 @@ } cb(finalData); }; - $http.get('/_all_dbs').success(filterDbsCallback).error(errorHandler); + $http.get(acralyzerConfig.urlPrefix + '/_all_dbs').success(filterDbsCallback).error(errorHandler); }; /** @@ -353,7 +353,7 @@ console.log(doc); } console.log("Deleting " + docsToPurge.length + "reports."); - $http.post("/" + ReportsStore.dbName + "/_bulk_docs", { docs: docsToPurge }) + $http.post(acralyzerConfig.urlPrefix + "/" + ReportsStore.dbName + "/_bulk_docs", { docs: docsToPurge }) .success(finalCallback); }; @@ -391,7 +391,7 @@ console.log(doc); } console.log("Deleting " + docsToPurge.length + "reports."); - $http.post("/" + ReportsStore.dbName + "/_bulk_docs", { docs: docsToPurge }) + $http.post(acralyzerConfig.urlPrefix + "/" + ReportsStore.dbName + "/_bulk_docs", { docs: docsToPurge }) .success(finalCallback); }; diff --git a/_attachments/script/service.user.js b/_attachments/script/service.user.js index f736fd8..fdefcc0 100644 --- a/_attachments/script/service.user.js +++ b/_attachments/script/service.user.js @@ -26,7 +26,7 @@ * @static */ acralyzer.service('$user', ['$rootScope', '$q', '$resource', '$http', function($rootScope, $q, $resource, $http) { - var SessionResource = $resource('/_session'); + var SessionResource = $resource(acralyzerConfig.urlPrefix + '/_session'); var UserResource; var acralyzerDbName = location.pathname.split("/")[1]; var PreferencesResource = $resource("/" + acralyzerDbName + "/org.couchdb.user\\::name", @@ -120,7 +120,7 @@ /* Does this box support changing admin passwords */ if ($user.username && $user.isAdmin && _hasAdminPath === undefined) { - $http.get('/_config/admins/' + $user.username) + $http.get(acralyzerConfig + '/_config/admins/' + $user.username) .success(function(data, status, headers, config) { if (data.match(/^"-hashed-/)) { _hasAdminPath = true; @@ -154,7 +154,7 @@ var newSession = new SessionResource(data); */ var _newSessionPromise = $http.post( - '/_session', + acralyzerConfig.urlPrefix + '/_session', $.param(data), { headers: { @@ -193,7 +193,7 @@ } if ($user.isAdmin && _hasAdminPath === true) { - $http.put('/_config/admins/'+$user.username, JSON.stringify(password)) + $http.put(acralyzerConfig.urlPrefix + '/_config/admins/'+$user.username, JSON.stringify(password)) .success(function() { $user.logout(); deferred.resolve(); @@ -330,7 +330,7 @@ $http( { method: 'PUT', - url: '/_users/org.couchdb.user:' + login, + url: acralyzerConfig.urlPrefix + '/_users/org.couchdb.user:' + login, data: userData } ).success(