mirror of
https://github.com/ihabunek/toot.git
synced 2025-02-02 15:07:51 -05:00
Add custom fields to status output
This commit is contained in:
parent
459937f196
commit
baa5a37125
@ -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"]):
|
||||
|
Loading…
x
Reference in New Issue
Block a user