diff --git a/.gitignore b/.gitignore
index 139fab33c..fc1136152 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,4 +13,5 @@ data
npm-debug.log
pins/
blob/
+blobstage/
privileged.conf
diff --git a/.travis.yml b/.travis.yml
index 4160b8719..09967f1f1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,12 @@
language: node_js
env:
matrix:
- - "BROWSER='firefox:19:Windows 2012'"
- - "BROWSER='chrome::Windows 2008'"
+ - "BROWSER='firefox::Windows 10'"
+ - "BROWSER='chrome::Windows 10'"
+ #- "BROWSER='MicrosoftEdge:14.14393:Windows 10'"
+ #- "BROWSER='internet explorer:11.103:Windows 10'"
+ #- "BROWSER='safari:10.0:macOS 10.12'"
+ #- "BROWSER='safari:9.0:OS X 10.11'"
branches:
only:
- master
diff --git a/TestSelenium.js b/TestSelenium.js
index 9623577b5..fccd4e067 100644
--- a/TestSelenium.js
+++ b/TestSelenium.js
@@ -1,11 +1,13 @@
/* global process */
var WebDriver = require("selenium-webdriver");
+var nThen = require('nthen');
if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
// We can't do saucelabs on pull requests so don't fail.
return;
}
+// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
var driver;
if (process.env.SAUCE_USERNAME !== undefined) {
var browserArray = process.env.BROWSER.split(':');
@@ -21,18 +23,59 @@ if (process.env.SAUCE_USERNAME !== undefined) {
driver = new WebDriver.Builder().withCapabilities({ browserName: "chrome" }).build();
}
-driver.get('http://localhost:3000/assert/');
-var report = driver.wait(WebDriver.until.elementLocated(WebDriver.By.className("report")), 5000);
-report.getAttribute("class").then(function (cls) {
- report.getText().then(function (text) {
- console.log("\n-----\n" + text + "\n-----");
- driver.quit();
- if (!cls) {
- throw new Error("cls is null");
- } else if (cls.indexOf("failure") !== -1) {
- throw new Error("cls contains the word failure");
- } else if (cls.indexOf("success") === -1) {
- throw new Error("cls does not contain the word success");
- }
- });
+var SC_GET_DATA = "return (window.__CRYPTPAD_TEST__) ? window.__CRYPTPAD_TEST__.getData() : '[]'";
+
+var failed = false;
+var nt = nThen;
+[
+ //'/register/#?test=test',
+ '/assert/#?test=test',
+ // '/auth/#?test=test' // TODO(cjd): Not working on automatic tests, understand why.
+].forEach(function (path) {
+ if (failed) { return; }
+ var url = 'http://localhost:3000' + path;
+ nt = nt(function (waitFor) {
+ var done = waitFor();
+ console.log('\n\n-----TEST ' + url + ' -----');
+ var waitTo = setTimeout(function () {
+ console.log("no report in 20 seconds, timing out");
+ failed = true;
+ done();
+ done = undefined;
+ }, 20000);
+ var logMore = function () {
+ if (!done) { return; }
+ driver.executeScript(SC_GET_DATA).then(waitFor(function (dataS) {
+ if (!done) { return; }
+ var data = JSON.parse(dataS);
+ data.forEach(function (d) {
+ if (d.type !== 'log') { return; }
+ console.log('>' + d.val);
+ });
+ data.forEach(function (d) {
+ if (d.type !== 'report') { return; }
+ console.log('RESULT: ' + d.val);
+ if (d.val !== 'passed') {
+ if (d.error) {
+ console.log(d.error.message);
+ console.log(d.error.stack);
+ }
+ failed = true;
+ }
+ clearTimeout(waitTo);
+ console.log('-----END TEST ' + url + ' -----');
+ done();
+ done = undefined;
+ });
+ if (done) { setTimeout(logMore, 50); }
+ }));
+ };
+ driver.get(url).then(waitFor(logMore));
+ }).nThen;
+});
+
+nt(function (waitFor) {
+ driver.quit().then(waitFor(function () {
+ if (failed) { process.exit(100); }
+ }));
});
diff --git a/bower.json b/bower.json
index 5734be6ec..0c80203da 100644
--- a/bower.json
+++ b/bower.json
@@ -37,6 +37,7 @@
"diff-dom": "^2.1.1",
"alertifyjs": "^1.0.11",
"scrypt-async": "^1.2.0",
- "bootstrap": "#v4.0.0-alpha.6"
+ "bootstrap": "#v4.0.0-alpha.6",
+ "pdfjs-dist": "^1.8.398"
}
}
diff --git a/config.example.js b/config.example.js
index fe3f2fb91..c7a831b4c 100644
--- a/config.example.js
+++ b/config.example.js
@@ -10,7 +10,7 @@ module.exports = {
// the port on which your httpd will listen
- /* Cryptpad can be configured to send customized HTTP Headers
+ /* CryptPad can be configured to send customized HTTP Headers
* These settings may vary widely depending on your needs
* Examples are provided below
*/
@@ -31,18 +31,23 @@ module.exports = {
* connect-src is used to restrict what domains can connect to the websocket.
*
* it is recommended that you configure these fields to match the
- * domain which will serve your cryptpad instance.
+ * domain which will serve your CryptPad instance.
*/
"child-src 'self' *",
+ "media-src *",
+
/* this allows connections over secure or insecure websockets
if you are deploying to production, you'll probably want to remove
the ws://* directive, and change '*' to your domain
*/
- "connect-src 'self' ws: wss:",
+ "connect-src 'self' ws: wss: blob:",
// data: is used by codemirror
"img-src 'self' data: blob:",
+
+ // for accounts.cryptpad.fr authentication
+ "frame-ancestors 'self' accounts.cryptpad.fr",
].join('; '),
// CKEditor requires significantly more lax content security policy in order to function.
@@ -82,24 +87,24 @@ module.exports = {
*/
//websocketPort: 3000,
- /* if you want to run a different version of cryptpad but using the same websocket
+ /* if you want to run a different version of CryptPad but using the same websocket
* server, you should use the other server port as websocketPort and disable
* the websockets on that server
*/
//useExternalWebsocket: false,
- /* If Cryptpad is proxied without using https, the server needs to know.
+ /* If CryptPad is proxied without using https, the server needs to know.
* Specify 'useSecureWebsockets: true' so that it can send
* Content Security Policy Headers that prevent http and https from mixing
*/
useSecureWebsockets: false,
- /* Cryptpad can log activity to stdout
+ /* CryptPad can log activity to stdout
* This may be useful for debugging
*/
logToStdout: false,
- /* Cryptpad supports verbose logging
+ /* CryptPad supports verbose logging
* (false by default)
*/
verbose: false,
@@ -116,11 +121,57 @@ module.exports = {
'contact',
],
- /* Domain
- * If you want to have enable payments on your CryptPad instance, it has to be able to tell
- * our account server what is your domain
+ /* Limits, Donations, Subscriptions and Contact
+ *
+ * By default, CryptPad limits every registered user to 50MB of storage. It also shows a
+ * donate button which allows for making a donation to support CryptPad development.
+ *
+ * You can either:
+ * A: Leave it exactly as it is.
+ * B: Hide the donate button.
+ * C: Change the donate button to a subscribe button, people who subscribe will get more
+ * storage on your instance and you get 50% of the revenue earned.
+ *
+ * CryptPad is developed by people who need to live and who deserve an equivilent life to
+ * what they would get at a company which monitizes user data. However, we intend to have
+ * a mutually positive relationship with every one of our users, including you. If you are
+ * getting value from CryptPad, you should be giving equal value back.
+ *
+ * If you are using CryptPad in a business context, please consider taking a support contract
+ * by contacting sales@cryptpad.fr
+ *
+ * If you choose A then there's nothing to do.
+ *
+ * If you choose B, set this variable to true and it will remove the donate button.
+ */
+ removeDonateButton: false,
+ /*
+ * If you choose C, set allowSubscriptions to true, then set myDomain to the domain which people
+ * use to reach your CryptPad instance. Then contact sales@cryptpad.fr and tell us your domain.
+ * We will tell you what is needed to get paid.
+ */
+ allowSubscriptions: false,
+ myDomain: 'i.did.not.read.my.config.myserver.tld',
+
+ /*
+ * If you are using CryptPad internally and you want to increase the per-user storage limit,
+ * change the following value.
+ *
+ * Please note: This limit is what makes people subscribe and what pays for CryptPad
+ * development. Running a public instance that provides a "better deal" than cryptpad.fr
+ * is effectively using the project against itself.
+ */
+ defaultStorageLimit: 50 * 1024 * 1024,
+
+ /*
+ * By default, CryptPad also contacts our accounts server once a day to check for changes in
+ * the people who have accounts. This check-in will also send the version of your CryptPad
+ * instance and your email so we can reach you if we are aware of a serious problem. We will
+ * never sell it or send you marketing mail. If you want to block this check-in and remain
+ * completely invisible, set this and allowSubscriptions both to false.
*/
- // domain: 'https://cryptpad.fr',
+ adminEmail: 'i.did.not.read.my.config@cryptpad.fr',
+
/*
You have the option of specifying an alternative storage adaptor.
@@ -141,7 +192,7 @@ module.exports = {
storage: './storage/file',
/*
- Cryptpad stores each document in an individual file on your hard drive.
+ CryptPad stores each document in an individual file on your hard drive.
Specify a directory where files should be stored.
It will be created automatically if it does not already exist.
*/
@@ -164,17 +215,17 @@ module.exports = {
*/
blobStagingPath: './blobstage',
- /* Cryptpad's file storage adaptor closes unused files after a configurale
+ /* CryptPad's file storage adaptor closes unused files after a configurale
* number of milliseconds (default 30000 (30 seconds))
*/
channelExpirationMs: 30000,
- /* Cryptpad's file storage adaptor is limited by the number of open files.
+ /* CryptPad's file storage adaptor is limited by the number of open files.
* When the adaptor reaches openFileLimit, it will clean up older files
*/
openFileLimit: 2048,
- /* Cryptpad's socket server can be extended to respond to RPC calls
+ /* CryptPad's socket server can be extended to respond to RPC calls
* you can configure it to respond to custom RPC calls if you like.
* provide the path to your RPC module here, or `false` if you would
* like to disable the RPC interface completely
@@ -211,12 +262,6 @@ module.exports = {
*/
//restrictUploads: false,
- /* Default user storage limit (bytes)
- * if you don't want to limit users,
- * you can set this to the size of your hard disk
- */
- defaultStorageLimit: 50 * 1024 * 1024,
-
/* Max Upload Size (bytes)
* this sets the maximum size of any one file uploaded to the server.
* anything larger than this size will be rejected
@@ -232,7 +277,7 @@ module.exports = {
*/
//logFeedback: true,
- /* it is recommended that you serve cryptpad over https
+ /* it is recommended that you serve CryptPad over https
* the filepaths below are used to configure your certificates
*/
//privKeyAndCertFiles: [
diff --git a/customize.dist/BottomBar.html b/customize.dist/BottomBar.html
deleted file mode 100644
index c8d43dfce..000000000
--- a/customize.dist/BottomBar.html
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
diff --git a/customize.dist/about.html b/customize.dist/about.html
index 954a3fb6f..dadd21e3b 100644
--- a/customize.dist/about.html
+++ b/customize.dist/about.html
@@ -39,6 +39,9 @@
Blog
+
+
+
@@ -114,7 +117,7 @@
-
+
diff --git a/www/code/main.js b/www/code/main.js
index 660473ffd..5e9983fe6 100644
--- a/www/code/main.js
+++ b/www/code/main.js
@@ -53,6 +53,7 @@ define([
var andThen = function (CMeditor) {
var CodeMirror = Cryptpad.createCodemirror(CMeditor, ifrw, Cryptpad);
+ $iframe.find('.CodeMirror').addClass('fullPage');
editor = CodeMirror.editor;
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
@@ -110,8 +111,16 @@ define([
return stringify(obj);
};
+ var forceDrawPreview = function () {
+ try {
+ DiffMd.apply(DiffMd.render(editor.getValue()), $preview);
+ } catch (e) { console.error(e); }
+ };
+
var drawPreview = Cryptpad.throttle(function () {
- DiffMd.apply(DiffMd.render(editor.getValue()), $preview);
+ if (CodeMirror.highlightMode !== 'markdown') { return; }
+ if (!$previewContainer.is(':visible')) { return; }
+ forceDrawPreview();
}, 150);
var onLocal = config.onLocal = function () {
@@ -137,8 +146,13 @@ define([
var $codeMirror = $iframe.find('.CodeMirror');
if (mode === "markdown") {
APP.$previewButton.show();
- $previewContainer.show();
- $codeMirror.removeClass('fullPage');
+ Cryptpad.getPadAttribute('previewMode', function (e, data) {
+ if (e) { return void console.error(e); }
+ if (data !== false) {
+ $previewContainer.show();
+ $codeMirror.removeClass('fullPage');
+ }
+ });
return;
}
APP.$previewButton.hide();
@@ -155,7 +169,7 @@ define([
Metadata = Cryptpad.createMetadata(UserList, Title);
var configTb = {
- displayed: ['title', 'useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad', 'limit'],
+ displayed: ['title', 'useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad', 'limit', 'upgrade'],
userList: UserList.getToolbarConfig(),
share: {
secret: secret,
@@ -183,8 +197,8 @@ define([
/* add a history button */
var histConfig = {
- onLocal: config.onLocal(),
- onRemote: config.onRemote(),
+ onLocal: config.onLocal,
+ onRemote: config.onRemote,
setHistory: setHistory,
applyVal: function (val) {
var remoteDoc = JSON.parse(val || '{}').content;
@@ -235,9 +249,16 @@ define([
}
$previewContainer.toggle();
if ($previewContainer.is(':visible')) {
+ forceDrawPreview();
$codeMirror.removeClass('fullPage');
+ Cryptpad.setPadAttribute('previewMode', true, function (e) {
+ if (e) { return console.log(e); }
+ });
} else {
$codeMirror.addClass('fullPage');
+ Cryptpad.setPadAttribute('previewMode', false, function (e) {
+ if (e) { return console.log(e); }
+ });
}
});
$rightside.append($previewButton);
@@ -251,6 +272,7 @@ define([
CodeMirror.configureTheme();
}
+
// set the hash
if (!readOnly) { Cryptpad.replaceHash(editHash); }
};
@@ -302,6 +324,13 @@ define([
Title.updateTitle(Cryptpad.initialName);
}
+ Cryptpad.getPadAttribute('previewMode', function (e, data) {
+ if (e) { return void console.error(e); }
+ if (data === false && APP.$previewButton) {
+ APP.$previewButton.click();
+ }
+ });
+
Cryptpad.removeLoadingScreen();
setEditable(true);
initializing = false;
diff --git a/www/common/boot2.js b/www/common/boot2.js
index d894191e8..76ce9bcf9 100644
--- a/www/common/boot2.js
+++ b/www/common/boot2.js
@@ -7,7 +7,9 @@ define([], function () {
// jquery declares itself as literally "jquery" so it cannot be pulled by path :(
"jquery": "/bower_components/jquery/dist/jquery.min",
// json.sortify same
- "json.sortify": "/bower_components/json.sortify/dist/JSON.sortify"
+ "json.sortify": "/bower_components/json.sortify/dist/JSON.sortify",
+ "pdfjs-dist/build/pdf": "/bower_components/pdfjs-dist/build/pdf",
+ "pdfjs-dist/build/pdf.worker": "/bower_components/pdfjs-dist/build/pdf.worker"
}
});
diff --git a/www/common/common-interface.js b/www/common/common-interface.js
index b2b5dad10..5d1e01cc8 100644
--- a/www/common/common-interface.js
+++ b/www/common/common-interface.js
@@ -194,10 +194,17 @@ define([
};
UI.removeLoadingScreen = function (cb) {
$('#' + LOADING).fadeOut(750, cb);
- $('#loadingTip').css('top', '');
- window.setTimeout(function () {
- $('#loadingTip').fadeOut(750);
- }, 3000);
+ var $tip = $('#loadingTip').css('top', '')
+ // loading.less sets transition-delay: $wait-time
+ // and transition: opacity $fadeout-time
+ .css({
+ 'opacity': 0,
+ 'pointer-events': 'none',
+ });
+ setTimeout(function () {
+ $tip.remove();
+ }, 3750);
+ // jquery.fadeout can get stuck
};
UI.errorLoadingScreen = function (error, transparent) {
if (!$('#' + LOADING).is(':visible')) { UI.addLoadingScreen(undefined, true); }
diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js
index 50e99547b..b5707639d 100644
--- a/www/common/cryptpad-common.js
+++ b/www/common/cryptpad-common.js
@@ -25,7 +25,10 @@ define([
*/
var common = window.Cryptpad = {
Messages: Messages,
- Clipboard: Clipboard
+ Clipboard: Clipboard,
+ donateURL: 'https://accounts.cryptpad.fr/#/donate?on=' + window.location.hostname,
+ upgradeURL: 'https://accounts.cryptpad.fr/#/?on=' + window.location.hostname,
+ account: {},
};
// constants
@@ -216,6 +219,7 @@ define([
userNameKey,
userHashKey,
'loginToken',
+ 'plan',
].forEach(function (k) {
sessionStorage.removeItem(k);
localStorage.removeItem(k);
@@ -244,6 +248,11 @@ define([
var getUserHash = common.getUserHash = function () {
var hash = localStorage[userHashKey];
+ if (['undefined', 'undefined/'].indexOf(hash) !== -1) {
+ localStorage.removeItem(userHashKey);
+ return;
+ }
+
if (hash) {
var sHash = common.serializeHash(hash);
if (sHash !== hash) { localStorage[userHashKey] = sHash; }
@@ -575,7 +584,7 @@ define([
var data = makePad(href, name);
getStore().pushData(data, function (e, id) {
if (e) {
- if (e === 'E_OVER_LIMIT' && AppConfig.enablePinLimit) {
+ if (e === 'E_OVER_LIMIT') {
common.alert(Messages.pinLimitNotPinned, null, true);
return;
}
@@ -741,7 +750,7 @@ define([
};
common.isOverPinLimit = function (cb) {
- if (!common.isLoggedIn() || !AppConfig.enablePinLimit) { return void cb(null, false); }
+ if (!common.isLoggedIn()) { return void cb(null, false); }
var usage;
var andThen = function (e, limit, plan) {
if (e) { return void cb(e); }
@@ -775,7 +784,6 @@ define([
};
var LIMIT_REFRESH_RATE = 30000; // milliseconds
- var limitReachedDisplayed = false;
common.createUsageBar = function (cb, alwaysDisplayUpgrade) {
var todo = function (err, state, data) {
var $container = $('', {'class':'limit-container'});
@@ -797,7 +805,10 @@ define([
var width = Math.floor(Math.min(quota, 1)*200); // the bar is 200px width
var $usage = $('', {'class': 'usage'}).css('width', width+'px');
- if ((quota >= 0.8 || alwaysDisplayUpgrade) && data.plan !== "power") {
+ if (Config.noSubscriptionButton !== true &&
+ (quota >= 0.8 || alwaysDisplayUpgrade) &&
+ data.plan !== "power")
+ {
var origin = encodeURIComponent(window.location.hostname);
var $upgradeLink = $('', {
href: "https://accounts.cryptpad.fr/#!on=" + origin,
@@ -823,13 +834,7 @@ define([
if (quota < 0.8) { $usage.addClass('normal'); }
else if (quota < 1) { $usage.addClass('warning'); }
- else {
- $usage.addClass('above');
- if (!limitReachedDisplayed) {
- limitReachedDisplayed = true;
- common.alert(Messages._getKey('pinAboveLimitAlert', [prettyUsage, encodeURIComponent(window.location.hostname)]), null, true);
- }
- }
+ else { $usage.addClass('above'); }
var $text = $('', {'class': 'usageText'});
$text.text(usage + ' / ' + prettyLimit);
$limit.append($usage).append($text);
@@ -1405,6 +1410,14 @@ define([
console.log('RPC handshake complete');
rpc = common.rpc = env.rpc = call;
+ common.getPinLimit(function (e, limit, plan, note) {
+ if (e) { return void console.error(e); }
+ common.account.limit = limit;
+ localStorage.plan = common.account.plan = plan;
+ common.account.note = note;
+ cb();
+ });
+
common.arePinsSynced(function (err, yes) {
if (!yes) {
common.resetPins(function (err) {
@@ -1413,7 +1426,6 @@ define([
});
}
});
- cb();
});
} else if (PINNING_ENABLED) {
console.log('not logged in. pads will not be pinned');
diff --git a/www/common/fsStore.js b/www/common/fsStore.js
index 4e5f2f056..787cedf07 100644
--- a/www/common/fsStore.js
+++ b/www/common/fsStore.js
@@ -170,6 +170,10 @@ define([
proxy[tokenKey] = Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);
}
+ // copy User_hash into sessionStorage because cross-domain iframes
+ // on safari replaces localStorage with sessionStorage or something
+ if (sessionStorage) { sessionStorage.setItem('User_hash', localStorage.getItem('User_hash')); }
+
var localToken = tryParsing(localStorage.getItem(tokenKey));
if (localToken === null) {
// if that number hasn't been set to localStorage, do so.
diff --git a/www/common/media-tag.js b/www/common/media-tag.js
index 370b0e93d..d5d1143e9 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,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=0&&f.mediaTypes.splice(t,1)},f.removeAllAllowedMediaTypes=function(e){e.forEach(function(e){f.removeAllowedMediaType(e)})},f.isAllowedMediaType=function(e){return f.mediaTypes.some(function(t){return t===e})},e.exports=f},,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;n MediaTag cannot find a plugin able to renderer your content ","Download");r.processingEngine.setDefaultPlugin(b),r.CryptoFilter=f;var v=["image/png","image/jpeg","image/jpg","image/gif","audio/mp3","audio/ogg","audio/wav","audio/webm","video/mp4","video/ogg","video/webm","application/pdf","application/dash+xml","download"];r.CryptoFilter.setAllowedMediaTypes(v);var g=n(21),d=(n(13),n(0),new g);r.processingEngine.configure(d),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=n(1),a=n(5),c=n(6),s=function(e){function t(e){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.SANITIZER,a.EVERY))}return i(t,e),t}(c);e.exports=s},,,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){var n=t.type.split("/"),r=t.type,o=n[0],i=n[1];s.isAllowedMediaType(r)?(e.setAttribute("data-type",t.type),e.type=o,e.extension=i,e.mime=r):console.log("Not allowed metadata, allowed ones are : ",s.getAllowedMediaTypes()),e.name=t.name,e.setAttribute("data-attr-type",t.type)}function i(e){var t=e.getAttribute("src"),n=e.getAttribute("data-crypto-key"),r=p.getKeyFromStr(n),i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer";var u=function(e){var t=new Event("decryptionError");t.message="string"==typeof e?e:e.message,window.document.dispatchEvent(t)};i.onload=function(){if(/^4/.test(""+this.status))return u("XHR_ERROR",""+this.status);var t=i.response;if(t){var n=new Uint8Array(t);p.decrypt(n,r,function(t,n){if(t)return u(t);var r=n.content,i=y.getBlobUrl(r,e.getMimeType()),a=new Event("decryption");a.blob=new Blob([r],{type:e.getMimeType()}),a.metadata=n.metadata,e.setAttribute("src",i),e.removeAttribute("data-crypto-key"),o(e,n.metadata),a.callback=function(){c.processingEngine.return(e)},window.document.dispatchEvent(a)})}},i.send(null)}var u=function(){function e(e,t){for(var n=0;n1;){if(f){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),s=e.decodePrefix(c),f={metadata:void 0},p=new Uint8Array(t.subarray(2,2+s)),y=o.secretbox.open(p,u,n);e.increment(u);try{f.metadata=JSON.parse(o.util.encodeUTF8(y))}catch(e){return r("E_METADATA_DECRYPTION")}if(!f.metadata)return r("NO_METADATA");var h=function(r){var c=a*l+2+s,f=c+l;a++;var p=new Uint8Array(t.subarray(c,f)),y=o.secretbox.open(p,u,n);if(e.increment(u),!y)return void r("DECRYPTION_FAILURE");i(Math.min(f,t.length)),r(void 0,y)},b=[];!function n(){h(function(o,i){return o?setTimeout(function(){r(o)}):i?a*l1?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")}var o=function(){function e(e,t){for(var n=0;n=e.STACK_LIMIT)throw console.error(this.snapshots[n]),new Error("Plugin stack size exceed");if(this.snapshots[n].length>=e.SNAPSHOT_LIMIT)throw console.error(this.snapshots[n]),new Error("Plugin snapshots size exceed");var r=0;if(this.stacks[n].forEach(function(e){e.type===a.RENDERER&&r++}),r>1)throw console.error(this.snapshots[n]),new Error("More of one renderer in the stack");if(0===this.stacks[n].length&&!this.stats[n][a.RENDERER]){if(!this.defaultPlugin)throw new Error("No default plugin assignated");this.stacks[n].unshift(this.defaultPlugin)}}},{key:"return",value:function(e){var t=e.getId(),n=this.unstack(e);this.stats[t]||(this.stats[t]={}),this.stats[t][n.type]?this.stats[t][n.type]+=1:this.stats[t][n.type]=1,0===this.stacks[t].length&&n.type===a.RENDERER?this.run(e):n.type!==a.SANITIZER&&this.fill(e),this.snapshot(e),this.check(e),this.run(e)}},{key:"process",value:function(e){var t=e.getId(),n=this.stacks[t].length,r=this.stacks[t][n-1];if(!r)throw console.log(this.stacks),new Error("Impossible to run a undefined plugin");r.process(e)}},{key:"isStacked",value:function(e,t){var n=e.getId();return!(!this.stacks[n]||!this.stacks[n].includes(t))}},{key:"setDefaultPlugin",value:function(e){this.defaultPlugin=e}}]),e}();f.STACK_LIMIT=100,f.SNAPSHOT_LIMIT=100,e.exports=f},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 -1) {
+ var cpt = window.__CRYPTPAD_TEST__ = {
+ data: [],
+ getData: function () {
+ var data = JSON.stringify(cpt.data);
+ cpt.data = [];
+ return data;
+ }
+ };
+
+ // jshint -W103
+ var errProto = (new Error()).__proto__;
+ var doLog = function (o) {
+ var s;
+ if (typeof(o) === 'object' && o.__proto__ === errProto) {
+ s = JSON.stringify([ o.message, o.stack ]);
+ } else if (typeof(s) !== 'string') {
+ try {
+ s = JSON.stringify(o);
+ } catch (e) {
+ s = String(o);
+ }
+ }
+ var out = [s];
+ try { throw new Error(); } catch (e) { out.push(e.stack.split('\n')[3]); }
+ cpt.data.push({ type: 'log', val: out.join('') });
+ };
+
+ window.console._error = window.console.error;
+ window.console._log = window.console.log;
+ window.console.error = function (e) { window.console._error(e); doLog(e); };
+ window.console.log = function (l) { window.console._log(l); doLog(l); };
+
+ window.onerror = function (msg, url, lineNo, columnNo, e) {
+ cpt.data.push({
+ type: 'report',
+ val: 'failed',
+ error: {
+ message: e ? e.message : msg,
+ stack: e ? e.stack : (url + ":" + lineNo)
+ }
+ });
+ };
+ require.onError = function (e) {
+ cpt.data.push({
+ type: 'report',
+ val: 'failed',
+ error: { message: e.message, stack: e.stack }
+ });
+ };
+ out = function (f) { f(); };
+ out.testing = true;
+ out.passed = function () {
+ cpt.data.push({
+ type: 'report',
+ val: 'passed'
+ });
+ };
+ out.failed = function (reason) {
+ var e;
+ try { throw new Error(reason); } catch (err) { e = err; }
+ cpt.data.push({
+ type: 'report',
+ val: 'failed',
+ error: { message: e.message, stack: e.stack }
+ });
+ };
+ } else {
+ out.testing = false;
+ }
+ return out;
+});
diff --git a/www/common/toolbar.js b/www/common/toolbar.js
index 6920c0b0d..bf08fcb07 100644
--- a/www/common/toolbar.js
+++ b/www/common/toolbar.js
@@ -500,8 +500,12 @@ define([
var todo = function (e, overLimit) {
if (e) { return void console.error("Unable to get the pinned usage"); }
if (overLimit) {
+ var message = Messages.pinLimitReachedAlert;
+ if (ApiConfig.noSubscriptionButton === true) {
+ message = Messages.pinLimitReachedAlertNoAccounts;
+ }
$limit.show().click(function () {
- Cryptpad.alert(Messages.pinLimitReachedAlert, null, true);
+ Cryptpad.alert(message, null, true);
});
}
};
diff --git a/www/common/toolbar2.js b/www/common/toolbar2.js
index 57d113a48..8740606ee 100644
--- a/www/common/toolbar2.js
+++ b/www/common/toolbar2.js
@@ -10,7 +10,7 @@ define([
constants: {},
};
- var SPINNER_DISAPPEAR_TIME = 3000;
+ var SPINNER_DISAPPEAR_TIME = 1000;
// Toolbar parts
var TOOLBAR_CLS = Bar.constants.toolbar = 'cryptpad-toolbar';
@@ -33,6 +33,7 @@ define([
var LIMIT_CLS = Bar.constants.lag = 'cryptpad-limit';
var TITLE_CLS = Bar.constants.title = "cryptpad-title";
var NEWPAD_CLS = Bar.constants.newpad = "cryptpad-newpad";
+ var UPGRADE_CLS = Bar.constants.upgrade = "cryptpad-upgrade";
// User admin menu
var USERADMIN_CLS = Bar.constants.user = 'cryptpad-user-dropdown';
@@ -70,6 +71,7 @@ define([
var $userContainer = $('', {
'class': USER_CLS
}).appendTo($topContainer);
+ $('', {'class': UPGRADE_CLS + ' buttonSuccess'}).hide().appendTo($userContainer);
$('', {'class': SPINNER_CLS}).hide().appendTo($userContainer);
$('', {'class': STATE_CLS}).hide().appendTo($userContainer);
$('', {'class': LAG_CLS}).hide().appendTo($userContainer);
@@ -595,7 +597,6 @@ define([
'class': 'synced fa fa-check',
title: Messages.synced
}).appendTo($spin);
- toolbar.$userAdmin.prepend($spin);
if (config.realtime) {
config.realtime.onPatch(ks(toolbar, config));
config.realtime.onMessage(ks(toolbar, config, true));
@@ -616,8 +617,12 @@ define([
var todo = function (e, overLimit) {
if (e) { return void console.error("Unable to get the pinned usage"); }
if (overLimit) {
+ var key = 'pinLimitReachedAlert';
+ if (ApiConfig.noSubscriptionButton === true) {
+ key = 'pinLimitReachedAlertNoAccounts';
+ }
$limit.show().click(function () {
- Cryptpad.alert(Messages._getKey('pinLimitReachedAlert', [encodeURIComponent(window.location.hostname)]), null, true);
+ Cryptpad.alert(Messages._getKey(key, [encodeURIComponent(window.location.hostname)]), null, true);
});
}
};
@@ -631,6 +636,8 @@ define([
var pads_options = [];
Config.availablePadTypes.forEach(function (p) {
if (p === 'drive') { return; }
+ if (!Cryptpad.isLoggedIn() && Config.registeredOnlyTypes &&
+ Config.registeredOnlyTypes.indexOf(p) !== -1) { return; }
pads_options.push({
tag: 'a',
attributes: {
@@ -692,6 +699,33 @@ define([
return $userAdmin;
};
+ var createUpgrade = function (toolbar) {
+ if (ApiConfig.removeDonateButton) { return; }
+ if (Cryptpad.account.plan) { return; }
+
+ var text;
+ var feedback;
+ var url;
+ if (ApiConfig.allowSubscriptions && Cryptpad.isLoggedIn()) {
+ text = Messages.upgradeAccount;
+ feedback = "UPGRADE_ACCOUNT";
+ url = Cryptpad.upgradeURL;
+ } else {
+ text = Messages.supportCryptpad;
+ feedback = "SUPPORT_CRYPTPAD";
+ url = Cryptpad.donateURL;
+ }
+
+ var $upgrade = toolbar.$top.find('.' + UPGRADE_CLS).attr({
+ 'title': Messages.supportCryptpad
+ }).text(text).show()
+ .click(function () {
+ Cryptpad.feedback(feedback);
+ window.open(url,'_blank');
+ });
+ return $upgrade;
+ };
+
// Events
var initClickEvents = function (toolbar, config) {
var removeDropdowns = function () {
@@ -849,10 +883,10 @@ define([
tb['spinner'] = createSpinner;
tb['state'] = createState;
tb['limit'] = createLimit;
+ tb['upgrade'] = createUpgrade;
tb['newpad'] = createNewPad;
tb['useradmin'] = createUserAdmin;
-
var addElement = toolbar.addElement = function (arr, additionnalCfg, init) {
if (typeof additionnalCfg === "object") { $.extend(true, config, additionnalCfg); }
arr.forEach(function (el) {
diff --git a/www/drive/main.js b/www/drive/main.js
index 1a6c77bf2..225ede3ed 100644
--- a/www/drive/main.js
+++ b/www/drive/main.js
@@ -1373,6 +1373,10 @@ define([
}
AppConfig.availablePadTypes.forEach(function (type) {
if (type === 'drive') { return; }
+ if (!Cryptpad.isLoggedIn() && AppConfig.registeredOnlyTypes &&
+ AppConfig.registeredOnlyTypes.indexOf(type) !== -1) {
+ return;
+ }
var attributes = {
'class': 'newdoc',
'data-type': type,
@@ -2674,13 +2678,11 @@ define([
}
/* add the usage */
- if (AppConfig.enablePinLimit) {
- Cryptpad.createUsageBar(function (err, $limitContainer) {
- if (err) { return void logError(err); }
- $leftside.html('');
- $leftside.append($limitContainer);
- });
- }
+ Cryptpad.createUsageBar(function (err, $limitContainer) {
+ if (err) { return void logError(err); }
+ $leftside.html('');
+ $leftside.append($limitContainer);
+ }, true);
/* add a history button */
var histConfig = {
diff --git a/www/file/main.js b/www/file/main.js
index ff0d52ec4..82c5d01fe 100644
--- a/www/file/main.js
+++ b/www/file/main.js
@@ -50,8 +50,18 @@ define([
if (queue.inProgress) { return; }
queue.inProgress = true;
- var $cancelCell = $table.find('tr[id="'+id+'"]').find('.upCancel');
- $cancelCell.html('-');
+ var $row = $table.find('tr[id="'+id+'"]');
+
+ $row.find('.upCancel').html('-');
+ var $pv = $row.find('.progressValue');
+ var $pb = $row.find('.progressContainer');
+
+ var updateProgress = function (progressValue) {
+ $pv.text(Math.round(progressValue*100)/100 + '%');
+ $pb.css({
+ width: (progressValue/100)*188+'px'
+ });
+ };
var u8 = new Uint8Array(blob);
@@ -59,13 +69,10 @@ define([
var next = FileCrypto.encrypt(u8, metadata, key);
var estimate = FileCrypto.computeEncryptedSize(blob.byteLength, metadata);
- var chunks = [];
var sendChunk = function (box, cb) {
var enc = Nacl.util.encodeBase64(box);
-
- chunks.push(box);
- Cryptpad.rpc.send('UPLOAD', enc, function (e, msg) {
+ Cryptpad.rpc.send.unauthenticated('UPLOAD', enc, function (e, msg) {
console.log(box);
cb(e, msg);
});
@@ -77,16 +84,10 @@ define([
if (box) {
actual += box.length;
var progressValue = (actual / estimate * 100);
+ updateProgress(progressValue);
return void sendChunk(box, function (e) {
if (e) { return console.error(e); }
- var $pv = $table.find('tr[id="'+id+'"]').find('.progressValue');
- $pv.text(Math.round(progressValue*100)/100 + '%');
- var $pb = $table.find('tr[id="'+id+'"]').find('.progressContainer');
- $pb.css({
- width: (progressValue/100)*188+'px'
- });
-
next(again);
});
}
@@ -222,7 +223,7 @@ define([
Title = Cryptpad.createTitle({}, function(){}, Cryptpad);
- var displayed = ['title', 'useradmin', 'newpad', 'limit'];
+ var displayed = ['title', 'useradmin', 'newpad', 'limit', 'upgrade'];
if (secret && hexFileName) {
displayed.push('fileshare');
}
@@ -301,7 +302,12 @@ define([
}
if (!Cryptpad.isLoggedIn()) {
- return Cryptpad.alert("You must be logged in to upload files");
+ return Cryptpad.alert(Messages.upload_mustLogin, function () {
+ if (sessionStorage) {
+ sessionStorage.redirectTo = window.location.href;
+ }
+ window.location.href = '/login/';
+ });
}
$form.css({
diff --git a/www/login/index.html b/www/login/index.html
index e01c78a09..3e4e7a21e 100644
--- a/www/login/index.html
+++ b/www/login/index.html
@@ -62,6 +62,10 @@
+
diff --git a/www/login/main.js b/www/login/main.js
index 194c824ac..caa77fe4b 100644
--- a/www/login/main.js
+++ b/www/login/main.js
@@ -128,5 +128,16 @@ define([
}, 0);
}, 100);
});
+ $('#register').on('click', function () {
+ if (sessionStorage) {
+ if ($uname.val()) {
+ sessionStorage.login_user = $uname.val();
+ }
+ if ($passwd.val()) {
+ sessionStorage.login_pass = $passwd.val();
+ }
+ }
+ window.location.href = '/register/';
+ });
});
});
diff --git a/www/media/main.js b/www/media/main.js
index 81820f8c0..bc861d699 100644
--- a/www/media/main.js
+++ b/www/media/main.js
@@ -6,6 +6,8 @@ define([
'/common/cryptpad-common.js',
//'/common/visible.js',
//'/common/notify.js',
+ 'pdfjs-dist/build/pdf',
+ 'pdfjs-dist/build/pdf.worker',
'/bower_components/tweetnacl/nacl-fast.min.js',
'/bower_components/file-saver/FileSaver.min.js',
], function ($, Crypto, realtimeInput, Toolbar, Cryptpad /*, Visible, Notify*/) {
@@ -28,7 +30,7 @@ define([
var cryptKey = secret.keys && secret.keys.fileKeyStr;
var fileId = secret.channel;
var hexFileName = Cryptpad.base64ToHex(fileId);
- var type = "image/png";
+ // var type = "image/png";
var parsed = Cryptpad.parsePadUrl(window.location.href);
var defaultName = Cryptpad.getDefaultName(parsed);
@@ -57,7 +59,7 @@ define([
var $mt = $iframe.find('#encryptedFile');
$mt.attr('src', '/blob/' + hexFileName.slice(0,2) + '/' + hexFileName);
$mt.attr('data-crypto-key', 'cryptpad:'+cryptKey);
- $mt.attr('data-type', type);
+ // $mt.attr('data-type', type);
$(window.document).on('decryption', function (e) {
var decrypted = e.originalEvent;
@@ -98,6 +100,30 @@ define([
updateTitle(Cryptpad.initialName || getTitle() || defaultName);
+ /**
+ * Allowed mime types that have to be set for a rendering after a decryption.
+ *
+ * @type {Array}
+ */
+ var allowedMediaTypes = [
+ 'image/png',
+ 'image/jpeg',
+ 'image/jpg',
+ 'image/gif',
+ 'audio/mp3',
+ 'audio/ogg',
+ 'audio/wav',
+ 'audio/webm',
+ 'video/mp4',
+ 'video/ogg',
+ 'video/webm',
+ 'application/pdf',
+ 'application/dash+xml',
+ 'download'
+ ];
+
+ MediaTag.CryptoFilter.setAllowedMediaTypes(allowedMediaTypes);
+
MediaTag($mt[0]);
Cryptpad.removeLoadingScreen();
diff --git a/www/pad/index.html b/www/pad/index.html
index 4688001f6..3095c137f 100644
--- a/www/pad/index.html
+++ b/www/pad/index.html
@@ -4,6 +4,7 @@
CryptPad
+
div').addClass('half');
});
});
+
+ Test(function () {
+ $uname.val('test' + Math.random());
+ $passwd.val('test');
+ $confirm.val('test');
+ $checkImport[0].checked = true;
+ $checkAcceptTerms[0].checked = true;
+ $register.click();
+
+ window.setTimeout(function () {
+ Cryptpad.findOKButton().click();
+ }, 1000);
+ });
});
});
diff --git a/www/settings/index.html b/www/settings/index.html
index f6ab459c9..28b36675e 100644
--- a/www/settings/index.html
+++ b/www/settings/index.html
@@ -40,6 +40,9 @@
Blog
+
+
+
@@ -105,7 +108,7 @@
-
+