diff --git a/clientapp/models/state.js b/clientapp/models/state.js index 233e069..022936e 100644 --- a/clientapp/models/state.js +++ b/clientapp/models/state.js @@ -24,6 +24,16 @@ module.exports = HumanModel.define({ }, true); } + if (navigator.mozApps) { + this.installable = true; + var req = navigator.mozApps.checkInstalled(window.location.origin + '/manifest.webapp'); + req.onsuccess = function (e) { + if (req.result) { + self.installedFirefox = true; + } + }; + } + this.markActive(); }, session: { @@ -35,7 +45,9 @@ module.exports = HumanModel.define({ idleSince: 'date', allowAlerts: ['bool', true, false], badge: ['string', true, ''], - pageTitle: ['string', true, ''] + pageTitle: ['string', true, ''], + installable: ['bool', true, false], + installedFirefox: ['bool', true, false] }, derived: { title: { diff --git a/clientapp/pages/main.js b/clientapp/pages/main.js index 4f5f876..2005e90 100644 --- a/clientapp/pages/main.js +++ b/clientapp/pages/main.js @@ -19,6 +19,7 @@ module.exports = BasePage.extend({ }, events: { 'click .enableAlerts': 'enableAlerts', + 'click .installFirefox': 'installFirefox', 'dragover': 'handleAvatarChangeDragOver', 'drop': 'handleAvatarChange', 'change #uploader': 'handleAvatarChange', @@ -39,6 +40,9 @@ module.exports = BasePage.extend({ } }); }, + installFirefox: function () { + navigator.mozApps.install(window.location.origin + '/manifest.webapp'); + }, handleAvatarChangeDragOver: function (e) { e.preventDefault(); return false; diff --git a/clientapp/template.html b/clientapp/template.html index 327c8bc..6cc52e4 100644 --- a/clientapp/template.html +++ b/clientapp/template.html @@ -11,6 +11,7 @@

Connecting...

+ Cancel
diff --git a/clientapp/templates.js b/clientapp/templates.js index 6d4d341..0c8123c 100644 --- a/clientapp/templates.js +++ b/clientapp/templates.js @@ -178,7 +178,7 @@ exports.pages.groupchat = function anonymous(locals) { exports.pages.main = function anonymous(locals) { var buf = []; with (locals || {}) { - buf.push('

Current status

Change Avatar

Drag and drop a new avatar here

Alerts

'); + buf.push('

Current status

Change Avatar

Drag and drop a new avatar here

Desktop Integration

'); } return buf.join(""); }; diff --git a/clientapp/templates/pages/main.jade b/clientapp/templates/pages/main.jade index 0e229c2..b01e9fd 100644 --- a/clientapp/templates/pages/main.jade +++ b/clientapp/templates/pages/main.jade @@ -13,5 +13,6 @@ section.page.main input#uploader(type="file") div - h3 Alerts + h3 Desktop Integration button.enableAlerts Enable alerts + button.installFirefox Install app diff --git a/public/images/icon_128x128.png b/public/images/icon_128x128.png new file mode 100644 index 0000000..b6d4db3 Binary files /dev/null and b/public/images/icon_128x128.png differ diff --git a/public/manifest.webapp b/public/manifest.webapp new file mode 100644 index 0000000..1d03313 --- /dev/null +++ b/public/manifest.webapp @@ -0,0 +1,7 @@ +{ + "name": "Otalk", + "description": "Modern XMPP client", + "icons": { + "128": "/images/icon_128x128.png" + } +} diff --git a/server.js b/server.js index 972d455..e1e6e48 100644 --- a/server.js +++ b/server.js @@ -54,6 +54,11 @@ app.get('/oauth/callback', function (req, res) { res.render('oauthLogin'); }); +app.get('/manifest.webapp', function (req, res) { + res.set('Content-Type', 'application/x-web-app-manifest+json'); + res.sent(fs.readFileSync('public/manifest.webapp')); +}); + // serves app on every other url app.get('*', clientApp.html());