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

This commit is contained in:
yflory
2017-05-18 14:27:10 +02:00
11 changed files with 307 additions and 192 deletions

View File

@@ -779,6 +779,21 @@ define([
common.getPinnedUsage(todo);
};
common.uploadComplete = function (cb) {
if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); }
rpc.uploadComplete(cb);
};
common.uploadStatus = function (size, cb) {
if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); }
rpc.uploadStatus(size, cb);
};
common.uploadCancel = function (cb) {
if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); }
rpc.uploadCancel(cb);
};
var LIMIT_REFRESH_RATE = 30000; // milliseconds
common.createUsageBar = function (cb, alwaysDisplayUpgrade) {
var todo = function (err, state, data) {

View File

@@ -144,6 +144,40 @@ define([
});
};
exp.uploadComplete = function (cb) {
rpc.send('UPLOAD_COMPLETE', null, function (e, res) {
if (e) { return void cb(e); }
var id = res[0];
if (typeof(id) !== 'string') {
return void cb('INVALID_ID');
}
cb(void 0, id);
});
};
exp.uploadStatus = function (size, cb) {
if (typeof(size) !== 'number') {
return void window.setTimeout(function () {
cb('INVALID_SIZE');
});
}
rpc.send('UPLOAD_STATUS', size, function (e, res) {
if (e) { return void cb(e); }
var pending = res[0];
if (typeof(pending) !== 'boolean') {
return void cb('INVALID_RESPONSE');
}
cb(void 0, pending);
});
};
exp.uploadCancel = function (cb) {
rpc.send('UPLOAD_CANCEL', void 0, function (e, res) {
if (e) { return void cb(e); }
cb();
});
};
cb(e, exp);
});
};

View File

@@ -65,9 +65,8 @@ define([
}
// if not box then done
Cryptpad.rpc.send('UPLOAD_COMPLETE', '', function (e, res) {
Cryptpad.uploadComplete(function (e, id) {
if (e) { return void console.error(e); }
var id = res[0];
var uri = ['', 'blob', id.slice(0,2), id].join('/');
console.log("encrypted blob is now available as %s", uri);
@@ -78,32 +77,28 @@ define([
APP.toolbar.addElement(['fileshare'], {});
// check if the uploaded file can be decrypted
var newU8 = FileCrypto.joinChunks(chunks);
FileCrypto.decrypt(newU8, key, function (e, res) {
if (e) { return console.error(e); }
var title = document.title = res.metadata.name;
myFile = res.content;
myDataType = res.metadata.type;
var defaultName = Cryptpad.getDefaultName(Cryptpad.parsePadUrl(window.location.href));
Title.updateTitle(title || defaultName);
APP.toolbar.title.show();
Cryptpad.alert(Messages._getKey('upload_success', [title]));
});
var title = document.title = metadata.name;
myFile = blob;
myDataType = metadata.type;
var defaultName = Cryptpad.getDefaultName(Cryptpad.parsePadUrl(window.location.href));
Title.updateTitle(title || defaultName);
APP.toolbar.title.show();
console.log(title);
Cryptpad.alert(Messages._getKey('upload_success', [title]));
});
};
Cryptpad.rpc.send('UPLOAD_STATUS', estimate, function (e, pending) {
Cryptpad.uploadStatus(estimate, function (e, pending) {
if (e) {
console.error(e);
return void Cryptpad.alert(Messages.upload_serverError);
}
if (pending[0]) {
if (pending) {
// TODO queue uploads... ?
return void Cryptpad.confirm(Messages.upload_uploadPending, function (yes) {
if (!yes) { return; }
Cryptpad.rpc.send('UPLOAD_CANCEL', '', function (e, res) {
Cryptpad.uploadCancel(function (e, res) {
if (e) { return void console.error(e); }
console.log(res);
next(again);

View File

@@ -97,7 +97,7 @@
<div class="col">
<ul class="list-unstyled">
<li class="title" data-localization="footer_contact"><li>
<li><a href="https://riot.im/app/#/room/!cryptpad:matrix.org" target="_blank" rel="noopener noreferrer">Chat</a></li>
<li><a href="https://riot.im/app/#/room/#cryptpad:matrix.org" target="_blank" rel="noopener noreferrer">Chat</a></li>
<li><a href="https://twitter.com/cryptpad" target="_blank" rel="noopener noreferrer">Twitter</a></li>
<li><a href="https://github.com/xwiki-labs/cryptpad" target="_blank" rel="noopener noreferrer">GitHub</a></li>
<li><a href="/contact.html">Email</a></li>
@@ -105,7 +105,7 @@
</div>
</div>
</div>
<div class="version-footer">CryptPad v1.6.0 (Grootslang)</div>
<div class="version-footer">CryptPad v1.6.0 (Hodag)</div>
</footer>
</body>