Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 5acb36e

Browse files
committed
Mastodon - fix title item when toot is a reblog
1 parent e5e83a8 commit 5acb36e

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

twootfeed/mastodon/generate_toots_feed.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
def format_toot(toot: Dict, text_length_limit: int) -> Dict:
1111
created_at = toot['created_at']
1212
boosted = ""
13+
html_boosted = ""
1314

1415
reblog = toot.get('reblog')
1516
if reblog:
16-
boosted = f"<div>Boosted by {toot['account']['display_name']}: </div>"
17+
boosted = f"Boosted by {toot['account']['display_name']}: "
18+
html_boosted = f"<div>{boosted}</div>"
1719
toot = reblog
1820
toot['created_at'] = created_at
1921

@@ -23,13 +25,14 @@ def format_toot(toot: Dict, text_length_limit: int) -> Dict:
2325
'created_at': toot['created_at'],
2426
'url': toot['url'],
2527
'htmltext': (
26-
f"<blockquote>{boosted}<div><img src=\""
28+
f"<blockquote>{html_boosted}<div><img src=\""
2729
f"{toot['account']['avatar_static']}\" "
2830
f"alt=\"{toot['account']['display_name']}\""
2931
f" width= 100px\"/> "
3032
f"<strong>{toot['account']['display_name']} </strong>"
3133
f"{toot['content']}"
3234
),
35+
'boosted': boosted,
3336
}
3437

3538
source = toot.get('application')
@@ -54,7 +57,7 @@ def format_toot(toot: Dict, text_length_limit: int) -> Dict:
5457
)
5558

5659
rss_toot['text'] = BeautifulSoup(
57-
boosted + unescape(toot['content']), "html.parser"
60+
unescape(toot['content']), "html.parser"
5861
).text
5962

6063
if len(rss_toot['text']) > text_length_limit:
@@ -85,7 +88,8 @@ def generate_mastodon_feed(
8588
)
8689
f.add_item(
8790
title=(
88-
formatted_toot['display_name']
91+
formatted_toot['boosted']
92+
+ formatted_toot['display_name']
8993
+ ' ('
9094
+ formatted_toot['screen_name']
9195
+ '): '

twootfeed/tests/data.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@
411411
}
412412

413413
formatted_toot1 = {
414+
'boosted': '',
414415
'display_name': 'User',
415416
'screen_name': 'UserD',
416417
'created_at': datetime(2018, 10, 25, 14, 16, 42, 11000),
@@ -664,6 +665,7 @@
664665
}
665666

666667
formatted_toot2 = {
668+
'boosted': '',
667669
'display_name': 'User',
668670
'screen_name': 'UserD',
669671
'created_at': datetime(2018, 10, 25, 14, 16, 42, 11000),
@@ -826,6 +828,7 @@
826828
}
827829

828830
formatted_reblog = {
831+
'boosted': 'Boosted by User A: ',
829832
'display_name': 'User',
830833
'screen_name': 'UserD',
831834
'created_at': datetime(2018, 10, 25, 14, 17, 22),
@@ -837,7 +840,7 @@
837840
'<strong>User </strong>'
838841
'<p>What\'s New in <a href="https://linuxjobs.social/tags/python" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>python</span></a> today?</p>' # noqa
839842
'<br>♻ : 0, ✰ : 0</div></blockquote>',
840-
'text': 'Boosted by User A: What\'s New in #python today?',
843+
'text': 'What\'s New in #python today?',
841844
}
842845

843846
toot_1_home_timeline_feed = (

0 commit comments

Comments
 (0)