about summary refs log tree commit diff
path: root/app/lib/formatter.rb
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-08-17 20:18:52 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:19 -0500
commit4b83bf5c08d58618dfa63b786016759eb5e4d6b6 (patch)
tree18d13486e7003cfb69452b66484dc09337236215 /app/lib/formatter.rb
parentf0a34ccad762a34b153be108e7ba1b6c914317a5 (diff)
[Feature] Post signatures
Diffstat (limited to 'app/lib/formatter.rb')
-rw-r--r--app/lib/formatter.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index 5cc4761e5..5559ddb73 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -61,7 +61,7 @@ class Formatter
     html = "📄 #{html}" if summary_mode
     return html if options[:plaintext]
 
-    linkable_accounts = status.active_mentions.map(&:account)
+    linkable_accounts = status.mentions.map(&:account)
     linkable_accounts << status.account
 
     keep_html = !summary_mode && %w(text/markdown text/html).include?(status.content_type)
@@ -73,20 +73,31 @@ class Formatter
 
     unless keep_html
       html = simple_format(html, {}, sanitize: false)
-      html = html.delete("\n")
+      html.delete!("\n")
     end
 
     html = summary_mode ? format_article_summary(html, status) : format_article_content(summary, html) if summary.present?
+    html = format_footer(html, status.footer, linkable_accounts, status.emojis, **options) if status.footer.present?
     html.html_safe # rubocop:disable Rails/OutputSafety
   end
 
   def format_remote_content(html, emojis, **options)
-    html = reformat(html)
+    html = reformat(html, options[:outgoing])
     html = encode_custom_emojis(html, emojis, options[:autoplay]) if options[:custom_emojify]
     html = format_article_content(options[:summary], html) if options[:article_content] && options[:summary].present?
     html.html_safe # rubocop:disable Rails/OutputSafety
   end
 
+  def format_footer(html, footer, linkable_accounts, emojis, **options)
+    footer = encode_and_link_urls(footer, linkable_accounts)
+    footer = encode_custom_emojis(footer, emojis, options[:autoplay]) if options[:custom_emojify]
+    footer = "<span class=\"invisible\">– </span>#{footer}"
+    footer = simple_format(footer, { 'data-name': 'footer' }, sanitize: false)
+    footer.delete!("\n")
+
+    "#{html}#{footer}"
+  end
+
   def format_markdown(html)
     html = markdown_formatter.render(html)
     html.delete("\r").delete("\n")