From: Simon Tatham Date: Sun, 17 Dec 2023 09:22:08 +0000 (+0000) Subject: More timelines. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=b86f4ddc9ac36e714490d834f11a3a0b82dace78;p=mastodonochrome.git More timelines. These don't auto-update. --- diff --git a/client.py b/client.py index 7a0b792..b1bd560 100644 --- a/client.py +++ b/client.py @@ -251,6 +251,12 @@ class HomeTimelineFeed(IncrementalServerFeed): def __init__(self, client): super().__init__(client, "timelines/home", {}) +class PublicTimelineFeed(IncrementalServerFeed): + def __init__(self, client, local): + super().__init__(client, "timelines/public", { + 'local': {False:"false", True:"true"}[local] + }) + class MentionsFeed(IncrementalServerFeed): def __init__(self, client): super().__init__(client, "notifications", {"types[]":['mention']}, @@ -264,6 +270,10 @@ class UserStatusesFeed(IncrementalServerFeed): 'exclude_reblogs': not include_boosts, }) +class HashtagStatusesFeed(IncrementalServerFeed): + def __init__(self, client, hashtag): + super().__init__(client, f"timelines/tag/{hashtag}", {}) + class UserListFeed(IncrementalServerFeed): def __init__(self, client, url): super().__init__(client, url, {}) diff --git a/cursesclient.py b/cursesclient.py index d820a70..4b76ee3 100644 --- a/cursesclient.py +++ b/cursesclient.py @@ -342,6 +342,16 @@ class MainMenu(Menu): 'H', text.ColouredString("Home timeline", "K "))) self.items.append(text.BlankLine()) + self.items.append(text.MenuKeypressLine( + 'P', text.ColouredString("Public timeline (all servers)", + "K "))) + self.items.append(text.MenuKeypressLine( + 'L', text.ColouredString("Local public timeline (this server)", + "K "))) + self.items.append(text.MenuKeypressLine( + '#', text.ColouredString("Timeline for a #hashtag", + " K "))) + self.items.append(text.BlankLine()) self.items.append(text.MenuKeypressLine( 'C', text.ColouredString("Compose a post", "K "))) @@ -359,9 +369,33 @@ class MainMenu(Menu): self.push_to(self.cc.home_timeline) elif ch in {'c', 'C'}: self.push_to(self.cc.get_composer()) + elif ch in {'p', 'P'}: + feed = client.PublicTimelineFeed(self.cc, local=False) + title = text.ColouredString("Public timeline

", + "HHHHHHHHHHHHHHHHHHHKH") + self.push_to(StatusFile(self.cc, feed, title)) + elif ch in {'l', 'L'}: + feed = client.PublicTimelineFeed(self.cc, local=True) + title = text.ColouredString("Local public timeline ", + "HHHHHHHHHHHHHHHHHHHHHHHHHKH") + self.push_to(StatusFile(self.cc, feed, title)) + elif ch in {'#'}: + self.push_to(BottomLinePrompt( + self.cc, self.got_hashtag_to_view, + "View feed for hashtag: ")) else: return super().handle_key(ch) + def got_hashtag_to_view(self, tag): + tag = tag.strip().lstrip("@") + if tag == "": + return + + feed = client.HashtagStatusesFeed(self.cc, tag) + title = text.ColouredString( + f"Posts mentioning hashtag #{tag}", 'H') + self.push_to(StatusFile(self.cc, feed, title)) + class EscMenu(Menu): def __init__(self, cc): super().__init__(cc)