mastodon / mastodon

Your self-hosted, globally interconnected microblogging community
https://joinmastodon.org
GNU Affero General Public License v3.0
47.28k stars 7.01k forks source link

Support for inline spoilers / spoiler tags #17115

Open trwnh opened 2 years ago

trwnh commented 2 years ago

Pitch

Summary

Similar to how mentions and hashtags are metadata with inline representations, I propose support for an additional type of metadata: spoiler tags.

ActivityPub representation

Just like mentions and hashtags, spoiler tags can be added to the tag property on a Note:

{
...
  "content": "@trwnh Personally, I was really surprised when I found out that Darth Vader is Luke Skywalker's father. #mindblown"
  "tag": [
    {
      "type": "Mention",
      "href": "https://mastodon.social/users/trwnh",
      "name": "@trwnh"
    },
    {
      "type": "Spoiler",
      "name": "Darth Vader is Luke Skywalker's father"
    },
    {
      "type": "Hashtag",
      "href": "https://mastodon.social/tags/mindblown",
      "name": "#mindblown"
    }
  ],
...
}

Mastodon API

Perhaps a spoiler_tags property on the Status entity? This could be an array of Strings to search through content and hide upon finding each string. To remove ambiguity, perhaps include a <span> tag, maybe something like <span class="spoiler">Darth Vader is Luke Skywalker's father</span>. This would not violate the current HTML sanitizer or the API expectations.

Client UI

This is potentially the most contentious part of the feature request, as the most natural way to add support for this feature would be through a different controversial feature request: rich text formatting. Discord handles spoilers by using || as a delimiter at the start and end of the spoiler text; some forums use pseudo-HTML <spoiler></spoiler>, and so on, but IMO the most natural way is to provide a button on highlight that will mark the selected text as a spoiler. However, there's nothing stopping the adoption of another syntax for this, similar to @ for mentions and # for hashtags -- perhaps %[], or simply reusing Discord's ||||.

Motivation

Sometimes you want finer-grained control and don't want to hide an entire status behind a CW, which would make the entire status be marked as "sensitive" and introduce knock-on effects for things like image attachments and potential filtering by certain clients.

shleeable commented 2 years ago

I could imagine this could extend to the inline text, but I know big G doesn't want markdown or anything in the toots.

something awful method always made sense.

image

Clicking on the black.

image
RokeJulianLockhart commented 1 year ago

We could use https://github.com/LemmyNet/lemmy-ui/issues/687#issuecomment-1619177350

```html ``` tags like https://help.disqus.com/en/articles/1717306-spoiler-tags
georgeh commented 1 year ago

When USENET was used for discussions, people would frequently use rot13 encoding for spoilers. The content block of the note could potentially be rot13'd to prevent spoilers from displaying on other ActivityPub platforms. e.g.:

{
...
  "content": "@trwnh Personally, I was really surprised when I found out that Qnegu Inqre vf Yhxr Fxljnyxre'f sngure. #mindblown"
  "tag": [
    {
      "type": "Mention",
      "href": "https://mastodon.social/users/trwnh",
      "name": "@trwnh"
    },
    {
      "type": "Spoiler",
      "name": "Qnegu Inqre vf Yhxr Fxljnyxre'f sngure",
      "encoding": "rot13"
    },
    {
      "type": "Hashtag",
      "href": "https://mastodon.social/tags/mindblown",
      "name": "#mindblown"
    }
  ],
...
}