From: Simon Tatham Date: Fri, 1 Dec 2023 09:03:52 +0000 (+0000) Subject: Also display From: lines. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=d2f1b59810f702d0653d210e2331cb05536292c8;p=mastodonochrome.git Also display From: lines. --- diff --git a/mastodonochrome b/mastodonochrome index c68528a..6614d08 100755 --- a/mastodonochrome +++ b/mastodonochrome @@ -56,8 +56,12 @@ class Post: tm = time.strptime(date, "%Y-%m-%dT%H:%M:%S") self.datestamp = calendar.timegm(tm) + self.account = data['account'] + def text(self): yield text.SeparatorLine(self.datestamp) + yield text.FromLine('@' + self.account['acct'], + self.account['display_name']) class MainUI(Client): def run(self): diff --git a/text.py b/text.py index 3fb55f4..00f9c60 100644 --- a/text.py +++ b/text.py @@ -12,3 +12,13 @@ class SeparatorLine: # FIXME: colours suffix = "[" + date + "]--" return "-" * (width - len(suffix)) + suffix + +class FromLine: + def __init__(self, account, nameline): + self.account = account + self.nameline = nameline + + def render(self, width): + # FIXME: truncate + + return f"From: {self.nameline} ({self.account})"