From 9ceb0799edf9205db7b7db8e9fbdd188acf68420 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Fri, 10 Jan 2014 22:06:20 +0100 Subject: [PATCH] allow custom roomnode function as part of config to make deployment changes easier to merge --- app.js | 32 ++++++++++++++++++++------------ config.js | 1 + 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app.js b/app.js index 4bb34bf6a..c0b545360 100644 --- a/app.js +++ b/app.js @@ -48,19 +48,27 @@ function doJoin() { var roomnode = null; var path = window.location.pathname; var roomjid; - /* - * this is making assumptions about how the URL->room mapping happens. - * It currently assumes deployment at root, with a rewrite like the - * following one (for nginx): - location ~ ^/([a-zA-Z0-9]+)$ { - rewrite ^/(.*)$ / break; - } - */ - if (path.length > 1) { - roomnode = path.substr(1).toLowerCase(); + + // determinde the room node from the url + // TODO: just the roomnode or the whole bare jid? + if (config.getroomnode && typeof config.getroomnode === 'function') { + // custom function might be responsible for doing the pushstate + roomnode = config.getroomnode(path); } else { - roomnode = Math.random().toString(36).substr(2, 20); - window.history.pushState('VideoChat', 'Room: ' + roomnode, window.location.pathname + roomnode); + /* fall back to default strategy + * this is making assumptions about how the URL->room mapping happens. + * It currently assumes deployment at root, with a rewrite like the + * following one (for nginx): + location ~ ^/([a-zA-Z0-9]+)$ { + rewrite ^/(.*)$ / break; + } + */ + if (path.length > 1) { + roomnode = path.substr(1).toLowerCase(); + } else { + roomnode = Math.random().toString(36).substr(2, 20); + window.history.pushState('VideoChat', 'Room: ' + roomnode, window.location.pathname + roomnode); + } } roomjid = roomnode + '@' + config.hosts.muc; diff --git a/config.js b/config.js index b18a4ec49..ee99d5411 100644 --- a/config.js +++ b/config.js @@ -4,6 +4,7 @@ var config = { muc: 'meet.jit.si', // FIXME: use XEP-0030 bridge: 'jitsi-videobridge.lambada.jitsi.net' // FIXME: use XEP-0030 }, +// getroomnode: function (path) { return 'someprefixpossiblybasedonpath'; }, useNicks: false, bosh: '//lambada.jitsi.net/http-bind' // FIXME: use xep-0156 for that };