From f394d78c1e45b75ad4f2dd29cd8e267e73f6fd3e Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Sun, 31 Dec 2023 13:16:28 +0000 Subject: [PATCH 1/2] tui: keep CW note after opening toot Continue to display 'Marked as sensitive' in the toot view even after the CW has been opened. This matches the behaviour of other clients, and is useful to see because it might affect whether you want to boost the toot or not (for example). --- toot/tui/timeline.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/toot/tui/timeline.py b/toot/tui/timeline.py index 0cc7756..a14ada2 100644 --- a/toot/tui/timeline.py +++ b/toot/tui/timeline.py @@ -340,6 +340,9 @@ class StatusDetails(urwid.Pile): if status.data["spoiler_text"] and not status.show_sensitive: yield ("pack", urwid.Text(("content_warning", "Marked as sensitive. Press S to view."))) else: + if status.data["spoiler_text"]: + yield ("pack", urwid.Text(("content_warning", "Marked as sensitive."))) + content = status.original.translation if status.original.show_translation else status.data["content"] widgetlist = html_to_widgets(content) From 1ed129f5dd393bb4e651d832130df9d829609730 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Sun, 31 Dec 2023 13:27:37 +0000 Subject: [PATCH 2/2] tui: add --always-show-sensitive option When enabled, this option expands toots with content warnings automatically, instead of requiring the user to press 'S'. --- toot/cli/tui.py | 9 ++++++++- toot/tui/app.py | 1 + toot/tui/timeline.py | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/toot/cli/tui.py b/toot/cli/tui.py index 391f8e3..c13b745 100644 --- a/toot/cli/tui.py +++ b/toot/cli/tui.py @@ -29,11 +29,17 @@ COLOR_OPTIONS = ", ".join(TUI_COLORS.keys()) type=click.Choice(VISIBILITY_CHOICES), help="Default visibility when posting new toots; overrides the server-side preference" ) +@click.option( + "-S", "--always-show-sensitive", + is_flag=True, + help="Expand toots with content warnings automatically" +) @pass_context def tui( ctx: Context, colors: Optional[int], media_viewer: Optional[str], + always_show_sensitive: bool, relative_datetimes: bool, default_visibility: Optional[str] ): @@ -45,7 +51,8 @@ def tui( colors=colors, media_viewer=media_viewer, relative_datetimes=relative_datetimes, - default_visibility=default_visibility + default_visibility=default_visibility, + always_show_sensitive=always_show_sensitive, ) tui = TUI.create(ctx.app, ctx.user, options) tui.run() diff --git a/toot/tui/app.py b/toot/tui/app.py index 5d9982b..b19b7a2 100644 --- a/toot/tui/app.py +++ b/toot/tui/app.py @@ -30,6 +30,7 @@ DEFAULT_MAX_TOOT_CHARS = 500 class TuiOptions(NamedTuple): colors: int media_viewer: Optional[str] + always_show_sensitive: bool relative_datetimes: bool default_visibility: Optional[bool] diff --git a/toot/tui/timeline.py b/toot/tui/timeline.py index a14ada2..1c6090e 100644 --- a/toot/tui/timeline.py +++ b/toot/tui/timeline.py @@ -313,6 +313,7 @@ class StatusDetails(urwid.Pile): def __init__(self, timeline: Timeline, status: Optional[Status]): self.status = status self.followed_accounts = timeline.tui.followed_accounts + self.options = timeline.tui.options reblogged_by = status.author if status and status.reblog else None widget_list = list(self.content_generator(status.original, reblogged_by) @@ -337,7 +338,7 @@ class StatusDetails(urwid.Pile): yield ("pack", urwid.Divider()) # Show content warning - if status.data["spoiler_text"] and not status.show_sensitive: + if status.data["spoiler_text"] and not status.show_sensitive and not self.options.always_show_sensitive: yield ("pack", urwid.Text(("content_warning", "Marked as sensitive. Press S to view."))) else: if status.data["spoiler_text"]: