mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-22 01:02:23 -05:00
Use Stanza.io 6.10.2
This commit is contained in:
parent
735b9ca08f
commit
edc7151987
@ -2,8 +2,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
var async = require('async');
|
|
||||||
var Backbone = require('backbone');
|
var Backbone = require('backbone');
|
||||||
|
Backbone.$ = $;
|
||||||
|
var async = require('async');
|
||||||
var StanzaIO = require('stanza.io');
|
var StanzaIO = require('stanza.io');
|
||||||
|
|
||||||
var AppState = require('./models/state');
|
var AppState = require('./models/state');
|
||||||
@ -17,16 +18,16 @@ var Notify = require('notify.js');
|
|||||||
var Desktop = require('./helpers/desktop');
|
var Desktop = require('./helpers/desktop');
|
||||||
var AppCache = require('./helpers/cache');
|
var AppCache = require('./helpers/cache');
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
launch: function () {
|
launch: function () {
|
||||||
|
|
||||||
var self = window.app = this;
|
var self = window.app = this;
|
||||||
var config = localStorage.config;
|
var config = localStorage.config;
|
||||||
|
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
console.log('missing config');
|
console.log('missing config');
|
||||||
window.location = '/login';
|
window.location = '/login';
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
config = JSON.parse(config);
|
config = JSON.parse(config);
|
||||||
@ -128,5 +129,6 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$(function () {
|
||||||
module.exports.launch();
|
module.exports.launch();
|
||||||
|
});
|
||||||
|
@ -32,7 +32,6 @@ module.exports = function (jid, id, type, source, cb) {
|
|||||||
return cb(fallback(jid));
|
return cb(fallback(jid));
|
||||||
}
|
}
|
||||||
|
|
||||||
resp = resp.toJSON();
|
|
||||||
type = resp.vCardTemp.photo.type || type;
|
type = resp.vCardTemp.photo.type || type;
|
||||||
|
|
||||||
var data = resp.vCardTemp.photo.data;
|
var data = resp.vCardTemp.photo.data;
|
||||||
@ -53,7 +52,6 @@ module.exports = function (jid, id, type, source, cb) {
|
|||||||
return cb(fallback(jid));
|
return cb(fallback(jid));
|
||||||
}
|
}
|
||||||
|
|
||||||
resp = resp.toJSON();
|
|
||||||
var data = resp.pubsub.retrieve.item.avatarData;
|
var data = resp.pubsub.retrieve.item.avatarData;
|
||||||
var uri = 'data:' + type + ';base64,' + data;
|
var uri = 'data:' + type + ';base64,' + data;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ var discoCapsQueue = async.queue(function (pres, cb) {
|
|||||||
}
|
}
|
||||||
if (client.verifyVerString(result.discoInfo, caps.hash, caps.ver)) {
|
if (client.verifyVerString(result.discoInfo, caps.hash, caps.ver)) {
|
||||||
log.info('Saving info for ' + caps.ver);
|
log.info('Saving info for ' + caps.ver);
|
||||||
var data = result.discoInfo.toJSON();
|
var data = result.discoInfo;
|
||||||
app.storage.disco.add(caps.ver, data, function () {
|
app.storage.disco.add(caps.ver, data, function () {
|
||||||
if (resource) resource.discoInfo = data;
|
if (resource) resource.discoInfo = data;
|
||||||
cb();
|
cb();
|
||||||
@ -112,8 +112,6 @@ module.exports = function (client, app) {
|
|||||||
window.readyForDeviceID = true;
|
window.readyForDeviceID = true;
|
||||||
|
|
||||||
client.getRoster(function (err, resp) {
|
client.getRoster(function (err, resp) {
|
||||||
resp = resp.toJSON();
|
|
||||||
|
|
||||||
if (resp.roster && resp.roster.items && resp.roster.items.length) {
|
if (resp.roster && resp.roster.items && resp.roster.items.length) {
|
||||||
app.storage.roster.clear(function () {
|
app.storage.roster.clear(function () {
|
||||||
me.contacts.reset();
|
me.contacts.reset();
|
||||||
@ -143,7 +141,6 @@ module.exports = function (client, app) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on('roster:update', function (iq) {
|
client.on('roster:update', function (iq) {
|
||||||
iq = iq.toJSON();
|
|
||||||
var items = iq.roster.items;
|
var items = iq.roster.items;
|
||||||
|
|
||||||
me.rosterVer = iq.roster.ver;
|
me.rosterVer = iq.roster.ver;
|
||||||
@ -169,7 +166,6 @@ module.exports = function (client, app) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on('available', function (pres) {
|
client.on('available', function (pres) {
|
||||||
pres = pres.toJSON();
|
|
||||||
var contact = me.getContact(pres.from);
|
var contact = me.getContact(pres.from);
|
||||||
if (contact) {
|
if (contact) {
|
||||||
delete pres.id;
|
delete pres.id;
|
||||||
@ -206,7 +202,6 @@ module.exports = function (client, app) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on('unavailable', function (pres) {
|
client.on('unavailable', function (pres) {
|
||||||
pres = pres.toJSON();
|
|
||||||
var contact = me.getContact(pres.from);
|
var contact = me.getContact(pres.from);
|
||||||
if (contact) {
|
if (contact) {
|
||||||
var resource = contact.resources.get(pres.from.full);
|
var resource = contact.resources.get(pres.from.full);
|
||||||
@ -273,7 +268,6 @@ module.exports = function (client, app) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on('chat', function (msg) {
|
client.on('chat', function (msg) {
|
||||||
msg = msg.toJSON();
|
|
||||||
msg.mid = msg.id;
|
msg.mid = msg.id;
|
||||||
delete msg.id;
|
delete msg.id;
|
||||||
|
|
||||||
@ -298,7 +292,6 @@ module.exports = function (client, app) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on('groupchat', function (msg) {
|
client.on('groupchat', function (msg) {
|
||||||
msg = msg.toJSON();
|
|
||||||
msg.mid = msg.id;
|
msg.mid = msg.id;
|
||||||
delete msg.id;
|
delete msg.id;
|
||||||
|
|
||||||
@ -318,7 +311,6 @@ module.exports = function (client, app) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on('replace', function (msg) {
|
client.on('replace', function (msg) {
|
||||||
msg = msg.toJSON();
|
|
||||||
msg.mid = msg.id;
|
msg.mid = msg.id;
|
||||||
delete msg.id;
|
delete msg.id;
|
||||||
|
|
||||||
@ -333,8 +325,6 @@ module.exports = function (client, app) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
client.on('receipt', function (msg) {
|
client.on('receipt', function (msg) {
|
||||||
msg = msg.toJSON();
|
|
||||||
|
|
||||||
var contact = me.getContact(msg.from, msg.to);
|
var contact = me.getContact(msg.from, msg.to);
|
||||||
if (!contact) return;
|
if (!contact) return;
|
||||||
|
|
||||||
|
8
clientapp/libraries/jquery.js
vendored
8
clientapp/libraries/jquery.js
vendored
File diff suppressed because one or more lines are too long
@ -313,7 +313,6 @@ module.exports = HumanModel.define({
|
|||||||
var results = res.mamQuery.results || [];
|
var results = res.mamQuery.results || [];
|
||||||
results.reverse();
|
results.reverse();
|
||||||
results.forEach(function (result) {
|
results.forEach(function (result) {
|
||||||
result = result.toJSON();
|
|
||||||
var msg = result.mam.forwarded.message;
|
var msg = result.mam.forwarded.message;
|
||||||
|
|
||||||
msg.mid = msg.id;
|
msg.mid = msg.id;
|
||||||
|
@ -115,7 +115,7 @@ module.exports = HumanModel.define({
|
|||||||
app.whenConnected(function () {
|
app.whenConnected(function () {
|
||||||
client.getDiscoInfo(self.id, '', function (err, res) {
|
client.getDiscoInfo(self.id, '', function (err, res) {
|
||||||
if (err) return;
|
if (err) return;
|
||||||
self.discoInfo = res.discoInfo.toJSON();
|
self.discoInfo = res.discoInfo;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -211,16 +211,17 @@ module.exports = BasePage.extend({
|
|||||||
this.$('button.call').prop('disabled', !resources.length);
|
this.$('button.call').prop('disabled', !resources.length);
|
||||||
},
|
},
|
||||||
appendModel: function (model, preload) {
|
appendModel: function (model, preload) {
|
||||||
var newEl, first, last;
|
var newEl, first, last, newDay = false;
|
||||||
|
|
||||||
var messageDay = Date.create(model.timestamp).format('{month} {ord}, {yyyy}');
|
var messageDay = Date.create(model.timestamp).format('{month} {ord}, {yyyy}');
|
||||||
if (messageDay !== this.lastDate) {
|
if (messageDay !== this.lastDate) {
|
||||||
var dayDivider = $(templates.includes.dayDivider({day_name: messageDay}));
|
var dayDivider = $(templates.includes.dayDivider({day_name: messageDay}));
|
||||||
this.staydown.append(dayDivider[0]);
|
this.staydown.append(dayDivider[0]);
|
||||||
this.lastDate = messageDay;
|
this.lastDate = messageDay;
|
||||||
|
newDay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isGrouped = model.shouldGroupWith(this.lastModel);
|
var isGrouped = !newDay && model.shouldGroupWith(this.lastModel);
|
||||||
if (isGrouped) {
|
if (isGrouped) {
|
||||||
newEl = $(model.partialTemplateHtml);
|
newEl = $(model.partialTemplateHtml);
|
||||||
last = this.$messageList.find('li').last();
|
last = this.$messageList.find('li').last();
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,17 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html manifest="/manifest.cache">
|
|
||||||
<head>
|
|
||||||
<title>Otalk</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="#{cssFileName}" />
|
|
||||||
<script src="#{jsFileName}"></script>
|
|
||||||
</head>
|
|
||||||
<body class="aux">
|
|
||||||
<header>
|
|
||||||
<img id="logo" src="/images/logo.png" alt="Otalk" />
|
|
||||||
</header>
|
|
||||||
<section class="box connect">
|
|
||||||
<h2>Connecting...</h2>
|
|
||||||
<a class="button secondary" href="/logout">Cancel</a>
|
|
||||||
</section>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
32
package.json
32
package.json
@ -1,41 +1,43 @@
|
|||||||
{
|
{
|
||||||
"name": "otalk.im",
|
"name": "otalk.im",
|
||||||
"description": "Otalk: WebRTC Enabled XMPP Client, in the Browser",
|
"description": "Otalk: WebRTC Enabled XMPP Client, in the Browser",
|
||||||
"version": "0.0.40",
|
"version": "0.0.50",
|
||||||
"browser": {
|
"browser": {
|
||||||
"crypto": "crypto-browserify"
|
"crypto": "crypto-browserify"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"andlog": "0.0.4",
|
"andlog": "0.0.4",
|
||||||
"async": "0.2.9",
|
"async": "^0.9.0",
|
||||||
"attachmediastream": "1.0.1",
|
"attachmediastream": "1.0.1",
|
||||||
"backbone": "1.0.0",
|
"backbone": "1.0.0",
|
||||||
"bluebird": "1.0.0",
|
"bluebird": "^2.3.2",
|
||||||
"bows": "0.3.0",
|
"bows": "0.3.0",
|
||||||
"browserify": "2.25.1",
|
"browserify": "4.x",
|
||||||
"crypto-browserify": "1.0.3",
|
"compression": "1.2.2",
|
||||||
"express": "3.3.7",
|
"crypto-browserify": "",
|
||||||
|
"express": "4.10.6",
|
||||||
"getconfig": "0.0.5",
|
"getconfig": "0.0.5",
|
||||||
"getusermedia": "0.2.1",
|
"getusermedia": "0.2.1",
|
||||||
"helmet": "0.1.0",
|
"helmet": "0.1.0",
|
||||||
"human-model": "2.6.0",
|
"human-model": "2.6.0",
|
||||||
"human-view": "1.5.0",
|
"human-view": "1.8.0",
|
||||||
"jade": "0.35.0",
|
"jade": "1.8.2",
|
||||||
"jxt": "0.6.0",
|
"jxt": "^2.6.1",
|
||||||
"moonboots": "1.0.0",
|
"moonboots-express": "2.x",
|
||||||
"node-uuid": "1.4.1",
|
"node-uuid": "^1.4.1",
|
||||||
"notify.js": "0.0.3",
|
"notify.js": "0.0.3",
|
||||||
"oembed": "0.1.0",
|
"oembed": "0.1.0",
|
||||||
"semi-static": "0.0.4",
|
"semi-static": "0.0.4",
|
||||||
|
"serve-static": "1.7.1",
|
||||||
"sound-effect-manager": "0.0.5",
|
"sound-effect-manager": "0.0.5",
|
||||||
"stanza.io": "3.6.x",
|
"stanza.io": "6.10.2",
|
||||||
"staydown": "1.0.3",
|
"staydown": "1.0.3",
|
||||||
"templatizer": "0.1.2",
|
"templatizer": "0.1.2",
|
||||||
"underscore": "1.5.1",
|
"underscore": "1.6.0",
|
||||||
"wildemitter": "1.0.1"
|
"wildemitter": "^1.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"precommit-hook": "0.3.6"
|
"precommit-hook": "^1.0.2"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
|
119
server.js
119
server.js
@ -2,17 +2,18 @@ var fs = require('fs');
|
|||||||
var https = require('https');
|
var https = require('https');
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
var helmet = require('helmet');
|
var helmet = require('helmet');
|
||||||
var Moonboots = require('moonboots');
|
var Moonboots = require('moonboots-express');
|
||||||
var config = require('getconfig');
|
var config = require('getconfig');
|
||||||
var templatizer = require('templatizer');
|
var templatizer = require('templatizer');
|
||||||
var oembed = require('oembed');
|
var oembed = require('oembed');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
|
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
|
var compression = require('compression');
|
||||||
|
var serveStatic = require('serve-static');
|
||||||
|
|
||||||
app.use(express.compress());
|
app.use(compression());
|
||||||
app.use(express.static(__dirname + '/public'));
|
app.use(serveStatic(__dirname + '/public'));
|
||||||
if (!config.isDev) {
|
if (!config.isDev) {
|
||||||
app.use(helmet.xframe());
|
app.use(helmet.xframe());
|
||||||
}
|
}
|
||||||
@ -22,58 +23,9 @@ app.use(helmet.contentTypeOptions());
|
|||||||
oembed.EMBEDLY_URL = config.embedly.url || 'https://api.embed.ly/1/oembed';
|
oembed.EMBEDLY_URL = config.embedly.url || 'https://api.embed.ly/1/oembed';
|
||||||
oembed.EMBEDLY_KEY = config.embedly.key;
|
oembed.EMBEDLY_KEY = config.embedly.key;
|
||||||
|
|
||||||
var clientApp = new Moonboots({
|
|
||||||
main: __dirname + '/clientapp/app.js',
|
|
||||||
templateFile: __dirname + '/clientapp/templates/main.html',
|
|
||||||
developmentMode: config.isDev,
|
|
||||||
cachePeriod: 0,
|
|
||||||
libraries: [
|
|
||||||
__dirname + '/clientapp/libraries/jquery.js',
|
|
||||||
__dirname + '/clientapp/libraries/ui.js',
|
|
||||||
__dirname + '/clientapp/libraries/resampler.js',
|
|
||||||
__dirname + '/clientapp/libraries/IndexedDBShim.min.js',
|
|
||||||
__dirname + '/clientapp/libraries/sugar-1.2.1-dates.js'
|
|
||||||
],
|
|
||||||
browserify: {
|
|
||||||
debug: false
|
|
||||||
},
|
|
||||||
stylesheets: [
|
|
||||||
__dirname + '/public/css/otalk.css'
|
|
||||||
],
|
|
||||||
server: app
|
|
||||||
});
|
|
||||||
|
|
||||||
if (config.isDev) {
|
|
||||||
clientApp.config.beforeBuildJS = function () {
|
|
||||||
var clientFolder = __dirname + '/clientapp';
|
|
||||||
templatizer(clientFolder + '/templates', clientFolder + '/templates.js');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
clientApp.on('ready', function () {
|
|
||||||
console.log('Client app ready');
|
|
||||||
var pkginfo = JSON.parse(fs.readFileSync(__dirname + '/package.json'));
|
|
||||||
|
|
||||||
var manifestTemplate = fs.readFileSync(__dirname + '/clientapp/templates/misc/manifest.cache', 'utf-8');
|
|
||||||
var cacheManifest = manifestTemplate
|
|
||||||
.replace('#{version}', pkginfo.version + config.isDev ? ' ' + Date.now() : '')
|
|
||||||
.replace('#{jsFileName}', clientApp.jsFileName())
|
|
||||||
.replace('#{cssFileName}', clientApp.cssFileName());
|
|
||||||
console.log('Cache manifest generated');
|
|
||||||
|
|
||||||
|
|
||||||
app.get('/manifest.cache', function (req, res, next) {
|
|
||||||
res.set('Content-Type', 'text/cache-manifest');
|
|
||||||
res.set('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
|
|
||||||
res.send(cacheManifest);
|
|
||||||
});
|
|
||||||
|
|
||||||
// serves app on every other url
|
|
||||||
app.get('*', clientApp.html());
|
|
||||||
});
|
|
||||||
|
|
||||||
var webappManifest = fs.readFileSync('./public/x-manifest.webapp');
|
var webappManifest = fs.readFileSync('./public/x-manifest.webapp');
|
||||||
|
|
||||||
|
app.set('views', __dirname + '/views');
|
||||||
app.set('view engine', 'jade');
|
app.set('view engine', 'jade');
|
||||||
|
|
||||||
app.get('/login', function (req, res) {
|
app.get('/login', function (req, res) {
|
||||||
@ -168,9 +120,66 @@ app.use(function handleError(err, req, res, next) {
|
|||||||
res.render('error', errorResult);
|
res.render('error', errorResult);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var clientApp = new Moonboots({
|
||||||
|
moonboots: {
|
||||||
|
main: __dirname + '/clientapp/app.js',
|
||||||
|
developmentMode: config.isDev,
|
||||||
|
libraries: [
|
||||||
|
__dirname + '/clientapp/libraries/jquery.js',
|
||||||
|
__dirname + '/clientapp/libraries/ui.js',
|
||||||
|
__dirname + '/clientapp/libraries/resampler.js',
|
||||||
|
__dirname + '/clientapp/libraries/IndexedDBShim.min.js',
|
||||||
|
__dirname + '/clientapp/libraries/sugar-1.2.1-dates.js'
|
||||||
|
],
|
||||||
|
browserify: {
|
||||||
|
debug: false
|
||||||
|
},
|
||||||
|
stylesheets: [
|
||||||
|
__dirname + '/public/css/otalk.css'
|
||||||
|
],
|
||||||
|
beforeBuildJS: function () {
|
||||||
|
if (config.isDev) {
|
||||||
|
var clientFolder = __dirname + '/clientapp';
|
||||||
|
templatizer(clientFolder + '/templates', clientFolder + '/templates.js');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
server: app,
|
||||||
|
cachePeriod: 0,
|
||||||
|
render: function (req, res) {
|
||||||
|
res.render('index');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
clientApp.on('ready', function () {
|
||||||
|
console.log('Client app ready');
|
||||||
|
var pkginfo = JSON.parse(fs.readFileSync(__dirname + '/package.json'));
|
||||||
|
|
||||||
|
var manifestTemplate = fs.readFileSync(__dirname + '/clientapp/templates/misc/manifest.cache', 'utf-8');
|
||||||
|
var cacheManifest = manifestTemplate
|
||||||
|
.replace('#{version}', pkginfo.version + config.isDev ? ' ' + Date.now() : '')
|
||||||
|
.replace('#{jsFileName}', clientApp.moonboots.jsFileName())
|
||||||
|
.replace('#{cssFileName}', clientApp.moonboots.cssFileName());
|
||||||
|
console.log('Cache manifest generated');
|
||||||
|
|
||||||
|
|
||||||
|
app.get('/manifest.cache', function (req, res, next) {
|
||||||
|
res.set('Content-Type', 'text/cache-manifest');
|
||||||
|
res.set('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
|
||||||
|
res.send(cacheManifest);
|
||||||
|
});
|
||||||
|
|
||||||
|
// serves app on every other url
|
||||||
|
app.get('*', function (req, res) {
|
||||||
|
res.render(clientApp.moonboots.htmlSource());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
//https.createServer({
|
//https.createServer({
|
||||||
// key: fs.readFileSync(config.http.key),
|
// key: fs.readFileSync(config.http.key),
|
||||||
// cert: fs.readFileSync(config.http.cert)
|
// cert: fs.readFileSync(config.http.cert)
|
||||||
//}, app).listen(config.http.port);
|
//}, app).listen(config.http.port);
|
||||||
app.listen(config.http.port);
|
|
||||||
|
app.listen(config.http.port, function () {
|
||||||
console.log('demo.stanza.io running at: ' + config.http.baseUrl);
|
console.log('demo.stanza.io running at: ' + config.http.baseUrl);
|
||||||
|
})
|
||||||
|
14
views/index.jade
Normal file
14
views/index.jade
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user