From db31937745a24701e026715a230ed3fb46fde4f8 Mon Sep 17 00:00:00 2001 From: Maurizio Paglia Date: Wed, 28 Dec 2022 11:39:26 +0100 Subject: [PATCH 1/7] Fixed Mastodon code Pls check hashtags variable since I think code is correct but tags are not passed to the web service. Thks! --- pelican/plugins/share_post/share_post.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pelican/plugins/share_post/share_post.py b/pelican/plugins/share_post/share_post.py index 35deb80..c6a8abb 100644 --- a/pelican/plugins/share_post/share_post.py +++ b/pelican/plugins/share_post/share_post.py @@ -57,10 +57,16 @@ def create_link_facebook(title, url, content): @create_link def create_link_mastodon(title, url, content): - tags = getattr(content, "tags", []) - tags = ", ".join([tag.slug for tag in tags]) - hashtags = f"&hashtags={tags}" if tags else "" - return f"https://toot.kytta.dev/?text={title}&url={url}{hashtags}" + if hasattr(content, 'tags'): + taglist = content.tags + new_taglist = [] + for i in taglist: + new_taglist.append('#' + str(i)) + hashtags = ' '.join(str(x).replace(" ", "") for x in new_taglist) + else: + hashtags = '' + + return f"https://toot.kytta.dev/?text={title}{newline}{url}{newline}{hashtags}" @create_link From 739b4bfb82be8e38ba0fd3102e530a30091b0772 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 28 Dec 2022 10:39:52 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pelican/plugins/share_post/share_post.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pelican/plugins/share_post/share_post.py b/pelican/plugins/share_post/share_post.py index c6a8abb..06e1c32 100644 --- a/pelican/plugins/share_post/share_post.py +++ b/pelican/plugins/share_post/share_post.py @@ -57,15 +57,15 @@ def create_link_facebook(title, url, content): @create_link def create_link_mastodon(title, url, content): - if hasattr(content, 'tags'): + if hasattr(content, "tags"): taglist = content.tags new_taglist = [] for i in taglist: - new_taglist.append('#' + str(i)) - hashtags = ' '.join(str(x).replace(" ", "") for x in new_taglist) + new_taglist.append("#" + str(i)) + hashtags = " ".join(str(x).replace(" ", "") for x in new_taglist) else: - hashtags = '' - + hashtags = "" + return f"https://toot.kytta.dev/?text={title}{newline}{url}{newline}{hashtags}" From 8de72f2182d404418dd65b75f9ead5e1f67ab163 Mon Sep 17 00:00:00 2001 From: Maurizio Paglia Date: Thu, 11 May 2023 08:27:01 +0200 Subject: [PATCH 3/7] Update share_post.py --- pelican/plugins/share_post/share_post.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pelican/plugins/share_post/share_post.py b/pelican/plugins/share_post/share_post.py index 06e1c32..99edc1e 100644 --- a/pelican/plugins/share_post/share_post.py +++ b/pelican/plugins/share_post/share_post.py @@ -21,6 +21,8 @@ from pelican.generators import ArticlesGenerator, PagesGenerator _create_link_functions = [] +newline = '%0D%0A' + # Use this decorator to mark a function as # a link creator. The function's prototype shall be From 96dfe3ea42a95d600dbad4a8465af82686ee714c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 11 May 2023 06:27:09 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pelican/plugins/share_post/share_post.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pelican/plugins/share_post/share_post.py b/pelican/plugins/share_post/share_post.py index 99edc1e..63c05c9 100644 --- a/pelican/plugins/share_post/share_post.py +++ b/pelican/plugins/share_post/share_post.py @@ -21,7 +21,7 @@ from pelican.generators import ArticlesGenerator, PagesGenerator _create_link_functions = [] -newline = '%0D%0A' +newline = "%0D%0A" # Use this decorator to mark a function as From 0fdb907f1fd9dac0d8a8151c61cfb285d570e713 Mon Sep 17 00:00:00 2001 From: Maurizio Paglia Date: Sat, 13 May 2023 15:24:00 +0200 Subject: [PATCH 5/7] Fixed hashtags error --- pelican/plugins/share_post/share_post.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pelican/plugins/share_post/share_post.py b/pelican/plugins/share_post/share_post.py index 63c05c9..ccb4286 100644 --- a/pelican/plugins/share_post/share_post.py +++ b/pelican/plugins/share_post/share_post.py @@ -63,7 +63,7 @@ def create_link_mastodon(title, url, content): taglist = content.tags new_taglist = [] for i in taglist: - new_taglist.append("#" + str(i)) + new_taglist.append("%23" + str(i)) hashtags = " ".join(str(x).replace(" ", "") for x in new_taglist) else: hashtags = "" From b3a8f622db50d4c2bd4ef30eb6f73bfe80f393d7 Mon Sep 17 00:00:00 2001 From: Maurizio Paglia Date: Thu, 18 May 2023 07:53:32 +0200 Subject: [PATCH 6/7] Fixed code for hashtags --- pelican/plugins/share_post/share_post.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pelican/plugins/share_post/share_post.py b/pelican/plugins/share_post/share_post.py index ccb4286..9b9971a 100644 --- a/pelican/plugins/share_post/share_post.py +++ b/pelican/plugins/share_post/share_post.py @@ -59,16 +59,13 @@ def create_link_facebook(title, url, content): @create_link def create_link_mastodon(title, url, content): - if hasattr(content, "tags"): - taglist = content.tags - new_taglist = [] - for i in taglist: - new_taglist.append("%23" + str(i)) - hashtags = " ".join(str(x).replace(" ", "") for x in new_taglist) - else: - hashtags = "" + hashtags = "" - return f"https://toot.kytta.dev/?text={title}{newline}{url}{newline}{hashtags}" + if hasattr(content, "tags"): + new_taglist = [f"%23{str(i).replace(' ', '')}" for i in content.tags] + hashtags = " ".join(new_taglist) + + return f"https://toot.kytta.dev/?text={title}{newline}{url}{newline}{hashtags}" @create_link From f813736c57bece47d76275c9d8add7c58d4317b7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 May 2023 05:53:39 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pelican/plugins/share_post/share_post.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pelican/plugins/share_post/share_post.py b/pelican/plugins/share_post/share_post.py index 9b9971a..f779c15 100644 --- a/pelican/plugins/share_post/share_post.py +++ b/pelican/plugins/share_post/share_post.py @@ -59,13 +59,13 @@ def create_link_facebook(title, url, content): @create_link def create_link_mastodon(title, url, content): - hashtags = "" + hashtags = "" - if hasattr(content, "tags"): - new_taglist = [f"%23{str(i).replace(' ', '')}" for i in content.tags] - hashtags = " ".join(new_taglist) + if hasattr(content, "tags"): + new_taglist = [f"%23{str(i).replace(' ', '')}" for i in content.tags] + hashtags = " ".join(new_taglist) - return f"https://toot.kytta.dev/?text={title}{newline}{url}{newline}{hashtags}" + return f"https://toot.kytta.dev/?text={title}{newline}{url}{newline}{hashtags}" @create_link