Merge branch 'soon' into staging

pull/1/head
ansuz 8 years ago
commit 56a871cb67

@ -32,7 +32,7 @@ server {
set $scriptSrc "'self'"; set $scriptSrc "'self'";
set $connectSrc "'self' wss://cryptpad.fr wss://api.cryptpad.fr"; set $connectSrc "'self' wss://cryptpad.fr wss://api.cryptpad.fr";
set $fontSrc "'self'"; set $fontSrc "'self'";
set $imgSrc "data: *"; set $imgSrc "data: * blob:";
set $frameSrc "'self' beta.cryptpad.fr"; set $frameSrc "'self' beta.cryptpad.fr";
if ($uri = /pad/inner.html) { if ($uri = /pad/inner.html) {
@ -65,8 +65,12 @@ server {
rewrite ^.*$ /customize/api/config break; rewrite ^.*$ /customize/api/config break;
} }
location ^~ /blob/ {
try_files $uri =404;
}
## TODO fix in the code so that we don't need this ## TODO fix in the code so that we don't need this
location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard)$ { location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard|file|media)$ {
rewrite ^(.*)$ $1/ redirect; rewrite ^(.*)$ $1/ redirect;
} }

@ -7,14 +7,16 @@ define(function () {
var userData = exp.userData = {}; var userData = exp.userData = {};
var userList = exp.userList = info.userList; var userList = exp.userList = info.userList;
var myData = exp.myData = {}; var myData = exp.myData = {};
var myUserName = exp.myUserName = info.myID; exp.myUserName = info.myID;
var myNetfluxId = exp.myNetfluxId = info.myID; exp.myNetfluxId = info.myID;
var network = Cryptpad.getNetwork();
var parsed = Cryptpad.parsePadUrl(window.location.href); var parsed = Cryptpad.parsePadUrl(window.location.href);
var appType = parsed ? parsed.type : undefined; var appType = parsed ? parsed.type : undefined;
var users = userList.users;
var addToUserData = exp.addToUserData = function(data) { var addToUserData = exp.addToUserData = function(data) {
var users = userList.users;
for (var attrname in data) { userData[attrname] = data[attrname]; } for (var attrname in data) { userData[attrname] = data[attrname]; }
if (users && users.length) { if (users && users.length) {
@ -34,7 +36,7 @@ define(function () {
return { return {
data: userData, data: userData,
list: userList, list: userList,
userNetfluxId: myNetfluxId userNetfluxId: exp.myNetfluxId
}; };
}; };
@ -44,13 +46,14 @@ define(function () {
if(myUserNameTemp.length > 32) { if(myUserNameTemp.length > 32) {
myUserNameTemp = myUserNameTemp.substr(0, 32); myUserNameTemp = myUserNameTemp.substr(0, 32);
} }
myUserName = myUserNameTemp; exp.myUserName = myUserNameTemp;
myData[myNetfluxId] = { myData = {};
name: myUserName, myData[exp.myNetfluxId] = {
name: exp.myUserName,
uid: Cryptpad.getUid(), uid: Cryptpad.getUid(),
}; };
addToUserData(myData); addToUserData(myData);
Cryptpad.setAttribute('username', myUserName, function (err) { Cryptpad.setAttribute('username', exp.myUserName, function (err) {
if (err) { if (err) {
console.log("Couldn't set username"); console.log("Couldn't set username");
console.error(err); console.error(err);
@ -72,7 +75,7 @@ define(function () {
if (typeof(lastName) === 'string') { if (typeof(lastName) === 'string') {
setName(lastName, onLocal); setName(lastName, onLocal);
} else { } else {
myData[myNetfluxId] = { myData[exp.myNetfluxId] = {
name: "", name: "",
uid: Cryptpad.getUid(), uid: Cryptpad.getUid(),
}; };
@ -90,6 +93,11 @@ define(function () {
setName(newName, onLocal); setName(newName, onLocal);
}); });
network.on('reconnect', function (uid) {
exp.myNetfluxId = uid;
exp.setName(exp.myUserName);
});
return exp; return exp;
}; };

@ -2369,7 +2369,7 @@ define([
module.hideMenu(); module.hideMenu();
}); });
$appContainer.on('click', function (e) { $appContainer.on('mousedown', function (e) {
if (e.which !== 1) { return ; } if (e.which !== 1) { return ; }
removeSelected(e); removeSelected(e);
removeInput(); removeInput();

@ -90,6 +90,7 @@ define([
var newU8 = FileCrypto.joinChunks(chunks); var newU8 = FileCrypto.joinChunks(chunks);
FileCrypto.decrypt(newU8, key, function (e, res) { FileCrypto.decrypt(newU8, key, function (e, res) {
if (e) { return console.error(e); }
var title = document.title = res.metadata.name; var title = document.title = res.metadata.name;
myFile = res.content; myFile = res.content;
myDataType = res.metadata.type; myDataType = res.metadata.type;
@ -218,12 +219,15 @@ define([
var key = Nacl.util.decodeBase64(cryptKey); var key = Nacl.util.decodeBase64(cryptKey);
FileCrypto.decrypt(u8, key, function (e, data) { FileCrypto.decrypt(u8, key, function (e, data) {
if (e) {
Cryptpad.removeLoadingScreen();
return console.error(e);
}
console.log(data); console.log(data);
var title = document.title = data.metadata.name; var title = document.title = data.metadata.name;
myFile = data.content; myFile = data.content;
myDataType = data.metadata.type; myDataType = data.metadata.type;
updateTitle(title || defaultName); updateTitle(title || defaultName);
Cryptpad.removeLoadingScreen(); Cryptpad.removeLoadingScreen();
}); });
}); });

Loading…
Cancel
Save