diff --git a/client/app/editor/editor.jade b/client/app/editor/editor.jade index 3b2619d..2696356 100644 --- a/client/app/editor/editor.jade +++ b/client/app/editor/editor.jade @@ -1,9 +1,9 @@ -div.toolbar(ng-attr-embedded='{{$root.config.chwalaHost !== undefined}}') +div.toolbar(ng-attr-embedded='{{$root.config.embedderHost !== undefined}}') div.toolbar-item.title title-editor div.toolbar-item export-button div.toolbar-item save-button -wodo-editor.wodo(ng-attr-embedded='{{$root.config.chwalaHost !== undefined}}') +wodo-editor.wodo(ng-attr-embedded='{{$root.config.embedderHost !== undefined}}') diff --git a/client/components/wodo/editor.controller.js b/client/components/wodo/editor.controller.js index ea5bbae..e35e493 100644 --- a/client/components/wodo/editor.controller.js +++ b/client/components/wodo/editor.controller.js @@ -1,158 +1,158 @@ 'use strict'; /*global Wodo*/ angular.module('manticoreApp') .controller('WodoCtrl', function ($scope, Auth, Adaptor) { var editorInstance, clientAdaptor, editorOptions = { collabEditingEnabled: true, unstableFeaturesEnabled: true, imageEditingEnabled: false, hyperlinkEditingEnabled: false }, onConnectCalled = false, listeners = {}, allowedOrigin; function addIframeEventListener(name, callback) { if (!listeners[name]) { listeners[name] = []; } listeners[name].push(callback); } function removeIframeEventListener(name, callback) { if (!listeners[name]) { return; } var index = listeners[name].indexOf(callback); if (index !== -1) { listeners[name].splice(index, 1); } } function broadcastIframeEvent(data) { if (allowedOrigin) { window.parent.postMessage(data, allowedOrigin); } } function setupCrossWindowMessaging() { - var chwalaHost = $scope.$root.config.chwalaHost; - if (chwalaHost) { + var embedderHost = $scope.$root.config.embedderHost; + if (embedderHost) { var temp = document.createElement('a'); - temp.href = 'http://localhost:8000'; + temp.href = embedderHost; allowedOrigin = temp.protocol + '//' + temp.host; window.addEventListener('message', function (event) { if (event.origin !== allowedOrigin || !event.data.name) { return; } - console.log('Received message from Roundcube: ' + event.data.name); + console.log('Received message from Embedder: ' + event.data.name); var subscribers = listeners[event.data.name]; if (subscribers && subscribers.length) { for(var i = 0; i < subscribers.length; i += 1) { subscribers[i](event); } } }); } } function closeEditing() { editorInstance.leaveSession(function () { $scope.$apply(function () { $scope.joined = false; }); clientAdaptor.leaveSession(function () { console.log('Closed editing, left session.'); }); }); } function handleEditingError(error) { alert('Something went wrong!\n' + error); console.log(error); closeEditing(); } function openEditor(permission) { setupCrossWindowMessaging(); if (permission === 'write') { editorOptions.allFeaturesEnabled = true; editorOptions.reviewModeEnabled = false; } else { editorOptions.reviewModeEnabled = true; } Wodo.createCollabTextEditor('wodoContainer', editorOptions, function (err, editor) { editorInstance = editor; $scope.editor = editor; $scope.editor.addIframeEventListener = addIframeEventListener; $scope.editor.removeIframeEventListener = removeIframeEventListener; $scope.editor.broadcastIframeEvent = broadcastIframeEvent; editorInstance.clientAdaptor = clientAdaptor; editorInstance.addEventListener(Wodo.EVENT_UNKNOWNERROR, handleEditingError); editorInstance.joinSession(clientAdaptor, function () { $scope.$apply(function () { $scope.joined = true; }); }); }); } function boot() { clientAdaptor = new Adaptor( $scope.document._id, Auth.getToken(), function onConnect() { console.log('onConnect'); if (onConnectCalled) { console.log('Reconnecting not yet supported'); return; } onConnectCalled = true; clientAdaptor.joinSession(function (memberId, permission) { if (!memberId) { console.log('Could not join; memberId not received'); } else { console.log('Joined with memberId ' + memberId); openEditor(permission); } }); }, function onKick() { console.log('onKick'); closeEditing(); }, function onDisconnect() { console.log('onDisconnect'); } ); } function destroy (cb) { if (editorInstance) { closeEditing(); editorInstance.destroy(cb); } else { if (clientAdaptor) { clientAdaptor.leaveSession(); clientAdaptor.destroy(); cb(); } } } this.boot = boot; this.destroy = destroy; }); diff --git a/server/config/environment/index.js b/server/config/environment/index.js index 2e8252c..e8f2cb2 100644 --- a/server/config/environment/index.js +++ b/server/config/environment/index.js @@ -1,84 +1,84 @@ 'use strict'; var path = require('path'); var _ = require('lodash'); function requiredProcessEnv(name) { if(!process.env[name]) { throw new Error('You must set the ' + name + ' environment variable'); } return process.env[name]; } // All configurations will extend these options // ============================================ var all = { env: process.env.NODE_ENV, // Root path of server root: path.normalize(__dirname + '/../../..'), // Server port port: process.env.PORT || 9000, // Should we populate the DB with sample data? seedDB: true, // Secret for session, you will want to change this and make it an environment variable secrets: { session: 'manticore-secret' }, // List of user roles userRoles: ['guest', 'user', 'admin'], // MongoDB connection options mongo: { options: { db: { safe: true } } }, defaultAccess: process.env.DEFAULT_ACCESS, client: { conversionHost: process.env.LOCODOC_SERVER, - chwalaHost: (process.env.STORAGE === 'chwala' && process.env.CHWALA_SERVER) || undefined + embedderHost: (process.env.STORAGE === 'chwala' && process.env.ROUNDCUBE_SERVER) || undefined }, auth: { type: process.env.AUTH || 'local', 'webdav': { server: process.env.WEBDAV_SERVER, path: process.env.WEBDAV_PATH, key: process.env.AUTH_ENCRYPTION_KEY }, 'ldap': { server: process.env.LDAP_SERVER, base: process.env.LDAP_BASE, filter: process.env.LDAP_FILTER, bindDn: process.env.LDAP_BIND_DN, bindPw: process.env.LDAP_BIND_PW, key: process.env.AUTH_ENCRYPTION_KEY } }, storage: { type: process.env.STORAGE || 'local', 'webdav': { server: process.env.WEBDAV_SERVER, path: process.env.WEBDAV_PATH, key: process.env.AUTH_ENCRYPTION_KEY }, 'chwala': { server: process.env.CHWALA_SERVER } } }; // Export the config object based on the NODE_ENV // ============================================== module.exports = _.merge( all, require('./' + process.env.NODE_ENV + '.js') || {}); diff --git a/server/config/local.env.sample.js b/server/config/local.env.sample.js index 54ffdc5..17adeb1 100644 --- a/server/config/local.env.sample.js +++ b/server/config/local.env.sample.js @@ -1,67 +1,73 @@ 'use strict'; // Use local.env.js for environment variables that grunt will set when the server starts locally. // Use for your api keys, secrets, etc. This file should not be tracked by git. // // You will need to set these on the server you deploy to. module.exports = { DOMAIN: 'http://localhost:9000', SESSION_SECRET: 'manticore-secret', // Control debug level for modules using visionmedia/debug DEBUG: '', /* * Default access permissions for documents. * If a user has a link to a session and tries to open it, this represents the * access type they have if no permission has been explicitly set for them. * Possible values: 'write', 'read', 'deny'. * By default, is set to 'write' for testing purposes. * If completely outsourcing access control to a third party service (like Kolab), set it to 'deny'. * If left blank, defaults to 'deny'. */ DEFAULT_ACCESS: 'allow', /* * Supported authentication strategies. * 1. 'local' for using Manticore's built-in accounts system. Allow signups. * 2. 'webdav' for authenticating against a WebDAV server. Only login, no signups. * 3. 'ldap' for authenticating against an LDAP service. Only login, no signups. */ AUTH: 'local', /* * Supported storage backends. * 1. 'local' for storing everything in Mongo/GridFS. The fastest and most reliable way. * Can be used with any AUTH strategy. * 2. 'webdav' for two-way synchronizing of documents with a WebDAV server. * Can be used if AUTH is 'ldap' or 'webdav'; those credentials are used to talk to the storage server. * 3. 'chwala' can be used for integrating with Kolab. */ STORAGE: 'local', /* * WebDAV server config, only if AUTH or STORAGE is 'webdav'. */ WEBDAV_SERVER: 'https://demo.owncloud.org', WEBDAV_PATH: '/remote.php/webdav', + /* + * When using Chwala storage, it is expected that Manticore will be embedded within Roundcube, + * so make sure you provide the host for the Roundcube server. This is intended for safe + * cross-origin communication. + */ CHWALA_SERVER: 'http://172.17.0.12', + ROUNDCUBE_SERVER: 'http://172.17.0.12', /* * Make sure you provide an encryption key to protect users' auth credentials. * This is necessary because the storage server may not support authentication tokens. */ AUTH_ENCRYPTION_KEY: 'suchauth123muchkey456', // LDAP server config, only if AUTH is 'ldap' LDAP_SERVER: 'ldap://172.17.0.12', LDAP_BASE: 'ou=People,dc=example,dc=org', LDAP_FILTER: '(&(objectclass=person)(|(uid={{username}})(mail={{username}})))', LDAP_BIND_DN: 'uid=binderservice,ou=Special Users,dc=example,dc=org', LDAP_BIND_PW: 'binderpass', // locodoc Server config LOCODOC_SERVER: 'http://localhost:3030' };