Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging
This commit is contained in:
commit
d2e46d1378
@ -141,6 +141,23 @@ module.exports = {
|
||||
*/
|
||||
filePath: './datastore/',
|
||||
|
||||
/* CryptPad allows logged in users to request that particular documents be
|
||||
* stored by the server indefinitely. This is called 'pinning'.
|
||||
* Pin requests are stored in a pin-store. The location of this store is
|
||||
* defined here.
|
||||
*/
|
||||
pinPath: './pins',
|
||||
|
||||
/* CryptPad allows logged in users to upload encrypted files. Files/blobs
|
||||
* are stored in a 'blob-store'. Set its location here.
|
||||
*/
|
||||
blobPath: './blob',
|
||||
|
||||
/* CryptPad stores incomplete blobs in a 'staging' area until they are
|
||||
* fully uploaded. Set its location here.
|
||||
*/
|
||||
blobStagingPath: './blobstage',
|
||||
|
||||
/* Cryptpad's file storage adaptor closes unused files after a configurale
|
||||
* number of milliseconds (default 30000 (30 seconds))
|
||||
*/
|
||||
|
||||
60
rpc.js
60
rpc.js
@ -2,6 +2,8 @@
|
||||
/* Use Nacl for checking signatures of messages */
|
||||
var Nacl = require("tweetnacl");
|
||||
|
||||
var Fs = require("fs");
|
||||
|
||||
var RPC = module.exports;
|
||||
|
||||
var Store = require("./storage/file");
|
||||
@ -380,18 +382,29 @@ var getLimit = function (cb) {
|
||||
|
||||
};
|
||||
|
||||
var createBlobStaging = function (cb) {
|
||||
|
||||
};
|
||||
|
||||
var createBlobStore = function (cb) {
|
||||
var safeMkdir = function (path, cb) {
|
||||
Fs.mkdir(path, function (e) {
|
||||
if (!e || e.code === 'EEXIST') { return void cb(); }
|
||||
cb(e);
|
||||
});
|
||||
};
|
||||
|
||||
var upload = function (store, Sessions, publicKey, cb) {
|
||||
/*
|
||||
1. check if there is an upload in progress
|
||||
* if yes, return error
|
||||
2.
|
||||
|
||||
*/
|
||||
|
||||
console.log('UPLOAD_NOT_IMPLEMENTED');
|
||||
cb('NOT_IMPLEMENTED');
|
||||
};
|
||||
|
||||
|
||||
var cancelUpload = function (store, Sessions, publicKey, cb) {
|
||||
console.log('CANCEL_UPLOAD_NOT_IMPLEMENTED');
|
||||
cb('NOT_IMPLEMENTED');
|
||||
};
|
||||
|
||||
/*::const ConfigType = require('./config.example.js');*/
|
||||
RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function)=>void*/) {
|
||||
@ -504,20 +517,43 @@ RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function)
|
||||
if (e) { return void Respond(e); }
|
||||
Respond(void 0, dict);
|
||||
});
|
||||
|
||||
case 'UPLOAD':
|
||||
return void upload(null, null, null, function (e) {
|
||||
Respond(e);
|
||||
});
|
||||
case 'CANCEL_UPLOAD':
|
||||
return void cancelUpload(null, null, null, function (e) {
|
||||
Respond(e);
|
||||
});
|
||||
default:
|
||||
return void Respond('UNSUPPORTED_RPC_CALL', msg);
|
||||
}
|
||||
};
|
||||
|
||||
var keyOrDefaultString = function (key, def) {
|
||||
return typeof(config[key]) === 'string'? config[key]: def;
|
||||
};
|
||||
|
||||
var pinPath = keyOrDefaultString('pinPath', './pins');
|
||||
var blobPath = keyOrDefaultString('blobPath', './blob');
|
||||
var blobStagingPath = keyOrDefaultString('blobStagingPath', './blobstage');
|
||||
|
||||
Store.create({
|
||||
filePath: './pins'
|
||||
filePath: pinPath,
|
||||
}, function (s) {
|
||||
store = s;
|
||||
cb(void 0, rpc);
|
||||
|
||||
// expire old sessions once per minute
|
||||
setInterval(function () {
|
||||
expireSessions(Sessions);
|
||||
}, 60000);
|
||||
safeMkdir(blobPath, function (e) {
|
||||
if (e) { throw e; }
|
||||
safeMkdir(blobStagingPath, function (e) {
|
||||
if (e) { throw e; }
|
||||
cb(void 0, rpc);
|
||||
// expire old sessions once per minute
|
||||
setInterval(function () {
|
||||
expireSessions(Sessions);
|
||||
}, 60000);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -155,7 +155,7 @@ define([
|
||||
// stopPropagation because the event would be cancelled by the dropdown menus
|
||||
e.stopPropagation();
|
||||
});
|
||||
var $label = $('<label>').text(' / '+ states.length).appendTo($nav);
|
||||
var $label2 = $('<label>').text(' / '+ states.length).appendTo($nav);
|
||||
$('<br>').appendTo($nav);
|
||||
var $close = $('<button>', {
|
||||
'class':'closeHistory',
|
||||
@ -169,7 +169,7 @@ define([
|
||||
onUpdate = function () {
|
||||
$cur.attr('max', states.length);
|
||||
$cur.val(c+1);
|
||||
$label.text(' / ' + states.length);
|
||||
$label2.text(' / ' + states.length);
|
||||
};
|
||||
|
||||
var close = function () {
|
||||
|
||||
@ -498,7 +498,7 @@ define([
|
||||
'title': Messages.pinLimitReached
|
||||
}).append($limitIcon).hide().appendTo($userContainer);
|
||||
var todo = function (e, overLimit) {
|
||||
if (e) { return void console.error("Unable tog et the pinned usage"); }
|
||||
if (e) { return void console.error("Unable to get the pinned usage"); }
|
||||
if (overLimit) {
|
||||
$limit.show().click(function () {
|
||||
Cryptpad.alert(Messages.pinLimitReachedAlert, null, true);
|
||||
|
||||
@ -606,6 +606,10 @@ define([
|
||||
// Permanently delete multiple files at once using a list of paths
|
||||
// NOTE: We have to be careful when removing elements from arrays (trash root, unsorted or template)
|
||||
var removePadAttribute = function (f) {
|
||||
if (typeof(f) !== 'string') {
|
||||
console.error("Can't find pad attribute for an undefined pad");
|
||||
return;
|
||||
}
|
||||
Object.keys(files).forEach(function (key) {
|
||||
var hash = f.indexOf('#') !== -1 ? f.slice(f.indexOf('#') + 1) : null;
|
||||
if (hash && key.indexOf(hash) === 0) {
|
||||
|
||||
@ -2393,6 +2393,7 @@ console.log(files);
|
||||
// don't initialize until the store is ready.
|
||||
Cryptpad.ready(function () {
|
||||
Cryptpad.reportAppUsage();
|
||||
if (!Cryptpad.isLoggedIn()) { Cryptpad.feedback('ANONYMOUS_DRIVE'); }
|
||||
APP.$bar = $iframe.find('#toolbar');
|
||||
|
||||
var storeObj = Cryptpad.getStore().getProxy && Cryptpad.getStore().getProxy().proxy ? Cryptpad.getStore().getProxy() : undefined;
|
||||
|
||||
@ -482,7 +482,10 @@ define([
|
||||
// CSS
|
||||
$('<label>', {'for': 'cssPrint'}).text(Messages.printCSS).appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
var $textarea = $('<textarea>', {'id':'cssPrint'}).css({'width':'100%', 'height':'100px'}).appendTo($p);
|
||||
var $textarea = $('<textarea>', {'id':'cssPrint'}).css({'width':'100%', 'height':'100px'}).appendTo($p)
|
||||
.on('keydown keyup', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
$textarea.val(slideOptionsTmp.style);
|
||||
window.setTimeout(function () { $textarea.focus(); }, 0);
|
||||
|
||||
@ -504,7 +507,7 @@ define([
|
||||
|
||||
var $nav = $('<nav>').appendTo($div);
|
||||
var $cancel = $('<button>', {'class': 'cancel'}).text(Messages.cancelButton).appendTo($nav).click(todoCancel);
|
||||
var $ok = $('<button>', {'class': 'ok'}).text(Messages.slideOptionsButton).appendTo($nav).click(todo);
|
||||
var $ok = $('<button>', {'class': 'ok'}).text(Messages.settings_save).appendTo($nav).click(todo);
|
||||
|
||||
return $container;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user