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.
This commit is contained in:
Felix Eckhofer 2014-02-22 13:45:36 +01:00
parent efda3d4963
commit fa01c0a53f

View file

@ -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