mirror of
https://github.com/ihabunek/toot
synced 2025-02-03 12:47:32 +01:00
Merge pull request #450 from lexiwinter/autoopen-cw
add an option to automatically expand content warnings
This commit is contained in:
commit
fda498d793
@ -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()
|
||||
|
@ -33,6 +33,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]
|
||||
|
||||
|
@ -319,6 +319,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)
|
||||
@ -343,9 +344,12 @@ 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"]:
|
||||
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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user