mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 09:37:20 +02:00
feat: add email share
This commit is contained in:
@@ -104,6 +104,8 @@
|
|||||||
"watch.title": "Be notified of new replies in this topic",
|
"watch.title": "Be notified of new replies in this topic",
|
||||||
"unwatch.title": "Stop watching this topic",
|
"unwatch.title": "Stop watching this topic",
|
||||||
"share-this-post": "Share this Post",
|
"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",
|
"watching": "Watching",
|
||||||
"not-watching": "Not Watching",
|
"not-watching": "Not Watching",
|
||||||
"ignoring": "Ignoring",
|
"ignoring": "Ignoring",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('share', ['hooks'], function (hooks) {
|
define('share', ['hooks', 'translator'], function (hooks, translator) {
|
||||||
const share = {};
|
const share = {};
|
||||||
const baseUrl = window.location.protocol + '//' + window.location.host;
|
const baseUrl = window.location.protocol + '//' + window.location.host;
|
||||||
|
|
||||||
@@ -69,6 +69,16 @@ define('share', ['hooks'], function (hooks) {
|
|||||||
return openShare(mastodon_url, postUrl, 626, 760);
|
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 });
|
hooks.fire('action:share.addHandlers', { openShare: openShare });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ social.getPostSharing = async function () {
|
|||||||
name: 'Mastodon',
|
name: 'Mastodon',
|
||||||
class: 'fa-brands fa-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 = await plugins.hooks.fire('filter:social.posts', networks);
|
||||||
networks.forEach((network) => {
|
networks.forEach((network) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user