mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 04:56:18 +08:00
e37fb3042d
* Remove checkmark for official plugins * Add author for plugin, which is By Discourse for all discourse and discourse-org github plugins * Link to meta topic instead of github repo * Add experimental flag for plugin metadata and show this as a badge on the plugin list if present --------- Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com>
30 lines
815 B
Ruby
30 lines
815 B
Ruby
# frozen_string_literal: true
|
|
|
|
# name: spoiler-alert
|
|
# about: Uses the Spoiler Alert plugin to blur text when spoiling it.
|
|
# meta_topic_id: 12650
|
|
# version: 1.1.0
|
|
# authors: Discourse Team
|
|
# url: https://github.com/discourse/discourse/tree/main/plugins/spoiler-alert
|
|
# transpile_js: true
|
|
|
|
enabled_site_setting :spoiler_enabled
|
|
|
|
register_asset "stylesheets/discourse_spoiler_alert.scss"
|
|
|
|
after_initialize do
|
|
on(:reduce_cooked) do |fragment, post|
|
|
fragment
|
|
.css(".spoiler")
|
|
.each do |el|
|
|
link = fragment.document.create_element("a")
|
|
link["href"] = post.url
|
|
link.content = I18n.t("spoiler_alert.excerpt_spoiler")
|
|
el.inner_html = link.to_html
|
|
end
|
|
end
|
|
|
|
# Remove spoilers from topic excerpts
|
|
on(:reduce_excerpt) { |doc, post| doc.css(".spoiler").remove }
|
|
end
|