Added ability to configure HTTP route prefixes.

This commit is contained in:
Braydon Fuller 2015-10-13 10:49:44 -04:00
parent fb43ff70d4
commit c45a0edd60
2 changed files with 16 additions and 5 deletions

View File

@ -6,6 +6,13 @@ var fs = require('fs');
var InsightUI = function(options) { var InsightUI = function(options) {
BaseService.call(this, options); BaseService.call(this, options);
this.routePrefix = options.routePrefix;
if (typeof options.apiPrefix !== 'undefined') {
this.apiPrefix = options.apiPrefix;
} else {
this.apiPrefix = 'insight-api';
}
}; };
InsightUI.dependencies = ['insight-api']; InsightUI.dependencies = ['insight-api'];
@ -18,7 +25,11 @@ InsightUI.prototype.start = function(callback) {
}; };
InsightUI.prototype.getRoutePrefix = function() { InsightUI.prototype.getRoutePrefix = function() {
return 'insight'; if (typeof this.routePrefix !== 'undefined') {
return this.routePrefix;
} else {
return 'insight';
}
}; };
InsightUI.prototype.setupRoutes = function(app, express) { InsightUI.prototype.setupRoutes = function(app, express) {
@ -38,8 +49,8 @@ InsightUI.prototype.setupRoutes = function(app, express) {
InsightUI.prototype.filterIndexHTML = function(data) { InsightUI.prototype.filterIndexHTML = function(data) {
var transformed = data var transformed = data
.replace(/<base href=\"\/\"/, '<base href="/insight/"') .replace(/<base href=\"\/\"/, '<base href="/"')
.replace(/apiPrefix = '\/api'/, "apiPrefix = '/insight-api'"); .replace(/apiPrefix = '\/api'/, "apiPrefix = '/" + this.apiPrefix + "'");
return transformed; return transformed;
}; };

View File

@ -7,7 +7,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="insight navbar-brand" href="/insight">insight</a> <a class="insight navbar-brand" href=".">insight</a>
</div> </div>
<div class="navbar-collapse collapse" collapse="$root.isCollapsed"> <div class="navbar-collapse collapse" collapse="$root.isCollapsed">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">