From 9ce2be3f3b99fc4f9dcb9fa256af5478f710ce7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Garc=C3=ADa=20Garz=C3=B3n?= Date: Sun, 14 Feb 2021 00:07:32 +0100 Subject: [PATCH 1/4] share_post: adding mastodon and telegram --- share_post/share_post.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/share_post/share_post.py b/share_post/share_post.py index d2a3c64d3..f29eec12d 100644 --- a/share_post/share_post.py +++ b/share_post/share_post.py @@ -67,6 +67,10 @@ def share_post(content): ) reddit_link = 'https://www.reddit.com/submit?url=%s&title=%s' % ( url, title) + mastodon_link = 'https://toot.karamoff.dev/?text=%s%%0D%%0A%s' %( + title, url) + telegram_link = 'https://telegram.me/share/url?url=%s' %( + url) content.share_post = { 'diaspora': diaspora_link, @@ -76,6 +80,8 @@ def share_post(content): 'hacker-news': hackernews_link, 'email': mail_link, 'reddit': reddit_link, + 'mastodon': mastodon_link, + 'telegram': telegram_link, } From 51b3416a0744ae78b16b5280161705211560da5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Garc=C3=ADa=20Garz=C3=B3n?= Date: Sun, 14 Feb 2021 00:18:06 +0100 Subject: [PATCH 2/4] share_post: cleaner code --- share_post/share_post.py | 55 +++++++++++++++------------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/share_post/share_post.py b/share_post/share_post.py index f29eec12d..51d383738 100644 --- a/share_post/share_post.py +++ b/share_post/share_post.py @@ -48,41 +48,28 @@ def share_post(content): if isinstance(content, contents.Static): return - title = article_title(content) - url = article_url(content) - summary = article_summary(content) - hastags = twitter_hastags(content) - via = twitter_via(content) - - mail_link = 'mailto:?subject=%s&body=%s' % (title, url) - diaspora_link = 'https://sharetodiaspora.github.io/?title=%s&url=%s' % ( - title, url) - facebook_link = 'https://www.facebook.com/sharer/sharer.php?u=%s' % url - twitter_link = 'https://twitter.com/intent/tweet?text=%s&url=%s%s%s' % ( - title, url, via, hastags) - hackernews_link = 'https://news.ycombinator.com/submitlink?t=%s&u=%s' % ( - title, url) - linkedin_link = 'https://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s&summary=%s&source=%s' % ( # noqa - url, title, summary, url + link_templates = dict( + mail = "mailto:?subject={title}&body={url}", + diaspora = "https://sharetodiaspora.github.io/?title={title}&url={url}", + facebook = "https://www.facebook.com/sharer/sharer.php?u={url}", + twitter = "https://twitter.com/intent/tweet?text={title}&url={url}{via}{hashtags}", + hackernews = "https://news.ycombinator.com/submitlink?t={title}&u={url}", + linkedin = "https://www.linkedin.com/shareArticle?mini=true&url={url}&title={title}&summary={summary}&source={url}", + reddit = "https://www.reddit.com/submit?url={url}&title={title}", + mastodon = "https://toot.karamoff.dev/?text={title}%0D%0A{url}", + telegram = "https://telegram.me/share/url?url={url}", ) - reddit_link = 'https://www.reddit.com/submit?url=%s&title=%s' % ( - url, title) - mastodon_link = 'https://toot.karamoff.dev/?text=%s%%0D%%0A%s' %( - title, url) - telegram_link = 'https://telegram.me/share/url?url=%s' %( - url) - - content.share_post = { - 'diaspora': diaspora_link, - 'twitter': twitter_link, - 'facebook': facebook_link, - 'linkedin': linkedin_link, - 'hacker-news': hackernews_link, - 'email': mail_link, - 'reddit': reddit_link, - 'mastodon': mastodon_link, - 'telegram': telegram_link, - } + fillin = dict( + title = article_title(content), + url = article_url(content), + summary = article_summary(content), + hashtags = twitter_hastags(content), + via = twitter_via(content), + ) + content.share_post = dict([ + (network, link_template.format(**fillin)) + for network, link_template in link_templates.items() + ]) def run_plugin(generators): From ac412f88b645333b9cae625d55c4113f41f51cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Garc=C3=ADa=20Garz=C3=B3n?= Date: Sun, 14 Feb 2021 02:09:37 +0100 Subject: [PATCH 3/4] share_post: added whatsapp support --- share_post/share_post.py | 1 + 1 file changed, 1 insertion(+) diff --git a/share_post/share_post.py b/share_post/share_post.py index 51d383738..a124355fe 100644 --- a/share_post/share_post.py +++ b/share_post/share_post.py @@ -58,6 +58,7 @@ def share_post(content): reddit = "https://www.reddit.com/submit?url={url}&title={title}", mastodon = "https://toot.karamoff.dev/?text={title}%0D%0A{url}", telegram = "https://telegram.me/share/url?url={url}", + whatsapp = "https://api.whatsapp.com/send/?phone&text={title}%0D%0A{url}&app_absent=0", ) fillin = dict( title = article_title(content), From ae911f509fe28c0083427dca0d8c04c8322c915e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Garc=C3=ADa=20Garz=C3=B3n?= Date: Sun, 14 Feb 2021 19:16:10 +0100 Subject: [PATCH 4/4] share_post: documentation --- share_post/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/share_post/README.md b/share_post/README.md index c1651b306..2740e2dfa 100644 --- a/share_post/README.md +++ b/share_post/README.md @@ -48,6 +48,9 @@ pip install beautifulsoup4 1. `linkedin` 1. `hacker-news` 1. `reddit` +1. `mastodon` +1. `telegram` +1. `whatsup` ## Template Example @@ -64,11 +67,17 @@ pip install beautifulsoup4 ❄ LinkedIn ❄ + Reddit + ❄ HackerNewsEmailReddit + ❄ + Reddit + ❄ + Reddit

{% endif %}