Show content warning in status details

This commit is contained in:
Ivan Habunek 2019-08-29 14:01:26 +02:00
parent 85ceb8b11f
commit 1dce948166
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
3 changed files with 20 additions and 3 deletions

View File

@ -4,7 +4,7 @@ PALETTE = [
('button', 'white', 'black'),
('button_focused', 'light gray', 'dark magenta'),
('editbox', 'white', 'black'),
('editbox_focused', '', 'dark magenta'),
('editbox_focused', 'white', 'dark magenta'),
('footer_message', 'dark green', ''),
('footer_message_error', 'light red', ''),
('footer_status', 'white', 'dark blue'),
@ -13,6 +13,7 @@ PALETTE = [
('header_bold', 'white,bold', 'dark blue'),
('intro_bigtext', 'yellow', ''),
('intro_smalltext', 'light blue', ''),
('content_warning', 'white', 'dark magenta'),
# Functional
('hashtag', 'light cyan,bold', ''),

View File

@ -24,6 +24,9 @@ class Status:
self.data = data
self.instance = instance
# This can be toggled by the user
self.show_sensitive = False
# TODO: make Status immutable?
self.id = self.data["id"]

View File

@ -122,6 +122,11 @@ class Timeline(urwid.Columns):
self._emit("reply", status)
return
if key in ("s", "S"):
status.show_sensitive = True
self.refresh_status_details()
return
if key in ("t", "T"):
self._emit("thread", status)
return
@ -194,8 +199,16 @@ class StatusDetails(urwid.Pile):
yield ("pack", urwid.Text(("yellow", status.author.account)))
yield ("pack", urwid.Divider())
for line in format_content(status.data["content"]):
yield ("pack", urwid.Text(highlight_hashtags(line)))
if status.data["spoiler_text"]:
yield ("pack", urwid.Text(status.data["spoiler_text"]))
yield ("pack", urwid.Divider())
# Show content warning
if status.data["spoiler_text"] and not status.show_sensitive:
yield ("pack", urwid.Text(("content_warning", "Marked as sensitive. Press S to view.")))
else:
for line in format_content(status.data["content"]):
yield ("pack", urwid.Text(highlight_hashtags(line)))
media = status.data["media_attachments"]
if media: