From 3c2665630daf3d24b1b64208c3b84c0e4029baca Mon Sep 17 00:00:00 2001 From: Ayo Ayco Date: Sat, 18 Jan 2025 19:52:02 +0100 Subject: [PATCH] feat: show tagged statuses in tag page --- mastodon.py | 16 +++++++++- templates/card.html | 4 ++- templates/tag.html | 72 ++++++++++++++++++++++++++++++++++++------ templates/threads.html | 3 +- threads.py | 40 +++++------------------ utils.py | 25 +++++++++++++++ 6 files changed, 115 insertions(+), 45 deletions(-) create mode 100644 utils.py diff --git a/mastodon.py b/mastodon.py index 631ca4a..7d35ce5 100644 --- a/mastodon.py +++ b/mastodon.py @@ -1,4 +1,18 @@ from mastodon import Mastodon +from . import utils + + +def get_account_tagged_statuses(app, tag): + mastodon = initialize_client(app) + account = mastodon.me() + print('>>> account id', account.id) + statuses = [] + try: + statuses = mastodon.account_statuses(id=account.id, tagged=tag) + except: + print('>>> failed to fetch statuses', tag) + + return list(map(lambda x: utils.clean_status(x), statuses)) def initialize_client(app): mastodon = None @@ -30,5 +44,5 @@ def initialize_client(app): app['password'], to_file = app['secret_file'] ) - + return mastodon \ No newline at end of file diff --git a/templates/card.html b/templates/card.html index d310896..e3c6bbb 100644 --- a/templates/card.html +++ b/templates/card.html @@ -16,8 +16,10 @@ {{ thread.created_at }} + {% if not is_tag %} · Anchor + {% endif %} @@ -51,7 +53,7 @@ {% endif %} - {% if is_thread %} + {% if is_thread and not is_tag %} Read full thread {% endif %} \ No newline at end of file diff --git a/templates/tag.html b/templates/tag.html index 4690eac..d2497cc 100644 --- a/templates/tag.html +++ b/templates/tag.html @@ -4,7 +4,7 @@ - {{ app.title }} + {{ app.title }} / {{ tag }} {% if threads|length == 1 %} @@ -16,7 +16,7 @@ - +