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

pull/1/head
ansuz 7 years ago
commit 16388a839c

@ -65,5 +65,7 @@ define(function() {
contacts: 'fa-users', contacts: 'fa-users',
}; };
config.displayCreationScreen = true;
return config; return config;
}); });

@ -0,0 +1,146 @@
@import (once) "./colortheme-all.less";
@import (once) "./tools.less";
.creation_main() {
.tippy-popper {
z-index: 100000001 !important;
}
#cp-creation-container {
//position: fixed;
z-index: 100000000; // #loading * 10
//top: 0px;
//bottom: 0px;
//left: 0px;
//right: 0px;
background: @colortheme_loading-bg;
color: @colortheme_loading-color;
display: flex;
align-items: center;
width: 100%;
height: 100%;
overflow: auto;
@media screen and (max-height: 600px), screen and (max-width: 500px) {
align-items: baseline;
}
}
#cp-creation {
text-align: center;
font: @colortheme_app-font;
width: 100%;
& > div {
width: 60vw;
max-width: 100%;
margin: 40px auto;
text-align: left;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
h2, p {
width: 100%;
}
h2 {
display: flex;
justify-content: space-between;
.cp-creation-help {
display: none;
}
}
@media screen and (max-width: 500px) {
width: ~"calc(100% - 30px)";
}
@media screen and (max-height: 600px), screen and (max-width: 500px) {
h2 .cp-creation-help {
display: inline;
}
p {
display: none;
}
}
@media screen and (min-height: 601px) {
@media screen and (min-width: 501px) {
p {
display: block !important;
}
}
}
}
.cp-creation-create{
button {
.tools_unselectable();
padding: 15px;
background: darken(@colortheme_loading-bg, 10%);
color: @colortheme_loading-color;
margin: 3px 10px;
border: none;
cursor: pointer;
&:hover {
background: darken(@colortheme_loading-bg, 5%);
}
}
}
input[type="radio"] {
display: none;
&:checked {
& + label {
font-weight: bold;
background-color: lighten(@colortheme_loading-bg, 20%);
cursor: default;
border: 1px solid #c1158e;
&:hover {
background-color: lighten(@colortheme_loading-bg, 20%);
}
}
}
}
input[type="radio"] + label {
.tools_unselectable();
display: inline-flex;
align-items: center;
justify-content: center;
width: 200px;
height: 50px;
padding: 5px;
margin: 0 20px;
border: 1px solid @colortheme_loading-color;
cursor: pointer;
&:hover {
background-color: lighten(@colortheme_loading-bg, 10%);
}
}
.cp-creation-expire {
#cp-creation-expire-true {
display: none;
&:checked {
& + label {
height: 100px;
.cp-creation-expire-picker {
display: inline;
}
}
}
}
label[for="cp-creation-expire-true"] {
flex-wrap: wrap;
.cp-creation-expire-picker {
display: none;
}
input {
width: 70px;
}
select {
width: 100px;
}
input, select {
border: none;
height: 30px;
background: @colortheme_loading-bg;
color: @colortheme_loading-color;
border-radius: 3px;
}
}
}
}
}

@ -568,7 +568,7 @@
width: 64px; width: 64px;
font-size: 1em; font-size: 1em;
color: inherit; color: inherit;
height: auto; height: 64px;
padding: 0px; padding: 0px;
margin: 0; margin: 0;
&::before { &::before {

@ -787,5 +787,24 @@ define(function () {
out.feedback_privacy = "We care about your privacy, and at the same time we want CryptPad to be very easy to use. We use this file to figure out which UI features matter to our users, by requesting it along with a parameter specifying which action was taken."; out.feedback_privacy = "We care about your privacy, and at the same time we want CryptPad to be very easy to use. We use this file to figure out which UI features matter to our users, by requesting it along with a parameter specifying which action was taken.";
out.feedback_optout = "If you would like to opt out, visit <a href='/settings/'>your user settings page</a>, where you'll find a checkbox to enable or disable user feedback"; out.feedback_optout = "If you would like to opt out, visit <a href='/settings/'>your user settings page</a>, where you'll find a checkbox to enable or disable user feedback";
// Creation page
out.creation_404 = "This pad not longer exists. Use the following form to create a new pad";
out.creation_ownedTitle = "Type of pad";
out.creation_ownedTrue = "Owned pad";
out.creation_ownedFalse = "Open pad";
out.creation_owned1 = "An <b>owned</b> pad is a pad that you can delete from the server whenever you want. Once it is deleted, no one else can access it, even if it is stored in their CryptDrive.";
out.creation_owned2 = "An <b>open</b> pad doesn't have any owner and thus, it can't be deleted from the server unless it has reached its expiration time.";
out.creation_expireTitle = "Life time";
out.creation_expireTrue = "Add a life time";
out.creation_expireFalse = "Unlimited";
out.creation_expireHours = "Hours";
out.creation_expireDays = "Days";
out.creation_expireMonths = "Months";
out.creation_expire1 = "By default, a pad stored by a registered users will never be removed from the server, unless it is requested by its owner.";
out.creation_expire2 = "If you prefer, you can set a life time to make sure the pad will be permanently deleted from the server and unavailable after the specified date.";
out.creation_createTitle = "Create a pad";
out.creation_createFromTemplate = "From template";
out.creation_createFromScratch = "From scratch";
return out; return out;
}); });

@ -4,6 +4,7 @@
@import (once) '../../customize/src/less2/include/fileupload.less'; @import (once) '../../customize/src/less2/include/fileupload.less';
@import (once) '../../customize/src/less2/include/alertify.less'; @import (once) '../../customize/src/less2/include/alertify.less';
@import (once) '../../customize/src/less2/include/tokenfield.less'; @import (once) '../../customize/src/less2/include/tokenfield.less';
@import (once) '../../customize/src/less2/include/creation.less';
.toolbar_main( .toolbar_main(
@bg-color: @colortheme_code-bg, @bg-color: @colortheme_code-bg,
@ -13,6 +14,7 @@
.fileupload_main(); .fileupload_main();
.alertify_main(); .alertify_main();
.tokenfield_main(); .tokenfield_main();
.creation_main();
// body // body
&.cp-app-code { &.cp-app-code {
@ -100,7 +102,7 @@
} }
@media (max-width: @browser_media-medium-screen) { @media (max-width: @browser_media-medium-screen) {
.CodeMirror { #cp-app-code-container {
flex: 1; flex: 1;
max-width: 100%; max-width: 100%;
resize: none; resize: none;

@ -6,11 +6,12 @@ define([
'/common/common-language.js', '/common/common-language.js',
'/common/common-interface.js', '/common/common-interface.js',
'/common/common-feedback.js', '/common/common-feedback.js',
'/common/hyperscript.js',
'/common/media-tag.js', '/common/media-tag.js',
'/customize/messages.js', '/customize/messages.js',
'css!/common/tippy.css', 'css!/common/tippy.css',
], function ($, Config, Util, Hash, Language, UI, Feedback, MediaTag, Messages) { ], function ($, Config, Util, Hash, Language, UI, Feedback, h, MediaTag, Messages) {
var UIElements = {}; var UIElements = {};
// Configure MediaTags to use our local viewer // Configure MediaTags to use our local viewer
@ -387,7 +388,6 @@ define([
common.getAttribute(['general', 'markdown-help'], function (e, data) { common.getAttribute(['general', 'markdown-help'], function (e, data) {
if (e) { return void console.error(e); } if (e) { return void console.error(e); }
if (data === true && $toolbarButton.length && tbState) { if (data === true && $toolbarButton.length && tbState) {
console.log($toolbar.is(':visible'));
$toolbarButton.click(); $toolbarButton.click();
} }
}); });
@ -1120,5 +1120,169 @@ define([
}); });
}; };
UIElements.getPadCreationScreen = function (common, cb) {
if (!common.isLoggedIn()) { return void cb(); }
var sframeChan = common.getSframeChannel();
var metadataMgr = common.getMetadataMgr();
var type = metadataMgr.getMetadataLazy().type;
var $body = $('body');
var $creationContainer = $('<div>', { id: 'cp-creation-container' }).appendTo($body);
var $creation = $('<div>', { id: 'cp-creation' }).appendTo($creationContainer);
var setHTML = function (e, html) {
e.innerHTML = html;
return e;
};
// Title
$creation.append(h('h1.cp-creation-title', Messages['button_new'+type]));
// Deleted pad warning
if (metadataMgr.getPrivateData().isDeleted) {
$creation.append(h('div.cp-creation-deleted', Messages.creation_404));
}
var createHelper = function (text) {
var q = h('span.cp-creation-help.fa.fa-question', {
title: text
});
return q;
};
// Owned pads
var owned = h('div.cp-creation-owned', [
h('h2', [
Messages.creation_ownedTitle,
createHelper(Messages.creation_owned1 + '\n' + Messages.creation_owned2)
]),
setHTML(h('p'), Messages.creation_owned1 + '<br>' + Messages.creation_owned2),
h('input#cp-creation-owned-true.cp-creation-owned-value', {
type: 'radio',
name: 'cp-creation-owned',
value: 1,
checked: 'checked'
}),
h('label', { 'for': 'cp-creation-owned-true' }, Messages.creation_ownedTrue),
h('input#cp-creation-owned-false.cp-creation-owned-value', {
type: 'radio',
name: 'cp-creation-owned',
value: 0
}),
h('label', { 'for': 'cp-creation-owned-false' }, Messages.creation_ownedFalse)
]);
$creation.append(owned);
// Life time
var expire = h('div.cp-creation-expire', [
h('h2', [
Messages.creation_expireTitle,
createHelper(Messages.creation_expire1, Messages.creation_expire2)
]),
setHTML(h('p'), Messages.creation_expire1 + '<br>' + Messages.creation_expire2),
h('input#cp-creation-expire-false.cp-creation-expire-value', {
type: 'radio',
name: 'cp-creation-expire',
value: 0,
checked: 'checked'
}),
h('label', { 'for': 'cp-creation-expire-false' }, Messages.creation_expireFalse),
h('input#cp-creation-expire-true.cp-creation-expire-value', {
type: 'radio',
name: 'cp-creation-expire',
value: 1
}),
h('label', { 'for': 'cp-creation-expire-true' }, [
Messages.creation_expireTrue,
h('span.cp-creation-expire-picker', [
h('input#cp-creation-expire-val', {
type: "number",
min: 1,
max: 100,
value: 3
}),
h('select#cp-creation-expire-unit', [
h('option', { value: 'hour' }, Messages.creation_expireHours),
h('option', { value: 'day' }, Messages.creation_expireDays),
h('option', {
value: 'month',
selected: 'selected'
}, Messages.creation_expireMonths)
])
])
])
]);
$creation.append(expire);
// Create the pad
var create = function (template) {
// Type of pad
var ownedVal = parseInt($('input[name="cp-creation-owned"]:checked').val());
// Life time
var expireVal = 0;
if(parseInt($('input[name="cp-creation-expire"]:checked').val())) {
var unit = 0;
switch ($('#cp-creation-expire-unit').val()) {
case "hour" : unit = 3600; break;
case "day" : unit = 3600 * 24; break;
case "month": unit = 3600 * 24 * 30; break;
default: unit = 0;
}
expireVal = ($('#cp-creation-expire-val').val() || 0) * unit;
}
// XXX TODO remove these lines
ownedVal = undefined;
expire = undefined;
sframeChan.query("Q_CREATE_PAD", {
owned: ownedVal,
expire: expireVal,
template: template
}, function () {
$creationContainer.remove();
cb();
});
};
var $create = $(h('div.cp-creation-create', [
h('h2', Messages.creation_createTitle)
])).appendTo($creation);
// Pick a template?
sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) {
if (!data) { return; }
var $templateButton = $('<button>').text(Messages.creation_createFromTemplate)
.appendTo($create);
var pickerCfg = {
types: [type],
where: ['template'],
hidden: true
};
common.openFilePicker(pickerCfg);
$templateButton.click(function () {
// Show the template picker
delete pickerCfg.hidden;
common.openFilePicker(pickerCfg);
var first = true; // We can only pick a template once (for a new document)
var fileDialogCfg = {
onSelect: function (data) {
if (data.type === type && first) {
create(data.href);
first = false;
}
}
};
common.initFilePicker(fileDialogCfg);
});
});
var $button = $('<button>').text(Messages.creation_createFromScratch).appendTo($create);
$button.click(function () {
create();
});
};
return UIElements; return UIElements;
}); });

@ -402,13 +402,15 @@ define([
}); });
}; };
common.useTemplate = function (href, Crypt, cb) { common.useTemplate = function (href, Crypt, cb, opts) {
// opts is used to overrides options for chainpad-netflux in cryptput
// it allows us to add owners and expiration time if it is a new file
var parsed = Hash.parsePadUrl(href); var parsed = Hash.parsePadUrl(href);
if(!parsed) { throw new Error("Cannot get template hash"); } if(!parsed) { throw new Error("Cannot get template hash"); }
Crypt.get(parsed.hash, function (err, val) { Crypt.get(parsed.hash, function (err, val) {
if (err) { throw new Error(err); } if (err) { throw new Error(err); }
var p = Hash.parsePadUrl(window.location.href); var p = Hash.parsePadUrl(window.location.href);
Crypt.put(p.hash, val, cb); Crypt.put(p.hash, val, cb, opts);
}); });
}; };
@ -750,7 +752,8 @@ define([
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
// Load the new pad when the hash has changed // Load the new pad when the hash has changed
var oldHref = document.location.href; var oldHref = document.location.href;
window.onhashchange = function () { window.onhashchange = function (ev) {
if (ev && ev.reset) { oldHref = document.location.href; return; }
var newHref = document.location.href; var newHref = document.location.href;
var parsedOld = Hash.parsePadUrl(oldHref).hashData; var parsedOld = Hash.parsePadUrl(oldHref).hashData;
var parsedNew = Hash.parsePadUrl(newHref).hashData; var parsedNew = Hash.parsePadUrl(newHref).hashData;

@ -742,6 +742,9 @@ define([
}, // post EV_PAD_DISCONNECT }, // post EV_PAD_DISCONNECT
channel: data.channel, channel: data.channel,
validateKey: data.validateKey, validateKey: data.validateKey,
owners: data.owners,
password: data.password,
expire: data.expire,
network: store.network, network: store.network,
readOnly: data.readOnly, readOnly: data.readOnly,
onConnect: function (wc, sendMessage) { onConnect: function (wc, sendMessage) {

@ -33,6 +33,9 @@ define([], function () {
var onLeave = conf.onLeave; var onLeave = conf.onLeave;
var onReady = conf.onReady; var onReady = conf.onReady;
var onDisconnect = conf.onDisconnect; var onDisconnect = conf.onDisconnect;
var owners = conf.owners;
var password = conf.password;
var expire = conf.expire;
conf = undefined; conf = undefined;
var initializing = true; var initializing = true;
@ -177,10 +180,15 @@ define([], function () {
}); });
network.historyKeeper = hk; network.historyKeeper = hk;
var msg = ['GET_HISTORY', wc.id]; var cfg = {
validateKey: validateKey,
lastKnownHash: lastKnownHash,
owners: owners,
expire: expire,
password: password
};
var msg = ['GET_HISTORY', wc.id, cfg];
// Add the validateKey if we are the channel creator and we have a validateKey // Add the validateKey if we are the channel creator and we have a validateKey
msg.push(validateKey);
msg.push(lastKnownHash);
if (hk) { network.sendto(hk, JSON.stringify(msg)); } if (hk) { network.sendto(hk, JSON.stringify(msg)); }
} else { } else {
onRdy(); onRdy();

@ -373,13 +373,20 @@ define([
nThen(function (waitFor) { nThen(function (waitFor) {
UI.addLoadingScreen(); UI.addLoadingScreen();
SFCommon.create(waitFor(function (c) { common = c; })); SFCommon.create(waitFor(function (c) { common = c; }));
}).nThen(function (waitFor) {
common.getSframeChannel().onReady(waitFor());
}).nThen(function (waitFor) {
if (!AppConfig.displayCreationScreen) { return; }
if (common.getMetadataMgr().getPrivateData().isNewFile) {
common.getPadCreationScreen(waitFor());
}
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
cpNfInner = common.startRealtime({ cpNfInner = common.startRealtime({
// really basic operational transform // really basic operational transform
patchTransformer: options.patchTransformer || ChainPad.SmartJSONTransformer, patchTransformer: options.patchTransformer || ChainPad.SmartJSONTransformer,
// cryptpad debug logging (default is 1) // cryptpad debug logging (default is 1)
// logLevel: 0, // logLevel: 2,
validateContent: options.validateContent || function (content) { validateContent: options.validateContent || function (content) {
try { try {
JSON.parse(content); JSON.parse(content);

@ -27,6 +27,9 @@ define([], function () {
var readOnly = conf.readOnly || false; var readOnly = conf.readOnly || false;
var padRpc = conf.padRpc; var padRpc = conf.padRpc;
var sframeChan = conf.sframeChan; var sframeChan = conf.sframeChan;
var password = conf.password;
var owners = conf.owners;
var expire = conf.expire;
var onConnect = conf.onConnect || function () { }; var onConnect = conf.onConnect || function () { };
conf = undefined; conf = undefined;
@ -98,7 +101,10 @@ define([], function () {
padRpc.joinPad({ padRpc.joinPad({
channel: channel || null, channel: channel || null,
validateKey: validateKey, validateKey: validateKey,
readOnly: readOnly readOnly: readOnly,
owners: owners,
password: password,
expire: expire
}, function(data) { }, function(data) {
onOpen(data); onOpen(data);
}); });

@ -110,9 +110,13 @@ define([
chan.whenReg('EV_REGISTER_HANDLER', evReady.fire); chan.whenReg('EV_REGISTER_HANDLER', evReady.fire);
// Make sure both iframes are ready // Make sure both iframes are ready
var isReady =false;
chan.onReady = function (h) { chan.onReady = function (h) {
if (isReady) {
return void h();
}
if (typeof(h) !== "function") { return; } if (typeof(h) !== "function") { return; }
chan.on('EV_RPC_READY', function () { h(); }); chan.on('EV_RPC_READY', function () { isReady = true; h(); });
}; };
chan.ready = function () { chan.ready = function () {
chan.whenReg('EV_RPC_READY', function () { chan.whenReg('EV_RPC_READY', function () {

@ -36,7 +36,7 @@ define([
//patchTransformer: ChainPad.NaiveJSONTransformer, //patchTransformer: ChainPad.NaiveJSONTransformer,
//logLevel: 0, //logLevel: 0,
//transformFunction: JsonOT.validate, //transformFunction: JsonOT.validate,
logLevel: config.debug ? 1 : 0, logLevel: config.debug ? 2 : 0,
noPrune: true noPrune: true
}); });
}; };

@ -12,6 +12,7 @@ define([
var network; var network;
var secret; var secret;
var hashes; var hashes;
var isNewFile;
var CpNfOuter; var CpNfOuter;
var Cryptpad; var Cryptpad;
var Crypto; var Crypto;
@ -19,10 +20,10 @@ define([
var SFrameChannel; var SFrameChannel;
var sframeChan; var sframeChan;
var FilePicker; var FilePicker;
//var Messenger;
var Messaging; var Messaging;
var Notifier; var Notifier;
var Utils = {}; var Utils = {};
var AppConfig;
nThen(function (waitFor) { nThen(function (waitFor) {
// Load #2, the loading screen is up so grab whatever you need... // Load #2, the loading screen is up so grab whatever you need...
@ -41,11 +42,12 @@ define([
'/common/common-constants.js', '/common/common-constants.js',
'/common/common-feedback.js', '/common/common-feedback.js',
'/common/outer/local-store.js', '/common/outer/local-store.js',
'/customize/application_config.js',
'/common/outer/network-config.js', '/common/outer/network-config.js',
'/bower_components/netflux-websocket/netflux-client.js', '/bower_components/netflux-websocket/netflux-client.js',
], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel, ], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel,
_FilePicker, _Messaging, _Notifier, _Hash, _Util, _Realtime, _FilePicker, _Messaging, _Notifier, _Hash, _Util, _Realtime,
_Constants, _Feedback, _LocalStore, NetConfig, Netflux) { _Constants, _Feedback, _LocalStore, _AppConfig, NetConfig, Netflux) {
CpNfOuter = _CpNfOuter; CpNfOuter = _CpNfOuter;
Cryptpad = _Cryptpad; Cryptpad = _Cryptpad;
Crypto = _Crypto; Crypto = _Crypto;
@ -60,6 +62,7 @@ define([
Utils.Constants = _Constants; Utils.Constants = _Constants;
Utils.Feedback = _Feedback; Utils.Feedback = _Feedback;
Utils.LocalStore = _LocalStore; Utils.LocalStore = _LocalStore;
AppConfig = _AppConfig;
if (localStorage.CRYPTPAD_URLARGS !== ApiConfig.requireConf.urlArgs) { if (localStorage.CRYPTPAD_URLARGS !== ApiConfig.requireConf.urlArgs) {
console.log("New version, flushing cache"); console.log("New version, flushing cache");
@ -131,13 +134,25 @@ define([
} }
Cryptpad.getShareHashes(secret, waitFor(function (err, h) { hashes = h; })); Cryptpad.getShareHashes(secret, waitFor(function (err, h) { hashes = h; }));
} }
}).nThen(function (waitFor) {
// Check if the pad exists on server
if (!window.location.hash) { isNewFile = true; return; }
Cryptpad.getFileSize(window.location.href, waitFor(function (err, size) {
console.log(size);
if (size) {
isNewFile = false;
return;
}
isNewFile = true;
}));
}).nThen(function () { }).nThen(function () {
console.log(isNewFile);
var readOnly = secret.keys && !secret.keys.editKeyStr; var readOnly = secret.keys && !secret.keys.editKeyStr;
if (!secret.keys) { secret.keys = secret.key; } if (!secret.keys) { secret.keys = secret.key; }
var parsed = Utils.Hash.parsePadUrl(window.location.href); var parsed = Utils.Hash.parsePadUrl(window.location.href);
if (!parsed.type) { throw new Error(); } if (!parsed.type) { throw new Error(); }
var defaultTitle = Utils.Hash.getDefaultName(parsed); var defaultTitle = Utils.Hash.getDefaultName(parsed);
var edPublic;
var updateMeta = function () { var updateMeta = function () {
//console.log('EV_METADATA_UPDATE'); //console.log('EV_METADATA_UPDATE');
var metaObj, isTemplate; var metaObj, isTemplate;
@ -145,6 +160,7 @@ define([
Cryptpad.getMetadata(waitFor(function (err, m) { Cryptpad.getMetadata(waitFor(function (err, m) {
if (err) { console.log(err); } if (err) { console.log(err); }
metaObj = m; metaObj = m;
edPublic = metaObj.priv.edPublic; // needed to create an owned pad
})); }));
Cryptpad.isTemplate(window.location.href, waitFor(function (err, t) { Cryptpad.isTemplate(window.location.href, waitFor(function (err, t) {
if (err) { console.log(err); } if (err) { console.log(err); }
@ -169,7 +185,9 @@ define([
accounts: { accounts: {
donateURL: Cryptpad.donateURL, donateURL: Cryptpad.donateURL,
upgradeURL: Cryptpad.upgradeURL upgradeURL: Cryptpad.upgradeURL
} },
isNewFile: isNewFile,
isDeleted: window.location.hash.length > 0
}; };
for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; } for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; }
@ -540,12 +558,12 @@ define([
}); });
} }
sframeChan.ready();
Utils.Feedback.reportAppUsage();
if (!realtime) { return; }
// Join the netflux channel
var rtStarted = false;
var startRealtime = function () {
rtStarted = true;
var replaceHash = function (hash) { var replaceHash = function (hash) {
if (window.history && window.history.replaceState) { if (window.history && window.history.replaceState) {
if (!/^#/.test(hash)) { hash = '#' + hash; } if (!/^#/.test(hash)) { hash = '#' + hash; }
@ -577,6 +595,60 @@ define([
replaceHash(Utils.Hash.getEditHashFromKeys(wc, secret.keys)); replaceHash(Utils.Hash.getEditHashFromKeys(wc, secret.keys));
} }
}); });
};
sframeChan.on('Q_CREATE_PAD', function (data, cb) {
if (!isNewFile || rtStarted) { return; }
// Create a new hash
var newHash = Utils.Hash.createRandomHash();
secret = Utils.Hash.getSecrets(parsed.type, newHash);
// Update the hash in the address bar
var ohc = window.onhashchange;
window.onhashchange = function () {};
window.location.hash = newHash;
window.onhashchange = ohc;
ohc({reset: true});
// Update metadata values and send new metadata inside
parsed = Utils.Hash.parsePadUrl(window.location.href);
defaultTitle = Utils.Hash.getDefaultName(parsed);
readOnly = false;
updateMeta();
var rtConfig = {};
console.log(edPublic);
if (data.owned) {
//rtConfig.owners = [edPublic];
}
if (data.expire) {
//rtConfig.expire = data.expire;
}
if (data.template) {
// Pass rtConfig to useTemplate because Cryptput will create the file and
// we need to have the owners and expiration time in the first line on the
// server
Cryptpad.useTemplate(data.template, Cryptget, function () {
startRealtime();
cb();
}, rtConfig);
return;
}
// Start realtime outside the iframe and callback
console.log(data);
startRealtime(rtConfig);
cb();
});
sframeChan.ready();
Utils.Feedback.reportAppUsage();
if (!realtime) { return; }
if (isNewFile && AppConfig.displayCreationScreen) { return; }
startRealtime();
}); });
}; };

@ -90,6 +90,7 @@ define([
funcs.updateTags = callWithCommon(UIElements.updateTags); funcs.updateTags = callWithCommon(UIElements.updateTags);
funcs.createLanguageSelector = callWithCommon(UIElements.createLanguageSelector); funcs.createLanguageSelector = callWithCommon(UIElements.createLanguageSelector);
funcs.createMarkdownToolbar = callWithCommon(UIElements.createMarkdownToolbar); funcs.createMarkdownToolbar = callWithCommon(UIElements.createMarkdownToolbar);
funcs.getPadCreationScreen = callWithCommon(UIElements.getPadCreationScreen);
// Thumb // Thumb
funcs.displayThumbnail = callWithCommon(Thumb.displayThumbnail); funcs.displayThumbnail = callWithCommon(Thumb.displayThumbnail);

@ -209,5 +209,8 @@ define({
// Notifications about connection and disconnection from the network // Notifications about connection and disconnection from the network
'EV_NETWORK_DISCONNECT': true, 'EV_NETWORK_DISCONNECT': true,
'EV_NETWORK_RECONNECT': true 'EV_NETWORK_RECONNECT': true,
// Pad creation screen: create a pad with the selected attributes (owned, expire)
'Q_CREATE_PAD': true,
}); });

Loading…
Cancel
Save