[kibana] use relative paths on the front-end, and basePath on the back-end

This commit is contained in:
spalger 2015-11-05 13:48:41 -06:00
parent 66535c4dcf
commit 0ed8889de1
12 changed files with 32 additions and 15 deletions

View file

@ -16,6 +16,7 @@ let babelExclude = [/[\/\\](webpackShims|node_modules|bower_components)[\/\\]/];
class BaseOptimizer {
constructor(opts) {
this.env = opts.env;
this.urlBasePath = opts.urlBasePath;
this.bundles = opts.bundles;
this.profile = opts.profile || false;
@ -74,7 +75,7 @@ class BaseOptimizer {
path: this.env.workingDir,
filename: '[name].bundle.js',
sourceMapFilename: '[file].map',
publicPath: '/bundles/',
publicPath: this.urlBasePath + '/bundles/',
devtoolModuleFilenameTemplate: '[absolute-resource-path]'
},

View file

@ -38,6 +38,7 @@ module.exports = async (kbnServer, server, config) => {
env: bundles.env,
bundles: bundles,
profile: config.get('optimize.profile'),
urlBasePath: config.get('server.basePath'),
sourceMaps: config.get('optimize.sourceMaps'),
unsafeCache: config.get('optimize.unsafeCache'),
});

View file

@ -15,6 +15,7 @@ module.exports = async (kbnServer, kibanaHapiServer, config) => {
profile: config.get('optimize.profile'),
sourceMaps: config.get('optimize.sourceMaps'),
prebuild: config.get('optimize.lazyPrebuild'),
urlBasePath: config.get('server.basePath'),
unsafeCache: config.get('optimize.unsafeCache'),
})
);

View file

@ -2,7 +2,7 @@
<div class="kbn-settings-about container" ng-controller="settingsAbout">
<div class="col-md-4 col-md-offset-4 jumbotron">
<center>
<img src='/plugins/kibana/settings/sections/about/barcode.svg' alt="Kibana Barcode Logo" width="128" height="128"><br>
<img src='../plugins/kibana/settings/sections/about/barcode.svg' alt="Kibana Barcode Logo" width="128" height="128"><br>
<h1>Kibana</h1>
<p>
<table class="table table-condensed kbn-settings-about-versions">

View file

@ -5,6 +5,6 @@ define(function (require) {
order: 3,
name: 'status',
display: 'Status',
url: '/status'
url: '../status'
};
});

View file

@ -23,7 +23,7 @@ require('ui/chrome')
// go ahead and get the info you want
return $http
.get('/api/status')
.get('./api/status')
.then(function (resp) {
if (ui.fetchError) {

View file

@ -19,7 +19,7 @@ class UiApp {
this.hidden = this.spec.hidden;
this.autoloadOverrides = this.spec.autoload;
this.templateName = this.spec.templateName || 'uiApp';
this.url = this.spec.url || '/app/' + this.id;
this.url = (spec.urlBasePath || '') + (this.spec.url || '/app/' + this.id);
// once this resolves, no reason to run it again
this.getModules = _.once(this.getModules);

View file

@ -4,9 +4,10 @@ var minimatch = require('minimatch');
var UiAppCollection = require('./UiAppCollection');
class UiExports {
constructor(kbnServer) {
constructor({ urlBasePath }) {
this.apps = new UiAppCollection(this);
this.aliases = {};
this.urlBasePath = urlBasePath;
this.exportConsumer = _.memoize(this.exportConsumer);
this.consumers = [];
this.bundleProviders = [];
@ -48,7 +49,10 @@ class UiExports {
case 'apps':
return (plugin, specs) => {
for (let spec of [].concat(specs || [])) {
let app = this.apps.new(_.defaults({}, spec, { id: plugin.id }));
let app = this.apps.new(_.defaults({}, spec, {
id: plugin.id,
urlBasePath: this.urlBasePath
}));
plugin.apps.add(app);
}
};

View file

@ -12,10 +12,13 @@ module.exports = async (kbnServer, server, config) => {
let UiBundlerEnv = require('./UiBundlerEnv');
let loadingGif = readFile(fromRoot('src/ui/public/loading.gif'), { encoding: 'base64'});
let uiExports = kbnServer.uiExports = new UiExports(kbnServer);
let uiExports = kbnServer.uiExports = new UiExports({
urlBasePath: config.get('server.basePath')
});
let bundlerEnv = new UiBundlerEnv(config.get('optimize.bundleDir'));
bundlerEnv.addContext('env', config.get('env.name'));
bundlerEnv.addContext('urlBasePath', config.get('server.basePath'));
bundlerEnv.addContext('sourceMaps', config.get('optimize.sourceMaps'));
bundlerEnv.addContext('kbnVersion', config.get('pkg.version'));
bundlerEnv.addContext('buildNum', config.get('pkg.buildNum'));
@ -72,13 +75,15 @@ module.exports = async (kbnServer, server, config) => {
version: kbnServer.version,
buildNum: config.get('pkg.buildNum'),
buildSha: config.get('pkg.buildSha'),
basePath: config.get('server.basePath'),
vars: defaults(app.getInjectedVars(), defaultInjectedVars),
};
return this.view(app.templateName, {
app: app,
loadingGif: loadingGif,
kibanaPayload: payload
kibanaPayload: payload,
bundlePath: config.get('server.basePath') + '/bundles',
});
});
};

View file

@ -21,7 +21,7 @@ module.exports = function (chrome, internals) {
.value('sessionId', Date.now())
.value('esUrl', (function () {
var a = document.createElement('a');
a.href = '/elasticsearch';
a.href = '../elasticsearch';
return a.href;
}()))
.directive('kbnChrome', function ($rootScope) {

View file

@ -9,7 +9,6 @@ require('ui/private');
require('ui/promises');
var metadata = require('ui/metadata');
var TabCollection = require('ui/chrome/TabCollection');
var chrome = {};
var internals = _.defaults(

View file

@ -38,11 +38,17 @@ block content
loading.removeChild(loading.lastChild);
}
function bundleFile(filename) {
var anchor = document.createElement('a');
anchor.setAttribute('href', !{JSON.stringify(bundlePath)} + '/' + filename);
return anchor.href;
}
var files = [
'/bundles/commons.style.css',
'/bundles/#{app.id}.style.css',
'/bundles/commons.bundle.js',
'/bundles/#{app.id}.bundle.js'
bundleFile('commons.style.css'),
bundleFile('#{app.id}.style.css'),
bundleFile('commons.bundle.js'),
bundleFile('#{app.id}.bundle.js')
];
(function next() {