diff --git a/config.example.js b/config.example.js
index 1b28a5e89..ce38b5c3a 100644
--- a/config.example.js
+++ b/config.example.js
@@ -35,6 +35,8 @@ module.exports = {
* domain which will serve your CryptPad instance.
*/
"child-src blob: *",
+ // IE/Edge
+ "frame-src blob: *",
"media-src * blob:",
@@ -62,7 +64,9 @@ module.exports = {
/* See above under 'contentSecurity' as to how these values should be
* configured for best effect.
*/
- "child-src *",
+ "child-src *",
+ // IE/Edge
+ "frame-src *",
// see the comment above in the 'contentSecurity' section
"connect-src 'self' ws: wss:" + domain,
diff --git a/customize.dist/pages.js b/customize.dist/pages.js
index f9a5addc6..784fc007f 100644
--- a/customize.dist/pages.js
+++ b/customize.dist/pages.js
@@ -657,10 +657,6 @@ define([
return loadingScreen();
};
- Pages['/contacts2/'] = Pages['/contacts2/index.html'] = function () {
- return loadingScreen();
- };
-
Pages['/pad/'] = Pages['/pad/index.html'] = function () {
return loadingScreen();
};
diff --git a/customize.dist/template.js b/customize.dist/template.js
index a980270a3..062be4308 100644
--- a/customize.dist/template.js
+++ b/customize.dist/template.js
@@ -9,7 +9,7 @@ define([
$(function () {
var $body = $('body');
var isMainApp = function () {
- return /^\/(pad|code|slide|poll|whiteboard|file|media|contacts|contacts2|drive|settings|profile|todo)\/$/.test(location.pathname);
+ return /^\/(pad|code|slide|poll|whiteboard|file|media|contacts|drive|settings|profile|todo)\/$/.test(location.pathname);
};
var infoPage = function () {
@@ -55,9 +55,6 @@ $(function () {
} else if (/^\/contacts\/$/.test(pathname)) {
$('body').append(h('body', Pages[pathname]()).innerHTML);
require([ '/contacts/main.js' ], ready);
- } else if (/contacts2/.test(pathname)) {
- $('body').append(h('body', Pages[pathname]()).innerHTML);
- require([ '/contacts2/main.js' ], ready);
} else if (/pad/.test(pathname)) {
$('body').append(h('body', Pages[pathname]()).innerHTML);
require([ '/pad/main.js' ], ready);
diff --git a/server.js b/server.js
index faab366f6..baf9b2e99 100644
--- a/server.js
+++ b/server.js
@@ -10,7 +10,13 @@ var NetfluxSrv = require('./node_modules/chainpad-server/NetfluxWebsocketSrv');
var Package = require('./package.json');
var Path = require("path");
-var config = require('./config');
+var config;
+try {
+ config = require('./config');
+} catch (e) {
+ console.log("You can customize the configuration by copying config.example.js to config.js");
+ config = require('./config.example');
+}
var websocketPort = config.websocketPort || config.httpPort;
var useSecureWebsockets = config.useSecureWebsockets || false;
diff --git a/www/common/common-messaging.js b/www/common/common-messaging.js
index e4f2d20e3..7d75a7393 100644
--- a/www/common/common-messaging.js
+++ b/www/common/common-messaging.js
@@ -6,62 +6,16 @@ define([
'/bower_components/marked/marked.min.js',
'/common/common-realtime.js',
-
- // displayAvatar
- // whenRealtimeSyncs
- // getRealtime -> removeFromFriendList
- /* UI
- Messages
- confirm
- fixHTML
- displayAvatar
- clearOwnedChannel
- alert
-
-
- pushMsg
- removeFromFriendList
-
- onDirectMessage
- getNetwork
- getProxy
- pushMsg
-
- Init
- getNetwork
- getProxy
- onDirectMessage
- removeFromFriendList
- notify
- onMessage
-
- */
-
], function ($, Crypto, Curve, Hash, Marked, Realtime) {
var Msg = {
inputs: [],
};
-
- var Types = {
- message: 'MSG',
- update: 'UPDATE',
- unfriend: 'UNFRIEND',
- mapId: 'MAP_ID',
- mapIdAck: 'MAP_ID_ACK'
- };
-
// TODO
// - mute a channel (hide notifications or don't open it?)
-
- var ready = [];
var pending = {};
var pendingRequests = [];
- var parseMessage = function (content) {
- return Marked(content);
- };
-
var createData = Msg.createData = function (proxy, hash) {
return {
channel: hash || Hash.createChannelId(),
@@ -82,13 +36,6 @@ define([
return proxy.friends ? proxy.friends[pubkey] : undefined;
};
- var removeFromFriendList = function (proxy, realtime, curvePublic, cb) {
- if (!proxy.friends) { return; }
- var friends = proxy.friends;
- delete friends[curvePublic];
- Realtime.whenRealtimeSyncs(realtime, cb);
- };
-
var getFriendList = Msg.getFriendList = function (proxy) {
if (!proxy.friends) { proxy.friends = {}; }
return proxy.friends;
@@ -101,7 +48,6 @@ define([
});
};
-
Msg.getFriendChannelsList = function (proxy) {
var list = [];
eachFriend(proxy, function (friend) {
@@ -110,500 +56,9 @@ define([
return list;
};
- // Messaging tools
- var avatars = {};
-
// TODO make this internal to the messenger
var channels = Msg.channels = window.channels = {};
- var UI = Msg.UI = {};
-
- UI.init = function (common, $listContainer, $msgContainer) {
- var ui = {
- containers: {
- friendList: $listContainer,
- messages: $msgContainer,
- },
- };
-
- ui.addToFriendList = function (data, display, remove) {
- var $block = ui.containers.friendBlock;
-
- var $friend = $('
', {'class': 'friend avatar'}).appendTo($block);
- $friend.data('key', data.curvePublic);
- var $rightCol = $('
', {'class': 'right-col'});
- $('', {'class': 'name'}).text(data.displayName).appendTo($rightCol);
- var $remove = $('', {'class': 'remove fa fa-user-times'}).appendTo($rightCol);
- $remove.attr('title', common.Messages.contacts_remove);
- $friend.dblclick(function () {
- if (data.profile) {
- window.open('/profile/#' + data.profile);
- }
- });
- $friend.click(function () {
- display(data.curvePublic);
- });
- $remove.click(function (e) {
- e.stopPropagation();
- common.confirm(common.Messages._getKey('contacts_confirmRemove', [
- common.fixHTML(data.displayName)
- ]), function (yes) {
- if (!yes) { return; }
- remove(data.curvePublic);
- }, null, true);
- });
- if (data.avatar && avatars[data.avatar]) {
- $friend.append(avatars[data.avatar]);
- $friend.append($rightCol);
- } else {
- common.displayAvatar($friend, data.avatar, data.displayName, function ($img) {
- if (data.avatar && $img) {
- avatars[data.avatar] = $img[0].outerHTML;
- }
- $friend.append($rightCol);
- });
- }
- $('', {'class': 'status'}).appendTo($friend);
- };
-
- ui.createFriendList = function (friends, display, remove) {
- var $block = ui.containers.friendBlock = $('');
- eachFriend(friends, function (friend) {
- ui.addToFriendList(friend, display, remove);
- });
- $block.appendTo($listContainer);
- };
-
- ui.notify = function (curvePublic) {
- var $friend = $listContainer.find('.friend').filter(function (idx, el) {
- return $(el).data('key') === curvePublic;
- });
- $friend.addClass('notify');
- };
-
- ui.unnotify = function (curvePublic) {
- var $friend = $listContainer.find('.friend').filter(function (idx, el) {
- return $(el).data('key') === curvePublic;
- });
- $friend.removeClass('notify');
- };
-
- ui.update = function (curvePublic, types) {
- var proxy = common.getProxy();
- var data = getFriend(proxy, curvePublic);
- var chan = channels[data.channel];
- if (!chan.ready) {
- chan.updateOnReady = (chan.updateOnReady || []).concat(types);
- return;
- }
- var $friend = $listContainer.find('.friend').filter(function (idx, el) {
- return $(el).data('key') === curvePublic;
- });
- if (types.indexOf('displayName') >= 0) {
- $friend.find('.name').text(data.displayName);
- }
- if (types.indexOf('avatar') >= 0) {
- $friend.find('.default').remove();
- $friend.find('media-tag').remove();
- if (data.avatar && avatars[data.avatar]) {
- $friend.prepend(avatars[data.avatar]);
- } else {
- common.displayAvatar($friend, data.avatar, data.displayName, function ($img) {
- if (data.avatar && $img) {
- avatars[data.avatar] = $img[0].outerHTML;
- }
- });
- }
- }
- };
-
- ui.updateStatus = function (curvePublic, online) {
- ui.getFriend(curvePublic).find('.status')
- .attr('class', 'status ' + (online? 'online' : 'offline'));
- };
-
- ui.getChannel = function (curvePublic) {
- var $chat = $msgContainer.find('.chat').filter(function (idx, el) {
- return $(el).data('key') === curvePublic;
- });
- return $chat.length? $chat: null;
- };
-
- ui.hideInfo = function () {
- $msgContainer.find('.info').hide();
- };
-
- ui.showInfo = function () {
- $msgContainer.find('.info').show();
- };
-
- ui.createChat = function (curvePublic) {
- return $('
', {'class':'chat'})
- .data('key', curvePublic).appendTo($msgContainer);
- };
-
- ui.hideChat = function () {
- $msgContainer.find('.chat').hide();
- };
-
- ui.getFriend = function (curvePublic) {
- return $listContainer.find('.friend').filter(function (idx, el) {
- return $(el).data('key') === curvePublic;
- });
- };
-
- ui.remove = function (curvePublic) {
- var $friend = ui.getFriend(curvePublic);
- var $chat = ui.getChannel(curvePublic);
- $friend.remove();
- if ($chat) { $chat.remove(); }
- ui.showInfo();
- };
-
- ui.createMessage = function (msg, name) {
- var $msg = $('
', {'class': 'message'})
- .attr('title', msg.time ? new Date(msg.time).toLocaleString(): '?');
-
- if (name) {
- $('
', {'class':'sender'}).text(name).appendTo($msg);
- }
-
- $('
', {'class':'content'}).html(parseMessage(msg.text)).appendTo($msg);
- return $msg;
- };
-
- ui.setEditable = function (bool) {
- bool = !bool;
- var input = ui.input;
- if (!input) { return; }
-
- if (bool) {
- input.setAttribute('disabled', bool);
- } else {
- input.removeAttribute('disabled');
- }
-
- if (common.Messages) {
- // set placeholder
- var placeholder = bool?
- common.Messages.disconnected:
- common.Messages.contacts_typeHere;
- input.setAttribute('placeholder', placeholder);
- }
- };
-
- ui.createChatBox = function (proxy, $container, curvePublic) {
- var data = getFriend(proxy, curvePublic);
-
- // Input
- var channel = channels[data.channel];
-
- var $header = $('
', {
- 'class': 'header',
- }).appendTo($container);
-
- var $avatar = $('
', {'class': 'avatar'}).appendTo($header);
-
- // more history...
- $('
', {
- 'class': 'more-history',
- })
- .text('get more history')
- .click(function () {
- console.log("GETTING HISTORY");
- channel.getPreviousMessages();
- })
- .appendTo($header);
-
- var $removeHistory = $('', {
- 'class': 'remove-history fa fa-eraser',
- title: common.Messages.contacts_removeHistoryTitle
- })
- .click(function () {
- common.confirm(common.Messages.contacts_confirmRemoveHistory, function (yes) {
- if (!yes) { return; }
- common.clearOwnedChannel(data.channel, function (e) {
- if (e) {
- console.error(e);
- common.alert(common.Messages.contacts_removeHistoryServerError);
- return;
- }
- });
- });
- });
- $removeHistory.appendTo($header);
-
- $('', {'class': 'messages'}).appendTo($container);
- var $inputBlock = $('
', {'class': 'input'}).appendTo($container);
-
- var $input = $('