Merge branch 'staging' into unifiedMetadata
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
define([
|
||||
'/common/curve.js',
|
||||
'/bower_components/chainpad-listmap/chainpad-listmap.js',
|
||||
], function (Curve, Listmap) {
|
||||
var Edit = {};
|
||||
|
||||
Edit.create = function (config, cb) { //network, channel, theirs, mine, cb) {
|
||||
var network = config.network;
|
||||
var channel = config.channel;
|
||||
var keys = config.keys;
|
||||
|
||||
try {
|
||||
var encryptor = Curve.createEncryptor(keys);
|
||||
var lm = Listmap.create({
|
||||
network: network,
|
||||
data: {},
|
||||
channel: channel,
|
||||
readOnly: false,
|
||||
validateKey: keys.validateKey || undefined,
|
||||
crypto: encryptor,
|
||||
userName: 'lol',
|
||||
logLevel: 1,
|
||||
});
|
||||
|
||||
var done = function () {
|
||||
// TODO make this abort and disconnect the session after the
|
||||
// user has finished making changes to the object, and they
|
||||
// have propagated.
|
||||
};
|
||||
|
||||
lm.proxy
|
||||
.on('create', function () {
|
||||
console.log('created');
|
||||
})
|
||||
.on('ready', function () {
|
||||
console.log('ready');
|
||||
cb(lm, done);
|
||||
})
|
||||
.on('disconnect', function () {
|
||||
console.log('disconnected');
|
||||
})
|
||||
.on('change', [], function (o, n, p) {
|
||||
console.log(o, n, p);
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
return Edit;
|
||||
});
|
||||
@@ -94,6 +94,18 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
// New support message from the admins
|
||||
handlers['SUPPORT_MESSAGE'] = function (common, data) {
|
||||
var content = data.content;
|
||||
content.getFormatText = function () {
|
||||
return Messages.support_notification;
|
||||
};
|
||||
content.handler = function () {
|
||||
common.openURL('/support/');
|
||||
defaultDismiss(common, data)();
|
||||
};
|
||||
};
|
||||
|
||||
handlers['REQUEST_PAD_ACCESS'] = function (common, data) {
|
||||
var content = data.content;
|
||||
var msg = content.msg;
|
||||
@@ -103,18 +115,50 @@ define([
|
||||
|
||||
// Display the notification
|
||||
content.getFormatText = function () {
|
||||
return 'Edit access request: ' + msg.content.title + ' - ' + msg.content.user.displayName;
|
||||
}; // XXX
|
||||
return Messages._getKey('requestEdit_request', [msg.content.title, msg.content.user.displayName]);
|
||||
};
|
||||
|
||||
// if not archived, add handlers
|
||||
content.handler = function () {
|
||||
UI.confirm("Give edit rights?", function (yes) {
|
||||
var metadataMgr = common.getMetadataMgr();
|
||||
var priv = metadataMgr.getPrivateData();
|
||||
|
||||
var link = h('a', {
|
||||
href: '#'
|
||||
}, Messages.requestEdit_viewPad);
|
||||
var verified = h('p.cp-notifications-requestedit-verified');
|
||||
var $verified = $(verified);
|
||||
|
||||
if (priv.friends && priv.friends[msg.author]) {
|
||||
var f = priv.friends[msg.author];
|
||||
$verified.append(h('span.fa.fa-certificate'));
|
||||
var $avatar = $(h('span.cp-avatar')).appendTo($verified);
|
||||
$verified.append(h('p', Messages._getKey('requestEdit_fromFriend', [f.displayName])));
|
||||
common.displayAvatar($avatar, f.avatar, f.displayName);
|
||||
} else {
|
||||
$verified.append(Messages.requestEdit_fromStranger);
|
||||
}
|
||||
|
||||
var div = h('div', [
|
||||
UI.setHTML(h('p'), Messages._getKey('requestEdit_confirm', [msg.content.title, msg.content.user.displayName])),
|
||||
verified,
|
||||
link
|
||||
]);
|
||||
$(link).click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
common.openURL(msg.content.href);
|
||||
});
|
||||
UI.confirm(div, function (yes) {
|
||||
if (!yes) { return; }
|
||||
common.getSframeChannel().event('EV_GIVE_ACCESS', {
|
||||
channel: msg.content.channel,
|
||||
user: msg.content.user
|
||||
});
|
||||
defaultDismiss(common, data)();
|
||||
}, {
|
||||
ok: Messages.friendRequest_accept,
|
||||
cancel: Messages.later
|
||||
});
|
||||
};
|
||||
|
||||
@@ -134,8 +178,8 @@ define([
|
||||
|
||||
// Display the notification
|
||||
content.getFormatText = function () {
|
||||
return 'Edit access received: ' + msg.content.title + ' from ' + msg.content.user.displayName;
|
||||
}; // XXX
|
||||
return Messages._getKey('requestEdit_accepted', [msg.content.title, msg.content.user.displayName]);
|
||||
};
|
||||
|
||||
// if not archived, add handlers
|
||||
content.handler = function () {
|
||||
|
||||
@@ -44,6 +44,7 @@ body.cp-app-sheet, body.cp-app-oodoc, body.cp-app-ooslide {
|
||||
height: 100%;
|
||||
background-color: lightgrey;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
}
|
||||
#cp-app-oo-editor {
|
||||
flex: 1;
|
||||
|
||||
@@ -201,6 +201,14 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
// Hide duplicates when receiving a SUPPORT_MESSAGE notification
|
||||
var supportMessage = false;
|
||||
handlers['SUPPORT_MESSAGE'] = function (ctx, box, data, cb) {
|
||||
if (supportMessage) { return void cb(true); }
|
||||
supportMessage = true;
|
||||
cb();
|
||||
};
|
||||
|
||||
// Incoming edit rights request: add data before sending it to inner
|
||||
handlers['REQUEST_PAD_ACCESS'] = function (ctx, box, data, cb) {
|
||||
var msg = data.msg;
|
||||
@@ -214,17 +222,19 @@ define([
|
||||
if (!res.length) { return void cb(true); }
|
||||
|
||||
var edPublic = ctx.store.proxy.edPublic;
|
||||
var title;
|
||||
var title, href;
|
||||
if (!res.some(function (obj) {
|
||||
if (obj.data &&
|
||||
Array.isArray(obj.data.owners) && obj.data.owners.indexOf(edPublic) !== -1 &&
|
||||
obj.data.href) {
|
||||
href = obj.data.href;
|
||||
title = obj.data.filename || obj.data.title;
|
||||
return true;
|
||||
}
|
||||
})) { return void cb(true); }
|
||||
|
||||
content.title = title;
|
||||
content.href = href;
|
||||
cb(false);
|
||||
};
|
||||
|
||||
|
||||
@@ -245,8 +245,11 @@ proxy.mailboxes = {
|
||||
});
|
||||
box.queue = [];
|
||||
};
|
||||
var lastReceivedHash; // Don't send a duplicate of the last known hash on reconnect
|
||||
box.onMessage = cfg.onMessage = function (msg, user, vKey, isCp, hash, author) {
|
||||
if (hash === m.lastKnownHash) { return; }
|
||||
if (hash === lastReceivedHash) { return; }
|
||||
lastReceivedHash = hash;
|
||||
try {
|
||||
msg = JSON.parse(msg);
|
||||
} catch (e) {
|
||||
@@ -364,6 +367,7 @@ proxy.mailboxes = {
|
||||
txid: txid,
|
||||
complete: true
|
||||
}, [req.cId]);
|
||||
delete ctx.req[txid];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -506,8 +506,14 @@ define([
|
||||
var fixRoot = function (elem) {
|
||||
if (typeof(files[ROOT]) !== "object") { debug("ROOT was not an object"); files[ROOT] = {}; }
|
||||
var element = elem || files[ROOT];
|
||||
if (!element) { return console.error("Invalid element in root"); }
|
||||
var nbMetadataFolders = 0;
|
||||
for (var el in element) {
|
||||
if (element[el] === null) {
|
||||
console.error('element[%s] is null', el);
|
||||
delete element[el];
|
||||
continue;
|
||||
}
|
||||
if (exp.isFolderData(element[el])) {
|
||||
if (nbMetadataFolders !== 0) {
|
||||
debug("Multiple metadata files in folder");
|
||||
|
||||
@@ -323,7 +323,7 @@ define([
|
||||
var mode;
|
||||
if (!mime) {
|
||||
var ext = /.+\.([^.]+)$/.exec(file.name);
|
||||
if (ext[1]) {
|
||||
if (ext && ext[1]) {
|
||||
mode = CMeditor.findModeByExtension(ext[1]);
|
||||
mode = mode && mode.mode || null;
|
||||
}
|
||||
@@ -339,7 +339,8 @@ define([
|
||||
exp.setMode('text');
|
||||
$toolbarContainer.find('#language-mode').val('text');
|
||||
}
|
||||
return { content: content };
|
||||
// return the mode so that the code editor can decide how to display the new content
|
||||
return { content: content, mode: mode };
|
||||
};
|
||||
|
||||
exp.setValueAndCursor = function (oldDoc, remoteDoc) {
|
||||
|
||||
@@ -585,7 +585,7 @@ MessengerUI, Messages) {
|
||||
|
||||
var $requestBlock = $('<button>', {
|
||||
'class': 'fa fa-lock cp-toolbar-share-button',
|
||||
title: 'REQUEST ACCESS' // XXX
|
||||
title: Messages.requestEdit_button
|
||||
}).hide();
|
||||
|
||||
// If we have access to the owner's mailbox, display the button and enable it
|
||||
@@ -593,10 +593,16 @@ MessengerUI, Messages) {
|
||||
// true ==> send the request
|
||||
Common.getSframeChannel().query('Q_REQUEST_ACCESS', false, function (err, obj) {
|
||||
if (obj && obj.state) {
|
||||
var locked = false;
|
||||
$requestBlock.show().click(function () {
|
||||
if (locked) { return; }
|
||||
locked = true;
|
||||
Common.getSframeChannel().query('Q_REQUEST_ACCESS', true, function (err, obj) {
|
||||
if (obj && obj.state) {
|
||||
UI.log('sent'); // XXX
|
||||
UI.log(Messages.requestEdit_sent);
|
||||
$requestBlock.hide();
|
||||
} else {
|
||||
locked = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1111,5 +1111,17 @@
|
||||
"notifications_cat_friends": "Friend requests",
|
||||
"notifications_cat_pads": "Shared with me",
|
||||
"notifications_cat_archived": "History",
|
||||
"notifications_dismissAll": "Dismiss all"
|
||||
"notifications_dismissAll": "Dismiss all",
|
||||
"support_notification": "An administrator has responded to your support ticket",
|
||||
"requestEdit_button": "Request edit rights",
|
||||
"requestEdit_dialog": "Are you sure you'd like to ask the owner of this pad for the ability to edit?",
|
||||
"requestEdit_confirm": "{1} has asked for the ability to edit the pad <b>{0}</b>. Would you like to grant them access?",
|
||||
"requestEdit_fromFriend": "You are friends with {0}",
|
||||
"requestEdit_fromStranger": "You are <b>not</b> friends with {0}",
|
||||
"requestEdit_viewPad": "Open the pad in a new tab",
|
||||
"later": "Decide later",
|
||||
"requestEdit_request": "{1} wants to edit the pad <b>{0}</b>",
|
||||
"requestEdit_accepted": "{1} granted you edit rights for the pad <b>{0}</b>",
|
||||
"requestEdit_sent": "Request sent",
|
||||
"uploadFolderButton": "Upload folder"
|
||||
}
|
||||
|
||||
@@ -389,5 +389,64 @@
|
||||
"fc_empty": "Удалить корзину",
|
||||
"fc_prop": "Свойства",
|
||||
"fc_hashtag": "Теги",
|
||||
"fc_sizeInKilobytes": "Размер в килобайтах"
|
||||
"fc_sizeInKilobytes": "Размер в килобайтах",
|
||||
"poll_title": "Приватный выбор даты",
|
||||
"fm_moveNestedSF": "Нельзя помещать одну общую папку в другую. Папка {0} не была перемещена.",
|
||||
"fc_color": "Изменить цвет",
|
||||
"fc_expandAll": "Расширить все",
|
||||
"fc_collapseAll": "Скрыть все",
|
||||
"fc_remove": "Удалить из вашего CryptDrive",
|
||||
"fo_moveUnsortedError": "Вы не можете переместить папку в список черновиков",
|
||||
"fo_existingNameError": "Это имя уже используется в данной директории. Пожалуйста выберите другое.",
|
||||
"fo_unableToRestore": "Невозможно восстановить этот файл в исходное местоположение. Вы можете попытаться переместить его в другое место.",
|
||||
"login_login": "Войти",
|
||||
"login_makeAPad": "Создать анонимный пэд",
|
||||
"login_nologin": "Просмотреть локальные пэды",
|
||||
"login_register": "Зарегистрироваться",
|
||||
"logoutButton": "Выйти",
|
||||
"settingsButton": "Настройки",
|
||||
"login_username": "Имя пользователя",
|
||||
"login_password": "Пароль",
|
||||
"login_confirm": "Подтвердите ваш пароль",
|
||||
"login_remember": "Запомнить меня",
|
||||
"login_hashing": "Ваш пароль хэшируется, это может занять некое время.",
|
||||
"login_hello": "Привет {0},",
|
||||
"login_helloNoName": "Привет,",
|
||||
"fm_info_sharedFolder": "Это общая папка. Вы не вошли в систему, поэтому можете получить к ней доступ только в режиме только для чтения.<br><a href=\"/register/\">Sign up</a> или <a href=\"/login/\">Log in</a> для импорта на CryptDrive и его изменения.",
|
||||
"fo_moveFolderToChildError": "Вы не можете переместить папку в одну из нее следующую",
|
||||
"fo_unavailableName": "Файл или папка с таким же именем уже существуют в новом месте. Переименуйте элемент и повторите попытку.",
|
||||
"fs_migration": "Ваш CryptDrive обновляется до новой версии. В результате, текущая страница должна быть перезагружена.<br><strong> перезагрузите эту страницу, чтобы продолжить ей пользоваться.</strong>.",
|
||||
"login_accessDrive": "Доступ к хранилищу",
|
||||
"login_orNoLogin": "или",
|
||||
"login_noSuchUser": "Неверный логин или пароль. Попробуйте еще раз или зарегистрируйтесь",
|
||||
"login_invalUser": "Неоьходимо имя пользователя",
|
||||
"login_invalPass": "Необходим пароль",
|
||||
"login_unhandledError": "Произошла неожиданная ошибка :(",
|
||||
"register_importRecent": "Импортировать пэды из вашей анонимной сессии",
|
||||
"register_passwordsDontMatch": "Пароли не совпадают!",
|
||||
"register_passwordTooShort": "Длина пароля должна составлять не менее {0} символов.",
|
||||
"register_mustAcceptTerms": "Вы должны принять условия пользования.",
|
||||
"register_mustRememberPass": "Мы не сможем сбросить ваш пароль, если вы его забудете. Очень важно, чтобы вы его запомнили! Пожалуйста, отметьте флажок для подтверждения.",
|
||||
"register_whyRegister": "Почему стоит зарегистрироваться?",
|
||||
"register_header": "Добро пожаловать в CryptPad",
|
||||
"register_writtenPassword": "Я записал свое имя пользователя и пароль, продолжить",
|
||||
"register_cancel": "Назад",
|
||||
"register_alreadyRegistered": "Этот пользователь уже существует, вы хотите войти?",
|
||||
"settings_cat_account": "Учетная запись",
|
||||
"settings_cat_drive": "КриптДрайв",
|
||||
"settings_cat_cursor": "курсор",
|
||||
"settings_cat_code": "Код",
|
||||
"settings_cat_pad": "Текст с форматированием",
|
||||
"settings_cat_creation": "новый пэд",
|
||||
"settings_cat_subscription": "Подписка",
|
||||
"settings_title": "Настройки",
|
||||
"settings_save": "Сохранить",
|
||||
"settings_backupHint": "Резервное копирование или восстановление всего содержимого CryptDrive. Он не будет содержать содержимое ваших пэдов, только ключи для доступа к ним.",
|
||||
"settings_restore": "Восстановить",
|
||||
"settings_exportDescription": "Пожалуйста, подождите, пока мы загружаем и расшифровываем ваши документы. Это может занять несколько минут. Закрытие вкладки прервет процесс.",
|
||||
"settings_exportFailed": "Если загрузка пэда занимает более 1 минуты, он не будет включен в экспорт. Отображается ссылка на любой блокнот, который не был экспортирован.",
|
||||
"settings_exportWarning": "Примечание: этот инструмент все еще находится в бета-версии и может иметь проблемы со масштабируемостью. Для повышения производительности рекомендуется оставить данную вкладку сфокусированной.",
|
||||
"settings_exportCancel": "Вы уверены, что хотите отменить экспорт? В следующий раз вам придется начинать все сначала.",
|
||||
"settings_export_reading": "Читаем ваше хранилище...",
|
||||
"settings_export_download": "Скачиваем и расшифровываем ваши документы..."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user