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

This commit is contained in:
ansuz
2017-02-27 14:32:04 +01:00
8 changed files with 61 additions and 34 deletions

View File

@@ -52,6 +52,7 @@ define([
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
var parsedHash = Cryptpad.parsePadUrl(window.location.href);
var defaultName = Cryptpad.getDefaultName(parsedHash);
var initialState = Messages.codeInitialState;
var editor = module.editor = CMeditor.fromTextArea($textarea[0], {
lineNumbers: true,
@@ -68,7 +69,7 @@ define([
mode: "javascript",
readOnly: true
});
editor.setOption('placeholder', Messages.codeInitialState);
editor.setValue(Messages.codeInitialState);
var setMode = module.setMode = function (mode, $select) {
module.highlightMode = mode;
@@ -84,8 +85,6 @@ define([
}
};
editor.setValue('');
var setTheme = module.setTheme = (function () {
var path = '/common/theme/';
@@ -562,7 +561,9 @@ define([
// Update the user list (metadata) from the hyperjson
updateMetadata(userDoc);
editor.setValue(newDoc || '');
if (newDoc) {
editor.setValue(newDoc);
}
if (Cryptpad.initialName && document.title === defaultName) {
updateTitle(Cryptpad.initialName);

View File

@@ -70,10 +70,16 @@ define([
TextPatcher.create({
realtime: realtime,
})(doc);
realtime.sync();
realtime.abort();
finish(Session, void 0);
var to = window.setTimeout(function () {
cb(new Error("Timeout"));
}, 5000);
Cryptpad.whenRealtimeSyncs(realtime, function () {
window.clearTimeout(to);
realtime.abort();
finish(Session, void 0);
});
};
overwrite(config, opt);

View File

@@ -1903,9 +1903,11 @@ define([
var createReadme = function (proxy, cb) {
if (proxy.initializing) {
var hash = Cryptpad.createRandomHash();
console.log(Messages.driveReadme);
Get.put(hash, Messages.driveReadme, function (e) {
if (e) { console.error(e); }
var href = '/pad/#' + hash;
console.log(href);
proxy.drive[UNSORTED].push(href);
proxy.drive[FILES_DATA].push({
href: href,

View File

@@ -4,7 +4,6 @@
<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>
<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
<script src="/bower_components/ckeditor/ckeditor.js"></script>
<style>

View File

@@ -130,7 +130,7 @@ define([
$(inner).css({
color: '#fff',
});
documentBody.innerHTML = Messages.initialState;
//documentBody.innerHTML = Messages.initialState;
var cursor = window.cursor = Cursor(inner);
@@ -367,7 +367,8 @@ define([
var realtimeOptions = {
// provide initialstate...
initialState: stringifyDOM(inner) || '{}',
//initialState: stringifyDOM(inner) || '{}',
initialState: '[]',
// the websocket URL
websocketURL: Cryptpad.getWebsocketURL(),
@@ -675,32 +676,41 @@ define([
module.realtime = info.realtime;
var shjson = info.realtime.getUserDoc();
applyHjson(shjson);
// Update the user list (metadata) from the hyperjson
updateMetadata(shjson);
var newPad = false;
if (shjson === '[]') { newPad = true; }
if (Visible.isSupported()) {
Visible.onChange(function (yes) {
if (yes) { unnotify(); }
});
}
if (!newPad) {
applyHjson(shjson);
if (!readOnly) {
var shjson2 = stringifyDOM(inner);
var hjson2 = JSON.parse(shjson2).slice(0,-1);
var hjson = JSON.parse(shjson).slice(0,-1);
if (stringify(hjson2) !== stringify(hjson)) {
console.log('err');
console.error("shjson2 !== shjson");
Cryptpad.errorLoadingScreen("Unable to display the content of that realtime session in your browser. Please try to reload that page."); // TODO translate
throw new Error();
// Update the user list (metadata) from the hyperjson
updateMetadata(shjson);
if (Visible.isSupported()) {
Visible.onChange(function (yes) {
if (yes) { unnotify(); }
});
}
if (!readOnly) {
var shjson2 = stringifyDOM(inner);
var hjson2 = JSON.parse(shjson2).slice(0,-1);
var hjson = JSON.parse(shjson).slice(0,-1);
if (stringify(hjson2) !== stringify(hjson)) {
console.log('err');
console.error("shjson2 !== shjson");
Cryptpad.errorLoadingScreen("Unable to display the content of that realtime session in your browser. Please try to reload that page."); // TODO translate
throw new Error();
}
}
} else {
updateMetadata(shjson);
documentBody.innerHTML = Messages.initialState;
}
Cryptpad.getLastName(function (err, lastName) {
console.log("Unlocking editor");
setEditable(true);
setEditable(!readOnly);
initializing = false;
Cryptpad.removeLoadingScreen(emitResize);

View File

@@ -72,6 +72,7 @@ define([
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
var parsedHash = Cryptpad.parsePadUrl(window.location.href);
var defaultName = Cryptpad.getDefaultName(parsedHash);
var initialState = Messages.slideInitialState;
var editor = module.editor = CMeditor.fromTextArea($textarea[0], {
lineNumbers: true,
@@ -88,7 +89,7 @@ define([
mode: "javascript",
readOnly: true
});
editor.setOption('placeholder', Messages.slideInitialState);
editor.setValue(initialState);
var setMode = module.setMode = function (mode, $select) {
module.highlightMode = mode;
@@ -102,8 +103,6 @@ define([
};
setMode('markdown');
editor.setValue('');
var setTheme = module.setTheme = (function () {
var path = '/common/theme/';
@@ -136,7 +135,7 @@ define([
var $modal = $pad.contents().find('#modal');
var $content = $pad.contents().find('#content');
Slide.setModal($modal, $content, $pad, ifrw, Messages.slideInitialState);
Slide.setModal($modal, $content, $pad, ifrw, initialState);
var enterPresentationMode = function (shouldLog) {
Slide.show(true, $textarea.val());
@@ -634,7 +633,7 @@ define([
// Update the user list (metadata) from the hyperjson
updateMetadata(userDoc);
editor.setValue(newDoc || '');
editor.setValue(newDoc || initialState);
Slide.update(newDoc);
if (Cryptpad.initialName && APP.title === defaultName) {