Add a button to get the read only URL

pull/1/head
Yann Flory 8 years ago
parent 99b50465c7
commit bf8c9a2c4b

@ -3,6 +3,11 @@ define(function () {
out.main_title = "Cryptpad: Editeur collaboratif en temps réel, zero knowledge";
out.type = {};
out.type.pad = 'Pad';
out.type.code = 'Code';
out.type.poll = 'Sondage';
out.type.slide = 'Présentation';
out.errorBox_errorType_disconnected = 'Connexion perdue';
out.errorBox_errorExplanation_disconnected = [
@ -60,6 +65,11 @@ define(function () {
out.commitButton = 'VALIDER';
out.linksButton = 'LIENS';
out.linksButtonTitle = 'Obtenir les liens disponibles pour accéder à ce document';
out.readonlyUrl = 'Lien de lecture seule';
out.editUrl = "Lien d'édition";
out.disconnectAlert = 'Perte de la connexion au réseau !';
out.tryIt = 'Essayez-le !';
@ -71,12 +81,6 @@ define(function () {
out.loginText = '<p>Votre nom d\'utilisateur et votre mot de passe sont utilisés pour générer une clé unique qui reste inconnue de notre serveur.</p>\n' +
'<p>Faites attention de ne pas oublier vos identifiants puisqu\'ils seront impossible à récupérer.</p>';
out.type = {};
out.type.pad = 'Pad';
out.type.code = 'Code';
out.type.poll = 'Sondage';
out.type.slide = 'Présentation';
out.forget = "Oublier";
// Polls

@ -3,6 +3,11 @@ define(function () {
out.main_title = "Cryptpad: Zero Knowledge, Collaborative Real Time Editing";
out.type = {};
out.type.pad = 'Pad';
out.type.code = 'Code';
out.type.poll = 'Poll';
out.type.slide = 'Presentation';
out.errorBox_errorType_disconnected = 'Connection Lost';
out.errorBox_errorExplanation_disconnected = [
@ -59,6 +64,11 @@ define(function () {
out.presentSuccess = 'Hit ESC to exit presentation mode';
out.commitButton = 'COMMIT';
out.linksButton = 'LINKS';
out.linksButtonTitle = 'Get the available links for this document';
out.readonlyUrl = 'Read only URL';
out.editUrl = 'Edit URL';
out.disconnectAlert = 'Network connection lost!';
@ -71,13 +81,6 @@ define(function () {
out.loginText = '<p>Your username and password are used to generate a unique key which is never known by our server.</p>\n' +
'<p>Be careful not to forget your credentials, as they are impossible to recover</p>';
// TODO : move at the beginning
out.type = {};
out.type.pad = 'Pad';
out.type.code = 'Code';
out.type.poll = 'Poll';
out.type.slide = 'Presentation';
out.forget = "Forget";
// Polls

@ -286,6 +286,13 @@ define([
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
var editHash;
var viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys);
if (!readOnly) {
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
}
/* add an export button */
var $export = $('<button>', {
title: Messages.exportButtonTitle,
@ -391,6 +398,22 @@ define([
});
$rightside.append($forgetPad);
/* add a 'links' button */
var $links = $('<button>', {
title: Messages.linksButtonTitle
})
.text(Messages.linksButton)
.addClass('rightside-button')
.click(function () {
var baseUrl = window.location.origin + window.location.pathname + '#';
var content = '<b>' + Messages.readonlyUrl + '</b> : <a target="_blank">' + baseUrl + viewHash + '</a>';
if (!readOnly) {
content += '<br><b>' + Messages.editUrl + '</b> : <a target="_blank">' + baseUrl + editHash + '</a>';
}
Cryptpad.alert(content);
});
$rightside.append($links);
var configureLanguage = function (cb) {
// FIXME this is async so make it happen as early as possible
@ -451,9 +474,9 @@ define([
// set the hash
if (!readOnly) {
window.location.hash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
window.location.hash = editHash;
}
console.log("View Hash : " + Cryptpad.getViewHashFromKeys(info.channel, secret.keys));
Cryptpad.getPadTitle(function (err, title) {
if (err) {
console.log("Unable to get pad title");

@ -488,6 +488,13 @@ define([
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
var editHash;
var viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys);
if (!readOnly) {
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
}
/* add an export button */
var $export = $('<button>', {
title: Messages.exportButtonTitle,
@ -559,11 +566,26 @@ define([
});
$rightside.append($forgetPad);
/* add a 'links' button */
var $links = $('<button>', {
title: Messages.linksButtonTitle
})
.text(Messages.linksButton)
.addClass('rightside-button')
.click(function () {
var baseUrl = window.location.origin + window.location.pathname + '#';
var content = '<b>' + Messages.readonlyUrl + '</b> : <a target="_blank">' + baseUrl + viewHash + '</a>';
if (!readOnly) {
content += '<br><b>' + Messages.editUrl + '</b> : <a target="_blank">' + baseUrl + editHash + '</a>';
}
Cryptpad.alert(content);
});
$rightside.append($links);
// set the hash
if (!readOnly) {
window.location.hash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
window.location.hash = editHash;
}
console.log("View Hash : " + Cryptpad.getViewHashFromKeys(info.channel, secret.keys));
Cryptpad.getPadTitle(function (err, title) {
if (err) {

Loading…
Cancel
Save