|
|
@ -1478,28 +1478,45 @@ define([
|
|
|
|
return 'thumbnail-' + parsed.type + '-' + channel;
|
|
|
|
return 'thumbnail-' + parsed.type + '-' + channel;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
sframeChan.on('Q_CREATE_TEMPLATES', function (type, cb) {
|
|
|
|
sframeChan.on('Q_CREATE_TEMPLATES', function (type, cb) {
|
|
|
|
Cryptpad.getSecureFilesList({
|
|
|
|
var templates;
|
|
|
|
types: [type],
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
where: ['template']
|
|
|
|
var next = waitFor();
|
|
|
|
}, function (err, data) {
|
|
|
|
require([
|
|
|
|
// NOTE: Never return data directly!
|
|
|
|
'/'+type+'/templates.js'
|
|
|
|
if (err) { return void cb({error: err}); }
|
|
|
|
], function (Templates) {
|
|
|
|
|
|
|
|
templates = Templates;
|
|
|
|
var res = [];
|
|
|
|
next();
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
}, function () {
|
|
|
|
Object.keys(data).map(function (el) {
|
|
|
|
next();
|
|
|
|
var k = getKey(data[el].href, data[el].channel);
|
|
|
|
});
|
|
|
|
Utils.LocalStore.getThumbnail(k, waitFor(function (e, thumb) {
|
|
|
|
}).nThen(function () {
|
|
|
|
res.push({
|
|
|
|
Cryptpad.getSecureFilesList({
|
|
|
|
id: el,
|
|
|
|
types: [type],
|
|
|
|
name: data[el].filename || data[el].title || '?',
|
|
|
|
where: ['template']
|
|
|
|
thumbnail: thumb,
|
|
|
|
}, function (err, data) {
|
|
|
|
used: data[el].used || 0
|
|
|
|
// NOTE: Never return data directly!
|
|
|
|
|
|
|
|
if (err) { return void cb({error: err}); }
|
|
|
|
|
|
|
|
var res = [];
|
|
|
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
|
|
|
|
Object.keys(data).map(function (el) {
|
|
|
|
|
|
|
|
var k = getKey(data[el].href, data[el].channel);
|
|
|
|
|
|
|
|
Utils.LocalStore.getThumbnail(k, waitFor(function (e, thumb) {
|
|
|
|
|
|
|
|
res.push({
|
|
|
|
|
|
|
|
id: el,
|
|
|
|
|
|
|
|
name: data[el].filename || data[el].title || '?',
|
|
|
|
|
|
|
|
thumbnail: thumb,
|
|
|
|
|
|
|
|
used: data[el].used || 0
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
|
|
|
if (Array.isArray(templates)) {
|
|
|
|
|
|
|
|
templates.forEach(function (obj) {
|
|
|
|
|
|
|
|
res.push(obj);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
cb({data: res});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}).nThen(function () {
|
|
|
|
|
|
|
|
cb({data: res});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -1892,6 +1909,7 @@ define([
|
|
|
|
Utils.rtConfig = rtConfig;
|
|
|
|
Utils.rtConfig = rtConfig;
|
|
|
|
var templatePw;
|
|
|
|
var templatePw;
|
|
|
|
nThen(function(waitFor) {
|
|
|
|
nThen(function(waitFor) {
|
|
|
|
|
|
|
|
if (data.templateContent) { return; }
|
|
|
|
if (data.templateId) {
|
|
|
|
if (data.templateId) {
|
|
|
|
if (data.templateId === -1) {
|
|
|
|
if (data.templateId === -1) {
|
|
|
|
isTemplate = true;
|
|
|
|
isTemplate = true;
|
|
|
@ -1905,6 +1923,14 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).nThen(function () {
|
|
|
|
}).nThen(function () {
|
|
|
|
var cryptputCfg = $.extend(true, {}, rtConfig, {password: password});
|
|
|
|
var cryptputCfg = $.extend(true, {}, rtConfig, {password: password});
|
|
|
|
|
|
|
|
if (data.templateContent) {
|
|
|
|
|
|
|
|
Cryptget.put(currentPad.hash, JSON.stringify(data.templateContent), function () {
|
|
|
|
|
|
|
|
console.error(arguments);
|
|
|
|
|
|
|
|
startRealtime();
|
|
|
|
|
|
|
|
cb();
|
|
|
|
|
|
|
|
}, cryptputCfg);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (data.template) {
|
|
|
|
if (data.template) {
|
|
|
|
// Start OO with a template...
|
|
|
|
// Start OO with a template...
|
|
|
|
// Cryptget and give href, password and content to inner
|
|
|
|
// Cryptget and give href, password and content to inner
|
|
|
|