Merge branch 'pad2' of github.com:xwiki-labs/cryptpad into pad2

pull/1/head
yflory 7 years ago
commit 33025a9df9

@ -27,7 +27,7 @@ CKEDITOR.editorConfig = function( config ) {
config.font_defaultLabel = 'Arial'; config.font_defaultLabel = 'Arial';
config.fontSize_defaultLabel = '16'; config.fontSize_defaultLabel = '16';
config.contentsCss = '/customize/ckeditor-contents.css'; config.contentsCss = '/customize/ckeditor-contents.css?' + CKEDITOR.CRYPTPAD_URLARGS;
config.keystrokes = [ config.keystrokes = [
[ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ], [ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ],
@ -55,3 +55,17 @@ CKEDITOR.editorConfig = function( config ) {
//skin: 'moono-dark,/pad/themes/moono-dark/' //skin: 'moono-dark,/pad/themes/moono-dark/'
//skin: 'office2013,/pad/themes/office2013/' //skin: 'office2013,/pad/themes/office2013/'
}; };
(function () {
// These are overrides inside of ckeditor which add ?ver= to the CSS files so that
// every part of ckeditor will get in the browser cache.
var fix = function (x) {
if (x.map) { return x.map(fix); }
console.log('> ' + x);
return (/\/bower_components\/.*\.css$/.test(x)) ? (x + '?ver=' + CKEDITOR.timestamp) : x;
};
CKEDITOR.tools._buildStyleHtml = CKEDITOR.tools.buildStyleHtml;
CKEDITOR.document._appendStyleSheet = CKEDITOR.document.appendStyleSheet;
CKEDITOR.tools.buildStyleHtml = function (x) { return CKEDITOR.tools._buildStyleHtml(fix(x)); };
CKEDITOR.document.appendStyleSheet = function (x) { return CKEDITOR.document._appendStyleSheet(fix(x)); };
}());

@ -2,7 +2,7 @@
define([ define([
'/common/requireconfig.js' '/common/requireconfig.js'
], function (RequireConfig) { ], function (RequireConfig) {
require.config(RequireConfig); require.config(RequireConfig());
// most of CryptPad breaks if you don't support isArray // most of CryptPad breaks if you don't support isArray
if (!Array.isArray) { if (!Array.isArray) {

@ -21,5 +21,7 @@ define([
} }
}; };
Object.keys(ApiConfig.requireConf).forEach(function (k) { out[k] = ApiConfig.requireConf[k]; }); Object.keys(ApiConfig.requireConf).forEach(function (k) { out[k] = ApiConfig.requireConf[k]; });
return out; return function () {
return JSON.parse(JSON.stringify(out));
};
}); });

@ -2,20 +2,18 @@
// Note that this file is meant to be executed only inside of a sandbox iframe. // Note that this file is meant to be executed only inside of a sandbox iframe.
;(function () { ;(function () {
var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1))); var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
if (req.cfg) { require.config(req.cfg); } req.cfg = req.cfg || {};
if (req.pfx) { if (req.pfx) {
require.config({ req.cfg.onNodeCreated = function (node, config, module, path) {
onNodeCreated: function (node, config, module, path) { node.setAttribute('src', req.pfx + node.getAttribute('src'));
node.setAttribute('src', req.pfx + node.getAttribute('src')); };
}
});
} }
require.config(req.cfg);
if (req.req) { require(req.req, function () { }); } if (req.req) { require(req.req, function () { }); }
window.addEventListener('message', function (msg) { window.addEventListener('message', function (msg) {
var data = JSON.parse(msg.data); var data = JSON.parse(msg.data);
if (data.q !== 'INIT') { return; } if (data.q !== 'INIT') { return; }
msg.source.postMessage(JSON.stringify({ txid: data.txid, content: 'OK' }), '*'); msg.source.postMessage(JSON.stringify({ txid: data.txid, content: 'OK' }), '*');
if (data.content && data.content.requireConf) { require.config(data.content.requireConf); }
require(['/common/sframe-boot2.js'], function () { }); require(['/common/sframe-boot2.js'], function () { });
}); });
}()); }());

@ -1,7 +1,7 @@
// This is stage 1, it can be changed but you must bump the version of the project. // This is stage 1, it can be changed but you must bump the version of the project.
// Note: This must only be loaded from inside of a sandbox-iframe. // Note: This must only be loaded from inside of a sandbox-iframe.
define(['/common/requireconfig.js'], function (RequireConfig) { define(['/common/requireconfig.js'], function (RequireConfig) {
require.config(RequireConfig); require.config(RequireConfig());
// most of CryptPad breaks if you don't support isArray // most of CryptPad breaks if you don't support isArray
if (!Array.isArray) { if (!Array.isArray) {

@ -145,7 +145,7 @@ define([
intr = setInterval(function () { intr = setInterval(function () {
ow.postMessage(JSON.stringify({ ow.postMessage(JSON.stringify({
txid: txid, txid: txid,
content: { requireConf: RequireConfig }, content: { requireConf: RequireConfig() },
q: 'INIT' q: 'INIT'
}), '*'); }), '*');
}, 1); }, 1);

@ -606,7 +606,7 @@ define([
title: buttonTitle, title: buttonTitle,
'class': "cryptpad-logo" 'class': "cryptpad-logo"
}).append($('<img>', { }).append($('<img>', {
src: '/customize/images/logo_white.png' src: '/customize/images/logo_white.png?' + ApiConfig.requireConf.urlArgs
})); }));
var onClick = function (e) { var onClick = function (e) {
e.preventDefault(); e.preventDefault();

@ -2,11 +2,7 @@
<html class="cp pad"> <html class="cp pad">
<head> <head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/> <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<link rel="stylesheet" href="/bower_components/components-font-awesome/css/font-awesome.min.css">
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
<script async data-bootload="/pad2/main.js" data-main="/common/sframe-boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.3.5"></script> <script async data-bootload="/pad2/main.js" data-main="/common/sframe-boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<script src="/bower_components/ckeditor/ckeditor.js"></script>
<style> <style>
html, body { html, body {
margin: 0px; margin: 0px;

@ -1,4 +1,22 @@
console.log('one'); require(['/api/config'], function (ApiConfig) {
// see ckeditor_base.js getUrl()
window.CKEDITOR_GETURL = function (resource) {
if (resource.indexOf( '/' ) === 0) {
resource = window.CKEDITOR.basePath.replace(/\/bower_components\/.*/, '') + resource;
} else if (resource.indexOf(':/') === -1) {
resource = window.CKEDITOR.basePath + resource;
}
if (resource[resource.length - 1] !== '/' && resource.indexOf('ver=') === -1) {
var args = ApiConfig.requireConf.urlArgs;
if (resource.indexOf('/bower_components/') !== -1) {
args = 'ver=' + window.CKEDITOR.timestamp;
}
resource += (resource.indexOf('?') >= 0 ? '&' : '?') + args;
}
return resource;
};
require(['/bower_components/ckeditor/ckeditor.js']);
});
define([ define([
'jquery', 'jquery',
'/bower_components/chainpad-crypto/crypto.js', '/bower_components/chainpad-crypto/crypto.js',
@ -14,15 +32,17 @@ define([
'/pad/links.js', '/pad/links.js',
'/bower_components/nthen/index.js', '/bower_components/nthen/index.js',
'/common/sframe-common.js', '/common/sframe-common.js',
'/api/config',
'/bower_components/file-saver/FileSaver.min.js', '/bower_components/file-saver/FileSaver.min.js',
'/bower_components/diff-dom/diffDOM.js', '/bower_components/diff-dom/diffDOM.js',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
'less!/customize/src/less/cryptpad.less', 'less!/customize/src/less/cryptpad.less',
'less!/customize/src/less/toolbar.less' 'less!/customize/src/less/toolbar.less'
], function ($, Crypto, Hyperjson, ], function ($, Crypto, Hyperjson,
Toolbar, Cursor, JsonOT, TypingTest, JSONSortify, TextPatcher, Cryptpad, Cryptget, Links, nThen, SFCommon) { Toolbar, Cursor, JsonOT, TypingTest, JSONSortify, TextPatcher, Cryptpad, Cryptget, Links, nThen, SFCommon, ApiConfig) {
var saveAs = window.saveAs; var saveAs = window.saveAs;
var Messages = Cryptpad.Messages; var Messages = Cryptpad.Messages;
var DiffDom = window.diffDOM; var DiffDom = window.diffDOM;
@ -725,6 +745,8 @@ define([
} else { } else {
$('meta[name=viewport]').attr('content', 'width=device-width, initial-scale=1.0, user-scalable=yes'); $('meta[name=viewport]').attr('content', 'width=device-width, initial-scale=1.0, user-scalable=yes');
} }
// Used in ckeditor-config.js
Ckeditor.CRYPTPAD_URLARGS = ApiConfig.requireConf.urlArgs;
editor = Ckeditor.replace('editor1', { editor = Ckeditor.replace('editor1', {
customConfig: '/customize/ckeditor-config.js', customConfig: '/customize/ckeditor-config.js',
}); });

@ -4,14 +4,17 @@ define([
'/common/requireconfig.js', '/common/requireconfig.js',
'/common/cryptget.js' '/common/cryptget.js'
], function (ApiConfig, $, RequireConfig, Cryptget) { ], function (ApiConfig, $, RequireConfig, Cryptget) {
var requireConfig = RequireConfig();
$(function () { $(function () {
var req = { var req = {
cfg: RequireConfig, cfg: requireConfig,
req: [ '/common/loading.js' ], req: [ '/common/loading.js' ],
pfx: window.location.origin pfx: window.location.origin
}; };
window.rc = requireConfig;
window.apiconf = ApiConfig;
$('#sbox-iframe').attr('src', $('#sbox-iframe').attr('src',
ApiConfig.httpSafeOrigin + '/pad2/inner.html?' + ApiConfig.requireConf.urlArgs + ApiConfig.httpSafeOrigin + '/pad2/inner.html?' + requireConfig.urlArgs +
'#' + encodeURIComponent(JSON.stringify(req))); '#' + encodeURIComponent(JSON.stringify(req)));
}); });
require([ require([
@ -21,7 +24,6 @@ define([
'/common/cryptpad-common.js', '/common/cryptpad-common.js',
'/bower_components/chainpad-crypto/crypto.js' '/bower_components/chainpad-crypto/crypto.js'
], function (SFrameChannel, CpNfOuter, nThen, Cryptpad, Crypto) { ], function (SFrameChannel, CpNfOuter, nThen, Cryptpad, Crypto) {
console.log('xxx');
var sframeChan; var sframeChan;
var hashes; var hashes;
var secret; var secret;

Loading…
Cancel
Save