Skip to content

Commit b34e18d

Browse files
authored
Merge pull request #13 from Fipaddict/main
feat: add parameter to set same hastags for all fediverse posts. (#5)…
2 parents c7441ed + 70c6fbd commit b34e18d

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,19 @@ On every run *Fediverse* looks for a file called `pelicanfediverse_clientcred.se
6565
If you **cancel** this file *Fediverse* will create another app on its next run (this could be done in case of problem despite the fact Mastodon advise this is NOT a good behaviour since app should be created only once).
6666

6767

68-
## parameters
68+
## Parameters
6969

7070
In `pelicanconf.py` some new parameters can be defined
7171

72-
- **MASTODON_VISIBILITY** : Set post's visiblity on mastodon. Can be 'direct', 'private', 'unlisted' or 'public'. Default value = 'direct'
73-
74-
More details : https://mastodonpy.readthedocs.io/en/stable/05_statuses.html#writing
72+
- **MASTODON_VISIBILITY** : Set post's visiblity on mastodon. Can be 'direct', 'private', 'unlisted' or 'public'. Default value = 'direct'
73+
<br>More details : https://mastodonpy.readthedocs.io/en/stable/05_statuses.html#writing
7574

7675
- **MASTODON_READ_MORE** : Text to add at the end of the post, before link to the pelican's article. Default value = 'Read more: '
7776

77+
- **FEDIVERSE_TAGS** : To add same tag on all fediverse post but not on blog post. It is possible to set multiple tags with comma separator. _(ie "MyFirstTag, AnotherOne" generate **#MyFirstTag** and **#AnotherOne**)_
78+
7879
``` Python
79-
MASTODON_VISIBILITY='direct'
80-
MASTODON_READ_MORE='Read more: '
80+
MASTODON_VISIBILITY = 'direct'
81+
MASTODON_READ_MORE = 'Read more: '
82+
FEDIVERSE_TAGS = 'FromMyBlog'
83+
```

fediverse.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def post_on_mastodon(settings, new_posts):
5252
global mt_visibility
5353
mt_visibility = settings.get('MASTODON_VISIBILITY', 'direct')
5454

55+
global mt_fediverse_tags
56+
mt_fediverse_tags = settings.get('FEDIVERSE_TAGS', '')
57+
5558
# check if config file contains username and password and prompt the user this is deprecated
5659
if mt_username or mt_password in globals():
5760
logger.warning('Pelican_fediverse: password authentication is DEPRECATED and will be removed soon!\nPlease use OAuth token instead...')
@@ -117,6 +120,11 @@ def post_updates(generator, writer):
117120
fedi_tag_list = []
118121
tags_to_publish = ''
119122

123+
# if FEDIVERSE_TAGS is set in pelicanconf.py, add tags to the post
124+
if mt_fediverse_tags != '':
125+
for tag in mt_fediverse_tags.split(','):
126+
fedi_tag_list.append('#' + tag.replace(' ', ''))
127+
120128
if hasattr(article, 'ftags'):
121129
for ftag in article.ftags.split(','):
122130
fedi_tag_list.append('#' + ftag.replace(' ', ''))

0 commit comments

Comments
 (0)