chiark / gitweb /
Post info: add list of mentioned users.
authorSimon Tatham <anakin@pobox.com>
Mon, 11 Dec 2023 19:11:04 +0000 (19:11 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 11 Dec 2023 19:11:04 +0000 (19:11 +0000)
Because the post itself doesn't show their fully qualified usernames.

client.py
text.py

index 856bd94c21a3ab51de4e99627090b071e345e872..8206af6f7e05db9ae6df267ad19650481abc6934 100644 (file)
--- a/client.py
+++ b/client.py
@@ -404,7 +404,7 @@ class Status:
             sensitive = "yes" if self.data['sensitive'] else "no"
             yield text.Paragraph("Sensitive: " + sensitive)
             spoiler = noneify(self.data['spoiler_text'], include_empty=True)
-            yield text.Paragraph("Spoiler text: " + spoiler)
+            yield text.IndentedParagraph(0, 2, "Spoiler text: " + spoiler)
             yield text.BlankLine()
 
             replies = str(self.data['replies_count'])
@@ -415,11 +415,19 @@ class Status:
             yield text.Paragraph("Favourites: " + faves)
             yield text.BlankLine()
 
+            if len(self.mentions) > 0:
+                yield text.Paragraph("Mentioned user:")
+                for mention in self.mentions:
+                    yield text.IndentedParagraph(2, 4, text.ColouredString(
+                        self.client.fq(mention['acct']), 'f'))
+                yield text.BlankLine()
+
             app_subdict = self.data.get('application', {})
             client = noneify(app_subdict.get('name'))
             yield text.Paragraph("Client name: " + client)
             client_url = noneify(app_subdict.get('website'), colour='u')
             yield text.Paragraph("Client website: " + client_url)
+            yield text.BlankLine()
 
     def get_reply_recipients(self):
         yield self.client.fq(self.account['acct'])
diff --git a/text.py b/text.py
index 42f70d0ce6f9f0dc7dee7a1a6409aa2eed7ec305..378b5fcc0630129380e02b5488accbd2b60cb0ad 100644 (file)
--- a/text.py
+++ b/text.py
@@ -383,6 +383,21 @@ class Paragraph:
     def __repr__(self):
         return f"Paragraph({self.words!r}, unfinished={self.unfinished_word!r})"
 
+class IndentedParagraph(Paragraph):
+    def __init__(self, firstindent, laterindent, text=None):
+        super().__init__(text)
+        self.firstindent = firstindent
+        self.laterindent = laterindent
+
+    def render(self, width):
+        it = super().render(width - self.firstindent, width - self.laterindent)
+        try:
+            yield " " * self.firstindent + next(it)
+        except StopIteration:
+            return
+        for line in it:
+            yield " " * self.laterindent + next(it)
+
 class NotificationLog:
     can_highlight_as_target = True