diff options
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/atom_serializer.rb | 2 | ||||
-rw-r--r-- | app/lib/formatter.rb | 24 |
2 files changed, 8 insertions, 18 deletions
diff --git a/app/lib/atom_serializer.rb b/app/lib/atom_serializer.rb index 920eac31b..6b0faf75f 100644 --- a/app/lib/atom_serializer.rb +++ b/app/lib/atom_serializer.rb @@ -332,7 +332,7 @@ class AtomSerializer end def serialize_status_attributes(entry, status) - append_element(entry, 'summary', status.spoiler_text, 'xml:lang': status.language) if status.spoiler_text? + append_element(entry, 'summary', Formatter.instance.format(status.proper, :spoiler_text, false).to_str, 'xml:lang': status.language, type: 'html') if status.spoiler_text? append_element(entry, 'content', Formatter.instance.format(status.proper).to_str, type: 'html', 'xml:lang': status.language) status.mentions.each do |mentioned| diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index 5b008278c..5a1b63c0a 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -9,13 +9,15 @@ class Formatter include ActionView::Helpers::TextHelper - def format(status) - return reformat(status.content) unless status.local? + def format(status, attribute = :text, paragraphize = true) + raw_content = status.public_send(attribute) - html = status.text - html = encode_and_link_urls(html, status.mentions) + return '' if raw_content.blank? + return reformat(raw_content) unless status.local? - html = simple_format(html, {}, sanitize: false) + html = raw_content + html = encode_and_link_urls(html, status.mentions) + html = simple_format(html, {}, sanitize: false) if paragraphize html = html.delete("\n") html.html_safe # rubocop:disable Rails/OutputSafety @@ -25,18 +27,6 @@ class Formatter 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_and_link_urls(html) - - html = simple_format(html, {}, sanitize: false) - html = html.delete("\n") - - html.html_safe # rubocop:disable Rails/OutputSafety - end - def plaintext(status) return status.text if status.local? strip_tags(status.text) |