From 729c013af7cd6e050253dcb234563d8db7a77559 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 5 Sep 2017 15:08:05 +0200 Subject: [PATCH] Get mediatag embed code from the file app --- customize.dist/translations/messages.fr.js | 5 ++ customize.dist/translations/messages.js | 5 ++ www/common/cryptpad-common.js | 17 ++++++ www/common/toolbar2.js | 63 +++++++++++++++++++--- www/common/toolbar3.js | 1 + www/file/main.js | 17 +++--- 6 files changed, 96 insertions(+), 12 deletions(-) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index dfeb46371..43519f76e 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -171,6 +171,11 @@ define(function () { out.viewShareTitle = "Copier lien d'accès en lecture seule dans le presse-papiers"; out.viewOpen = "Voir dans un nouvel onglet"; out.viewOpenTitle = "Ouvrir le lien en lecture seule dans un nouvel onglet"; + out.fileShare = "Copier le lien"; + out.fileEmbed = "Obtenir le code d'intégration"; + out.fileEmbedTitle = "Intégrer le fichier dans une page web"; + out.fileEmbedScript = "Pour intégrer un fichier, veuillez inclure le script suivant une fois dans votre page afin de pouvoir charger le Media Tag :"; + out.fileEmbedTag = "Ensuite vous pouvez placer ce Media Tag où vous souhaitez dans votre page pour l'intégrer :"; out.notifyJoined = "{0} a rejoint la session collaborative"; out.notifyRenamed = "{0} a changé son nom en {1}"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 96921c11a..3905b7601 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -173,6 +173,11 @@ define(function () { out.viewShareTitle = "Copy the read-only link to clipboard"; out.viewOpen = "Open read-only link in a new tab"; out.viewOpenTitle = "Open this pad in read-only mode in a new tab"; + out.fileShare = "Copy link"; + out.fileEmbed = "Get embed code"; + out.fileEmbedTitle = "Embed the file in an external page"; + out.fileEmbedScript = "To embed this file, include this script once in your page to load the Media Tag:"; + out.fileEmbedTag = "Then place this Media Tag wherever in your page you would like to embed:"; out.notifyJoined = "{0} has joined the collaborative session"; out.notifyRenamed = "{0} is now known as {1}"; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 7b6e67bde..88da2d533 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -1396,6 +1396,23 @@ define([ return isEmoji(emojis[0])? emojis[0]: str[0]; }; + common.getMediatagScript = function () { + var origin = window.location.origin; + return ''; + }; + common.getMediatagFromHref = function (href) { + var parsed = common.parsePadUrl(href); + var secret = common.getSecrets('file', parsed.hash); + if (secret.keys && secret.channel) { + var cryptKey = secret.keys && secret.keys.fileKeyStr; + var hexFileName = common.base64ToHex(secret.channel); + var origin = Config.fileHost || window.location.origin; + var src = origin + common.getBlobPathFromHex(hexFileName); + return '' + + ''; + } + return; + }; $(window.document).on('decryption', function (e) { var decrypted = e.originalEvent; if (decrypted.callback) { diff --git a/www/common/toolbar2.js b/www/common/toolbar2.js index c6cb82751..dd2b8c4b2 100644 --- a/www/common/toolbar2.js +++ b/www/common/toolbar2.js @@ -481,17 +481,68 @@ define([ if (!window.location.hash) { throw new Error("Unable to display the share button: hash required in the URL"); } + // Create dropdowns var $shareIcon = $('', {'class': 'fa fa-share-alt'}); - var $button = $('