From fa01c0a53fef0da3c350fc7de3a62ac828502aff Mon Sep 17 00:00:00 2001 From: Felix Eckhofer Date: Sat, 22 Feb 2014 13:45:36 +0100 Subject: [PATCH] Install Firefox Webapp from local checkout Ask Firefox to install the currently running copy of glowing bear instead of the copy from torhve.github.io This also fixes a bug when glowing bear is not running from a subdirectory (or one other than /glowing-bear) which would lead to a 404 because of torhve.github.io/original_subdir being loaded instead of /glowing-bear. Note that installing to a different subdirectory than /glowing-bear will lead to the icons not being found due to the fact that all icon paths inside manifest.webapp have to be absolute. --- js/glowingbear.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 55ef11d..477d0ce 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -788,7 +788,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', }; $scope.install = function() { if (navigator.mozApps !== undefined) { - var request = navigator.mozApps.install('http://torhve.github.io/glowing-bear/manifest.webapp'); + // Find absolute url with trailing '/' or '/index.html' removed + var base_url = location.protocol + '//' + location.host + + location.pathname.replace(/\/(index\.html)?$/, ''); + var request = navigator.mozApps.install(base_url + '/manifest.webapp'); request.onsuccess = function () { $scope.isinstalled = true; // Save the App object that is returned