Add custom fields to status output

This commit is contained in:
Ivan Habunek 2022-12-16 12:56:51 +01:00
parent 459937f196
commit baa5a37125
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
1 changed files with 22 additions and 10 deletions

View File

@ -3,7 +3,6 @@ import re
import sys
import textwrap
from textwrap import wrap
from toot.tui.utils import parse_datetime
from wcwidth import wcswidth
@ -167,11 +166,9 @@ def print_instance(instance):
def print_account(account):
print_out(f"<green>@{account['acct']}</green> {account['display_name']}")
note = get_text(account['note'])
if note:
if account["note"]:
print_out("")
print_out("\n".join(wrap(note)))
print_html(account["note"])
print_out("")
print_out(f"ID: <green>{account['id']}</green>")
@ -180,6 +177,13 @@ def print_account(account):
print_out(f"Followers: <yellow>{account['followers_count']}</yellow>")
print_out(f"Following: <yellow>{account['following_count']}</yellow>")
print_out(f"Statuses: <yellow>{account['statuses_count']}</yellow>")
if account["fields"]:
for field in account["fields"]:
name = field["name"].title()
print_out(f'\n<yellow>{name}</yellow>:')
print_html(field["value"])
print_out("")
print_out(account["url"])
@ -244,11 +248,8 @@ def print_status(status, width):
f"<yellow>{time}</yellow>",
)
for paragraph in parse_html(content):
print_out("")
for line in paragraph:
for subline in wc_wrap(line, width):
print_out(highlight_hashtags(subline))
print_out("")
print_html(content, width)
if media_attachments:
print_out("\nMedia:")
@ -268,6 +269,17 @@ def print_status(status, width):
)
def print_html(text, width=80):
first = True
for paragraph in parse_html(text):
if not first:
print_out("")
for line in paragraph:
for subline in wc_wrap(line, width):
print_out(highlight_hashtags(subline))
first = False
def print_poll(poll):
print_out()
for idx, option in enumerate(poll["options"]):