From bcd03038215160e0a70c0826e1af05fab0312451 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 19 May 2017 11:46:10 +0200 Subject: [PATCH 1/4] style /file/ with .less --- www/file/file.css | 70 ++++++++++++++++++++++++++++++++++++++ www/file/file.less | 82 +++++++++++++++++++++++++++++++++++++++++++++ www/file/inner.html | 79 +------------------------------------------ 3 files changed, 153 insertions(+), 78 deletions(-) create mode 100644 www/file/file.css create mode 100644 www/file/file.less diff --git a/www/file/file.css b/www/file/file.css new file mode 100644 index 000000000..08c95f730 --- /dev/null +++ b/www/file/file.css @@ -0,0 +1,70 @@ +html, +body { + margin: 0px; +} +.cryptpad-toolbar { + margin-bottom: 1px; + padding: 0px; + display: inline-block; +} +#file { + display: block; + height: 300px; + width: 300px; + border: 2px solid black; + margin: 50px; +} +.inputfile { + width: 0.1px; + height: 0.1px; + opacity: 0; + overflow: hidden; + position: absolute; + z-index: -1; +} +#upload-form { + padding: 0px; + margin: 0px; + position: relative; + width: 50vh; + height: 50vh; + display: block; + margin: auto; +} +#upload-form label { + position: relative; +} +.hovering { + background-color: rgba(255, 0, 115, 0.5) !important; +} +.block { + display: block; + height: 50vh; + width: 50vh; +} +.hidden { + display: none; +} +.inputfile + label { + border: 2px solid black; + background-color: rgba(50, 50, 50, 0.1); + margin: 50px; + display: block; +} +.inputfile:focus + label, +.inputfile + label:hover { + background-color: rgba(50, 50, 50, 0.3); +} +#progress { + position: absolute; + top: 0px; + left: 0px; + height: 100%; + transition: width 500ms; + width: 0%; + max-width: 100%; + max-height: 100%; + background-color: rgba(255, 0, 115, 0.75); + z-index: 10000; + display: block; +} diff --git a/www/file/file.less b/www/file/file.less new file mode 100644 index 000000000..69432a539 --- /dev/null +++ b/www/file/file.less @@ -0,0 +1,82 @@ +@import "../../customize.dist/src/less/variables.less"; +@import "../../customize.dist/src/less/mixins.less"; + +html, body { + margin: 0px; +} +.cryptpad-toolbar { + margin-bottom: 1px; + padding: 0px; + display: inline-block; +} +#file { + display: block; + height: 300px; + width: 300px; + border: 2px solid black; + margin: 50px; +} + +.inputfile { + width: 0.1px; + height: 0.1px; + opacity: 0; + overflow: hidden; + position: absolute; + z-index: -1; +} + +#upload-form { + padding: 0px; + margin: 0px; + + position: relative; + width: 50vh; + height: 50vh; + display: block; + margin: auto; +} +#upload-form label{ + position: relative; +} + +.hovering { + background-color: rgba(255, 0, 115, 0.5) !important; +} + +.block { + display: block; + height: 50vh; + width: 50vh; +} +.hidden { + display: none; +} +.inputfile + label { + border: 2px solid black; + background-color: rgba(50, 50, 50, .10); + margin: 50px; + display: block; +} + +.inputfile:focus + label, +.inputfile + label:hover { + background-color: rgba(50, 50, 50, 0.30); +} + +#progress { + position: absolute; + top: 0px; + left: 0px; + height: 100%; + + + transition: width 500ms; + width: 0%; + max-width: 100%; + max-height: 100%; + background-color: rgba(255, 0, 115, 0.75); + z-index: 10000; + display: block; +} + diff --git a/www/file/inner.html b/www/file/inner.html index 482fb4955..727e11498 100644 --- a/www/file/inner.html +++ b/www/file/inner.html @@ -5,84 +5,7 @@ - +
From e78299aed6a913a461142b80c37f21f722b7a0d1 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 19 May 2017 11:46:47 +0200 Subject: [PATCH 2/4] use async file decryption, listen for progress events. --- www/common/media-tag.js | 2 +- www/media/main.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/www/common/media-tag.js b/www/common/media-tag.js index cf8c78210..370b0e93d 100644 --- a/www/common/media-tag.js +++ b/www/common/media-tag.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MediaTag=t():e.MediaTag=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=82)}([function(e,t,n){"use strict";var r={IMAGE:"image",AUDIO:"audio",VIDEO:"video",PDF:"pdf",DASH:"dash",DOWNLOAD:"download",CRYPTO:"crypto",CLEAR_KEY:"clear-key",MEDIA_OBJECT:"media-object"};e.exports=r},function(e,t,n){"use strict";var r={MATCHER:"matcher",RENDERER:"renderer",FILTER:"filter",SANITIZER:"sanitizer"};e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var n=0;n=e.STACK_LIMIT)throw console.error(e.snapshots[n]),new Error("Plugin stack size exceed");if(e.snapshots[n].length>=e.SNAPSHOT_LIMIT)throw console.error(e.snapshots[n]),new Error("Plugin snapshots size exceed");var r=0;if(e.stacks[n].forEach(function(e){e.type===u.RENDERER&&r++}),r<1&&e.stacks[n].unshift(e.defaultPlugin),r>1)throw new Error("More of one renderer in the stack")}},{key:"return",value:function(t){e.start(t)}},{key:"run",value:function(t){var n=t.getId(),r=e.stacks[n].length,o=e.stacks[n][r-1];if(!o)throw console.log(e.stacks),new Error("Impossible to run a undefined plugin");o.process(t)}}]),e}();f.stacks={},f.STACK_LIMIT=1e3,f.snapshots={},f.SNAPSHOT_LIMIT=1e3,f.defaultPlugin=new s,e.exports=f},function(e,t,n){"use strict";var r={EVERY:"every",ANY:"any",ONCE:"once"};e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n1;){if(c){if("number"!=typeof e[t])throw new Error("E_UNSAFE_TYPE");if(e[t]>255)throw new Error("E_OUT_OF_BOUNDS")}if(255!==e[t])return void e[t]++;if(e[t]=0,0===t)throw new Error("E_NONCE_TOO_LARGE")}}},{key:"encodePrefix",value:function(e){return[65280,255].map(function(t,n){return(e&t)>>8*(1-n)})}},{key:"decodePrefix",value:function(e){return e[0]<<8|e[1]}},{key:"joinChunks",value:function(t){return new Uint8Array(t.reduce(function(t,n){return e.slice(t).concat(e.slice(n))},[]))}},{key:"slice",value:function(e){return Array.prototype.slice.call(e)}},{key:"getRandomKeyStr",value:function(){var t=e.Nacl,n=t.randomBytes(18);return t.util.encodeBase64(n)}},{key:"getKeyFromStr",value:function(t){return e.Nacl.util.decodeBase64(t)}},{key:"encrypt",value:function(t,n){var r=t,o=e.Nacl.randomBytes(24),i=e.Nacl.secretbox(r,o,n);if(i)return new Uint8Array(e.slice(o).concat(e.slice(i)));throw new Error}},{key:"decrypt",value:function(t,n){var r=e.Nacl,o=function(e){throw new Error(e||"DECRYPTION_ERROR")};o();var i=new Uint8Array(new Array(24).fill(0)),u=0,a=t.subarray(0,2),c=e.decodePrefix(a),f={metadata:void 0},l=new Uint8Array(t.subarray(2,2+c)),p=r.secretbox.open(l,i,n);e.increment(i);try{f.metadata=JSON.parse(r.util.encodeUTF8(p))}catch(e){return o("E_METADATA_DECRYPTION")}f.metadata||o("NO_METADATA");for(var y,b=function(){var o=u*s+2+c,a=o+s;u++;var f=new Uint8Array(t.subarray(o,a)),l=r.secretbox.open(f,i,n);return e.increment(i),l},h=[];u*s1?t[0]:window.location.protocol}},{key:"hostname",value:function(e){var t=e.getAttribute("src").split("://");return t.length>1?t[1].split("/")[0]:window.location.hostname}},{key:"source",value:function(e){return e.getAttribute("src")}},{key:"schemes",value:function(e){return/\w+:/.exec(e.getAttribute("src"))}},{key:"parse",value:function(t){return{protocol:e.protocol(t),hostname:e.hostname(t),src:e.source(t),type:e.type(t),extension:e.extension(t),mime:e.mime(t)}}}]),e}();e.exports=i},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var n=0;n=e.STACK_LIMIT)throw console.error(e.snapshots[n]),new Error("Plugin stack size exceed");if(e.snapshots[n].length>=e.SNAPSHOT_LIMIT)throw console.error(e.snapshots[n]),new Error("Plugin snapshots size exceed");var r=0;if(e.stacks[n].forEach(function(e){e.type===u.RENDERER&&r++}),r<1&&e.stacks[n].unshift(e.defaultPlugin),r>1)throw new Error("More of one renderer in the stack")}},{key:"return",value:function(t){e.start(t)}},{key:"run",value:function(t){var n=t.getId(),r=e.stacks[n].length,o=e.stacks[n][r-1];if(!o)throw console.log(e.stacks),new Error("Impossible to run a undefined plugin");o.process(t)}}]),e}();f.stacks={},f.STACK_LIMIT=1e3,f.snapshots={},f.SNAPSHOT_LIMIT=1e3,f.defaultPlugin=new s,e.exports=f},function(e,t,n){"use strict";var r={EVERY:"every",ANY:"any",ONCE:"once"};e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n1;){if(c){if("number"!=typeof e[t])throw new Error("E_UNSAFE_TYPE");if(e[t]>255)throw new Error("E_OUT_OF_BOUNDS")}if(255!==e[t])return void e[t]++;if(e[t]=0,0===t)throw new Error("E_NONCE_TOO_LARGE")}}},{key:"encodePrefix",value:function(e){return[65280,255].map(function(t,n){return(e&t)>>8*(1-n)})}},{key:"decodePrefix",value:function(e){return e[0]<<8|e[1]}},{key:"joinChunks",value:function(t){return new Uint8Array(t.reduce(function(t,n){return e.slice(t).concat(e.slice(n))},[]))}},{key:"slice",value:function(e){return Array.prototype.slice.call(e)}},{key:"getRandomKeyStr",value:function(){var t=e.Nacl,n=t.randomBytes(18);return t.util.encodeBase64(n)}},{key:"getKeyFromStr",value:function(t){return e.Nacl.util.decodeBase64(t)}},{key:"encrypt",value:function(t,n){var r=t,o=e.Nacl.randomBytes(24),i=e.Nacl.secretbox(r,o,n);if(i)return new Uint8Array(e.slice(o).concat(e.slice(i)));throw new Error}},{key:"decrypt",value:function(t,n,r){var o=e.Nacl,i=function(e){var n=new Event("decryptionProgress");n.percent=e/t.length*100,window.document.dispatchEvent(n)},u=e.createNonce(),a=0,c=t.subarray(0,2),f=e.decodePrefix(c),l={metadata:void 0},p=new Uint8Array(t.subarray(2,2+f)),y=o.secretbox.open(p,u,n);e.increment(u);try{l.metadata=JSON.parse(o.util.encodeUTF8(y))}catch(e){return r("E_METADATA_DECRYPTION")}if(!l.metadata)return r("NO_METADATA");var b=function(r){var c=a*s+2+f,l=c+s;a++;var p=new Uint8Array(t.subarray(c,l)),y=o.secretbox.open(p,u,n);if(e.increment(u),!y)return void r("DECRYPTION_FAILURE");i(Math.min(l,t.length)),r(void 0,y)},h=[];!function n(){b(function(o,i){return o?setTimeout(function(){r(o)}):i?a*s1?t[0]:window.location.protocol}},{key:"hostname",value:function(e){var t=e.getAttribute("src").split("://");return t.length>1?t[1].split("/")[0]:window.location.hostname}},{key:"source",value:function(e){return e.getAttribute("src")}},{key:"schemes",value:function(e){return/\w+:/.exec(e.getAttribute("src"))}},{key:"parse",value:function(t){return{protocol:e.protocol(t),hostname:e.hostname(t),src:e.source(t),type:e.type(t),extension:e.extension(t),mime:e.mime(t)}}}]),e}();e.exports=i},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var n=0;n Date: Fri, 19 May 2017 14:37:00 +0200 Subject: [PATCH 3/4] move rpc warnings out of server and into rpc --- rpc.js | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/rpc.js b/rpc.js index 2f2b96a4c..e7d3c1627 100644 --- a/rpc.js +++ b/rpc.js @@ -286,7 +286,10 @@ var getFileSize = function (Env, channel, cb) { } return void Env.msgStore.getChannelSize(channel, function (e, size) { - if (e) { return void cb(e.code); } + if (e) { + if (e === 'ENOENT') { return void cb(void 0, 0); } + return void cb(e.code); + } cb(void 0, size); }); } @@ -331,7 +334,7 @@ var getTotalSize = function (Env, publicKey, cb) { //var msgStore = Env.msgStore; return void getChannelList(Env, publicKey, function (channels) { - if (!channels) { cb('NO_ARRAY'); } // unexpected + if (!channels) { return cb('NO_ARRAY'); } // unexpected var count = channels.length; if (!count) { cb(void 0, 0); } @@ -755,6 +758,12 @@ RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function) // load pin-store... console.log('loading rpc module...'); + var warn = function (e, output) { + if (e && !config.suppressRPCErrors) { + console.error('[' + e + ']', output); + } + }; + var keyOrDefaultString = function (key, def) { return typeof(config[key]) === 'string'? config[key]: def; }; @@ -848,40 +857,59 @@ RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function) case 'COOKIE': return void Respond(void 0); case 'RESET': return resetUserPins(Env, safeKey, msg[1], function (e, hash) { + //warn(e, hash); return void Respond(e, hash); }); case 'PIN': return pinChannel(Env, safeKey, msg[1], function (e, hash) { + warn(e, hash); Respond(e, hash); }); case 'UNPIN': return unpinChannel(Env, safeKey, msg[1], function (e, hash) { + warn(e, hash); Respond(e, hash); }); case 'GET_HASH': return void getHash(Env, safeKey, function (e, hash) { + warn(e, hash); Respond(e, hash); }); case 'GET_TOTAL_SIZE': // TODO cache this, since it will get called quite a bit return getTotalSize(Env, safeKey, function (e, size) { - if (e) { return void Respond(e); } + if (e) { + warn(e, safeKey); + return void Respond(e); + } Respond(e, size); }); case 'GET_FILE_SIZE': - return void getFileSize(Env, msg[1], Respond); + return void getFileSize(Env, msg[2], function (e, size) { + warn(e, msg[2]); + Respond(e, size); + }); case 'UPDATE_LIMITS': return void updateLimits(config, safeKey, function (e, limit) { - if (e) { return void Respond(e); } + if (e) { + warn(e, limit); + return void Respond(e); + } Respond(void 0, limit); }); case 'GET_LIMIT': return void getLimit(Env, safeKey, function (e, limit) { - if (e) { return void Respond(e); } + if (e) { + warn(e, limit); + return void Respond(e); + } Respond(void 0, limit); }); case 'GET_MULTIPLE_FILE_SIZE': return void getMultipleFileSize(Env, msg[1], function (e, dict) { - if (e) { return void Respond(e); } + if (e) { + warn(e, dict); + return void Respond(e); + } Respond(void 0, dict); }); @@ -889,6 +917,7 @@ RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function) case 'UPLOAD': if (!privileged) { return deny(); } return void upload(Env, safeKey, msg[1], function (e, len) { + warn(e, len); Respond(e, len); }); case 'UPLOAD_STATUS': @@ -906,11 +935,13 @@ RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function) case 'UPLOAD_COMPLETE': if (!privileged) { return deny(); } return void upload_complete(Env, safeKey, function (e, hash) { + warn(e, hash); Respond(e, hash); }); case 'UPLOAD_CANCEL': if (!privileged) { return deny(); } return void upload_cancel(Env, safeKey, function (e) { + warn(e); Respond(e); }); default: From 0d265f543ea1f46e9b69665f817dc17c0b610544 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 19 May 2017 14:41:55 +0200 Subject: [PATCH 4/4] add file.css to npm style command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dd089605c..e75ec7b32 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "scripts": { "lint": "jshint --config .jshintrc --exclude-path .jshintignore .", "test": "node TestSelenium.js", - "style": "lessc ./customize.dist/src/less/cryptpad.less > ./customize.dist/main.css && lessc ./customize.dist/src/less/toolbar.less > ./customize.dist/toolbar.css && lessc ./www/drive/file.less > ./www/drive/file.css && lessc ./www/settings/main.less > ./www/settings/main.css && lessc ./www/slide/slide.less > ./www/slide/slide.css && lessc ./www/whiteboard/whiteboard.less > ./www/whiteboard/whiteboard.css && lessc ./www/poll/poll.less > ./www/poll/poll.css", + "style": "lessc ./customize.dist/src/less/cryptpad.less > ./customize.dist/main.css && lessc ./customize.dist/src/less/toolbar.less > ./customize.dist/toolbar.css && lessc ./www/drive/file.less > ./www/drive/file.css && lessc ./www/settings/main.less > ./www/settings/main.css && lessc ./www/slide/slide.less > ./www/slide/slide.css && lessc ./www/whiteboard/whiteboard.less > ./www/whiteboard/whiteboard.css && lessc ./www/poll/poll.less > ./www/poll/poll.css && lessc ./www/file/file.less > ./www/file/file.css", "template": "cd customize.dist/src && node build.js" } }