Skip to content

Improve the default host value #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions _site/js/app.js
Original file line number Diff line number Diff line change
@@ -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" : ["<span class=\'highlight\'>"],"post_tags" : ["</span>"],"fields":{',
elasticResponse: "",
Expand Down Expand Up @@ -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){
Expand Down
2 changes: 0 additions & 2 deletions _site/js/controllers/NavbarCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down