Discourse Spoiler Alert provides the ability to hide content marked with a [spoiler] tag in posts.
Install Guide
This plugin is bundled with Discourse core. There is no need to install the plugin separately.
Enabling Spoiler Alert
This plugin is default enabled once installed but can be disabled/enabled from its settings, accessed from your admin/plugins page:
Features
Once enabled it adds a ‘Blur Spoiler’ option to the menu in the composer’s formatting bar. Simply highlight the text you’d like to blur and select ‘blur spoiler’ and it will wrap the selected text in the necessary [spoiler] tags:
[spoiler]
I wanna be your vacuum cleaner
Breathing in your dust
I wanna be your Ford Cortina
I will never rust
If you like your coffee hot
Let me be your coffee pot
You call the shots
I wanna be yours
https://johncooperclarke.com/poems/i-wanna-be-yours
[/spoiler]
I wanna be your vacuum cleaner
Breathing in your dust
I wanna be your Ford Cortina
I will never rust
If you like your coffee hot
Let me be your coffee pot
You call the shots
I wanna be yours
Clicking on the blur will reveal the hidden text, and clicking again will re-blur it.
It also works for images:
(to re-blur an image that is large enough to generate a lightbox, you can click on the adjacent white space or refresh the page)
Is there anyway to edit the contents of how the spoiler preview looks? The current implementation looks nice, but it doesn’t abstract enough as far as what it’s spoiling.
Here’s an example from a thread I made, where users can upload their screenshots. If the screenshot is a spoiler, it needs to be tagged as such. As you can tell, the current implementation doesn’t really work in the context of spoiler tagging screenshots of critical moments in games, movies, etc.
Anyone who is familiar with the game I shared would immediately know what it is.
Edit: It’s also come to my attention that if any user clicks the edit history of a post that contains spoilers, the edit history will not spoiler tag the contents.
Not sure if this is worth a separate bug report or not, but realized via a chat push notification that the spoiler text isn’t being redacted like it does for everything else – Chat::Message#push_notification_excerpt truncates the raw markdown and will literally output the spoiler as this is a chat notification [spoiler]and this is the spoiler[/spoiler], which kind of defeats the purpose of a spoiler tag, if it outputs the whole spoiler in the notification! Seems like an oversight as it bypasses spoiler-alert’s :reduce_excerpt completely for a chat message vs a forum post. It otherwise functions just fine in chat! it’s the push notification that’s the problem.