Node.js based forum software built for the modern web
feat: add email share
Barış Soner Uşaklı43e7f0abb93e
diff --git a/public/language/en-GB/topic.json b/public/language/en-GB/topic.jsonindex ac69995c89..52808ea5bd 100644--- a/public/language/en-GB/topic.json+++ b/public/language/en-GB/topic.json@@ -104,6 +104,8 @@"watch.title": "Be notified of new replies in this topic","unwatch.title": "Stop watching this topic","share-this-post": "Share this Post",+ "share-mail-subject": "Check out this post on \"%1\"",+ "share-mail-body": "I thought you might be interested in this post: %1","watching": "Watching","not-watching": "Not Watching","ignoring": "Ignoring",diff --git a/public/src/modules/share.js b/public/src/modules/share.jsindex 94478d30cf..db6e4e19ac 100644--- a/public/src/modules/share.js+++ b/public/src/modules/share.js@@ -1,7 +1,7 @@'use strict';-define('share', ['hooks'], function (hooks) {+define('share', ['hooks', 'translator'], function (hooks, translator) {const share = {};const baseUrl = window.location.protocol + '//' + window.location.host;@@ -69,6 +69,16 @@ define('share', ['hooks'], function (hooks) {return openShare(mastodon_url, postUrl, 626, 760);});+ addHandler('[component="share/email"]', async function () {+ const postUrl = getPostUrl($(this));+ const [subject, body] = await translator.translateKeys([+ translator.compile('topic:share-mail-subject', config.siteTitle),+ translator.compile('topic:share-mail-body', postUrl),+ ]);+ const mailtoUrl = `mailto:?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;+ window.location.href = mailtoUrl;+ });+hooks.fire('action:share.addHandlers', { openShare: openShare });};diff --git a/src/social.js b/src/social.jsindex 9d52114583..c540a391c3 100644--- a/src/social.js+++ b/src/social.js@@ -45,6 +45,11 @@ social.getPostSharing = async function () {name: 'Mastodon',class: 'fa-brands fa-mastodon',},+ {+ id: 'email',+ name: 'Email',+ class: 'fa-regular fa-envelope',+ },];networks = await plugins.hooks.fire('filter:social.posts', networks);networks.forEach((network) => {