about summary refs log tree commit diff
path: root/app/lib/formatter.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-05-11 00:28:10 +0200
committerGitHub <noreply@github.com>2017-05-11 00:28:10 +0200
commit72698bc3b49925a2b2955f32e5a562c1eecd729b (patch)
tree747cf619113cc7377a4e48eaf504892b45a2696f /app/lib/formatter.rb
parent65027657ec5595131bfd82fce1458c9e2cd1afc6 (diff)
Fix regressions from #2683 (#2970)
* Fix regressions from #2683

Properly format spoiler text HTML, while keeping old logic for blankness intact
Process hashtags and mentions in spoiler text
Format spoiler text for Atom
Change "show more" toggle into a button instead of anchor
Fix style regression on dropdowns for detailed statuses

* Fix lint issue

* Convert spoiler text to plaintext in desktop notifications
Diffstat (limited to 'app/lib/formatter.rb')
-rw-r--r--app/lib/formatter.rb24
1 files changed, 7 insertions, 17 deletions
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)