diff --git a/_site/js/app.js b/_site/js/app.js index 12c2c04..5b4f819 100644 --- a/_site/js/app.js +++ b/_site/js/app.js @@ -1,6 +1,25 @@ angular.module('inquisitor.service', []) .value('Data', { - host: "http://localhost:9200", + host: (function () { + // Allow specifying the ES URL in the query string + try { + var searchParams = (new URL(location)).searchParams; + var url = searchParams.get("url"); + + if (null !== url) { + return url; + } + } catch (e) { + // If there is no support for URL in this browser, skip support for the query string + } + + // Use the ES host when running as a site plugin + if (location.href.indexOf("/_plugin/") !== -1) { + return location.protocol + "//" + location.host; + } + + return "http://localhost:9200"; + })(), query:'{"query" : {"match_all": {}}}', highlight: '"highlight":{"order" : "score", "pre_tags" : [""],"post_tags" : [""],"fields":{', elasticResponse: "", @@ -38,21 +57,21 @@ var app = angular.module('Inquisitor', ['inquisitor.service', 'ui.bootstrap', 'u app.factory('pubsub', function(){ var cache = {}; return { - publish: function(topic, args) { + publish: function(topic, args) { cache[topic] && $.each(cache[topic], function() { this.call(null, args || []); }); }, - + subscribe: function(topic, callback) { if(!cache[topic]) { cache[topic] = []; } - + cache[topic].push(callback); - return [topic, callback]; + return [topic, callback]; }, - + unsubscribe: function(handle) { var t = handle[0]; cache[t] && d.each(cache[t], function(idx){ diff --git a/_site/js/controllers/NavbarCtrl.js b/_site/js/controllers/NavbarCtrl.js index d20a74c..9949218 100644 --- a/_site/js/controllers/NavbarCtrl.js +++ b/_site/js/controllers/NavbarCtrl.js @@ -2,8 +2,6 @@ function NavbarCtrl($scope, $rootScope, $route, $location, Data) { $scope.data = Data; - $scope.data.host = window.location.protocol + '//' + window.location.host; - $scope.isActive = function(route) { var path = $location.path();