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
1 changed files with 4 additions and 1 deletions

View File

@ -788,7 +788,10 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}; };
$scope.install = function() { $scope.install = function() {
if (navigator.mozApps !== undefined) { 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 () { request.onsuccess = function () {
$scope.isinstalled = true; $scope.isinstalled = true;
// Save the App object that is returned // Save the App object that is returned