sanitize(html, Sanitize::Config::MASTODON_STRICT).html_safe # rubocop:disable Rails/OutputSafety
end
+ def format_spoiler(status)
+ return reformat(status.spoiler_text) unless status.local?
+
+ html = status.spoiler_text
+ html = encode(html)
+ html = html.delete("\n")
+ html = link_hashtags(html)
+
+ html.html_safe # rubocop:disable Rails/OutputSafety
+ end
+
def plaintext(status)
return status.text if status.local?
strip_tags(status.text)
class ProcessHashtagsService < BaseService
def call(status, tags = [])
- tags = status.text.scan(Tag::HASHTAG_RE).map(&:first) if status.local?
+ text = [status.text, status.spoiler_text].reject(&:empty?).join(' ')
+ tags = text.scan(Tag::HASHTAG_RE).map(&:first) if status.local?
tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |tag|
status.tags << Tag.where(name: tag).first_or_initialize(name: tag)
.status__content.p-name.emojify<
- if status.spoiler_text?
%p{ style: 'margin-bottom: 0' }<
- %span.p-summary> #{status.spoiler_text}
+ %span.p-summary> #{Formatter.instance.format_spoiler(status)}
%a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more')
.e-content{ lang: status.language, style: "display: #{status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status)
.status__content.p-name.emojify<
- if status.spoiler_text?
%p{ style: 'margin-bottom: 0' }<
- %span.p-summary> #{status.spoiler_text}
+ %span.p-summary> #{Formatter.instance.format_spoiler(status)}
%a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more')
.e-content{ lang: status.language, style: "display: #{status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status)