chiark / gitweb /
More timelines.
authorSimon Tatham <anakin@pobox.com>
Sun, 17 Dec 2023 09:22:08 +0000 (09:22 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 17 Dec 2023 09:22:08 +0000 (09:22 +0000)
These don't auto-update.

client.py
cursesclient.py

index 7a0b7920d51622c08db2a08fc13410871384e431..b1bd560cf182f378bd7893da84858a155fadbff9 100644 (file)
--- 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, {})
index d820a707b60c5d1f876c7154fb7b3da0fce7daa1..4b76ee3da4583ed8173d3f5b4b81d95e475914a9 100644 (file)
@@ -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   <P>",
+                                        "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   <L>",
+                                        "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)