1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-21 16:55:10 -05:00

Use Stanza.io 6.10.2

This commit is contained in:
Sebastien Hut 2015-02-09 15:22:17 +01:00
parent 735b9ca08f
commit edc7151987
14 changed files with 116 additions and 120 deletions

View File

@ -2,8 +2,9 @@
"use strict";
var _ = require('underscore');
var async = require('async');
var Backbone = require('backbone');
Backbone.$ = $;
var async = require('async');
var StanzaIO = require('stanza.io');
var AppState = require('./models/state');
@ -17,16 +18,16 @@ var Notify = require('notify.js');
var Desktop = require('./helpers/desktop');
var AppCache = require('./helpers/cache');
module.exports = {
launch: function () {
var self = window.app = this;
var config = localStorage.config;
if (!config) {
console.log('missing config');
window.location = '/login';
return;
}
config = JSON.parse(config);
@ -128,5 +129,6 @@ module.exports = {
}
};
module.exports.launch();
$(function () {
module.exports.launch();
});

View File

@ -32,7 +32,6 @@ module.exports = function (jid, id, type, source, cb) {
return cb(fallback(jid));
}
resp = resp.toJSON();
type = resp.vCardTemp.photo.type || type;
var data = resp.vCardTemp.photo.data;
@ -53,7 +52,6 @@ module.exports = function (jid, id, type, source, cb) {
return cb(fallback(jid));
}
resp = resp.toJSON();
var data = resp.pubsub.retrieve.item.avatarData;
var uri = 'data:' + type + ';base64,' + data;

View File

@ -44,7 +44,7 @@ var discoCapsQueue = async.queue(function (pres, cb) {
}
if (client.verifyVerString(result.discoInfo, caps.hash, 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 () {
if (resource) resource.discoInfo = data;
cb();
@ -112,8 +112,6 @@ module.exports = function (client, app) {
window.readyForDeviceID = true;
client.getRoster(function (err, resp) {
resp = resp.toJSON();
if (resp.roster && resp.roster.items && resp.roster.items.length) {
app.storage.roster.clear(function () {
me.contacts.reset();
@ -143,7 +141,6 @@ module.exports = function (client, app) {
});
client.on('roster:update', function (iq) {
iq = iq.toJSON();
var items = iq.roster.items;
me.rosterVer = iq.roster.ver;
@ -169,7 +166,6 @@ module.exports = function (client, app) {
});
client.on('available', function (pres) {
pres = pres.toJSON();
var contact = me.getContact(pres.from);
if (contact) {
delete pres.id;
@ -206,7 +202,6 @@ module.exports = function (client, app) {
});
client.on('unavailable', function (pres) {
pres = pres.toJSON();
var contact = me.getContact(pres.from);
if (contact) {
var resource = contact.resources.get(pres.from.full);
@ -273,7 +268,6 @@ module.exports = function (client, app) {
});
client.on('chat', function (msg) {
msg = msg.toJSON();
msg.mid = msg.id;
delete msg.id;
@ -298,7 +292,6 @@ module.exports = function (client, app) {
});
client.on('groupchat', function (msg) {
msg = msg.toJSON();
msg.mid = msg.id;
delete msg.id;
@ -318,7 +311,6 @@ module.exports = function (client, app) {
});
client.on('replace', function (msg) {
msg = msg.toJSON();
msg.mid = msg.id;
delete msg.id;
@ -333,8 +325,6 @@ module.exports = function (client, app) {
});
client.on('receipt', function (msg) {
msg = msg.toJSON();
var contact = me.getContact(msg.from, msg.to);
if (!contact) return;

File diff suppressed because one or more lines are too long

View File

@ -313,7 +313,6 @@ module.exports = HumanModel.define({
var results = res.mamQuery.results || [];
results.reverse();
results.forEach(function (result) {
result = result.toJSON();
var msg = result.mam.forwarded.message;
msg.mid = msg.id;

View File

@ -115,7 +115,7 @@ module.exports = HumanModel.define({
app.whenConnected(function () {
client.getDiscoInfo(self.id, '', function (err, res) {
if (err) return;
self.discoInfo = res.discoInfo.toJSON();
self.discoInfo = res.discoInfo;
});
});
}

View File

@ -211,16 +211,17 @@ module.exports = BasePage.extend({
this.$('button.call').prop('disabled', !resources.length);
},
appendModel: function (model, preload) {
var newEl, first, last;
var newEl, first, last, newDay = false;
var messageDay = Date.create(model.timestamp).format('{month} {ord}, {yyyy}');
if (messageDay !== this.lastDate) {
var dayDivider = $(templates.includes.dayDivider({day_name: messageDay}));
this.staydown.append(dayDivider[0]);
this.lastDate = messageDay;
newDay = true;
}
var isGrouped = model.shouldGroupWith(this.lastModel);
var isGrouped = !newDay && model.shouldGroupWith(this.lastModel);
if (isGrouped) {
newEl = $(model.partialTemplateHtml);
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

View File

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

View File

@ -1,41 +1,43 @@
{
"name": "otalk.im",
"description": "Otalk: WebRTC Enabled XMPP Client, in the Browser",
"version": "0.0.40",
"version": "0.0.50",
"browser": {
"crypto": "crypto-browserify"
},
"dependencies": {
"andlog": "0.0.4",
"async": "0.2.9",
"async": "^0.9.0",
"attachmediastream": "1.0.1",
"backbone": "1.0.0",
"bluebird": "1.0.0",
"bluebird": "^2.3.2",
"bows": "0.3.0",
"browserify": "2.25.1",
"crypto-browserify": "1.0.3",
"express": "3.3.7",
"browserify": "4.x",
"compression": "1.2.2",
"crypto-browserify": "",
"express": "4.10.6",
"getconfig": "0.0.5",
"getusermedia": "0.2.1",
"helmet": "0.1.0",
"human-model": "2.6.0",
"human-view": "1.5.0",
"jade": "0.35.0",
"jxt": "0.6.0",
"moonboots": "1.0.0",
"node-uuid": "1.4.1",
"human-view": "1.8.0",
"jade": "1.8.2",
"jxt": "^2.6.1",
"moonboots-express": "2.x",
"node-uuid": "^1.4.1",
"notify.js": "0.0.3",
"oembed": "0.1.0",
"semi-static": "0.0.4",
"serve-static": "1.7.1",
"sound-effect-manager": "0.0.5",
"stanza.io": "3.6.x",
"stanza.io": "6.10.2",
"staydown": "1.0.3",
"templatizer": "0.1.2",
"underscore": "1.5.1",
"wildemitter": "1.0.1"
"underscore": "1.6.0",
"wildemitter": "^1.0.1"
},
"devDependencies": {
"precommit-hook": "0.3.6"
"precommit-hook": "^1.0.2"
},
"license": "MIT",
"main": "server.js",

121
server.js
View File

@ -2,17 +2,18 @@ var fs = require('fs');
var https = require('https');
var express = require('express');
var helmet = require('helmet');
var Moonboots = require('moonboots');
var Moonboots = require('moonboots-express');
var config = require('getconfig');
var templatizer = require('templatizer');
var oembed = require('oembed');
var async = require('async');
var app = express();
var compression = require('compression');
var serveStatic = require('serve-static');
app.use(express.compress());
app.use(express.static(__dirname + '/public'));
app.use(compression());
app.use(serveStatic(__dirname + '/public'));
if (!config.isDev) {
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_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');
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.get('/login', function (req, res) {
@ -168,9 +120,66 @@ app.use(function handleError(err, req, res, next) {
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({
// key: fs.readFileSync(config.http.key),
// cert: fs.readFileSync(config.http.cert)
//}, app).listen(config.http.port);
app.listen(config.http.port);
console.log('demo.stanza.io running at: ' + config.http.baseUrl);
app.listen(config.http.port, function () {
console.log('demo.stanza.io running at: ' + config.http.baseUrl);
})

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