diff --git a/app/helpers/formatting_helper.rb b/app/helpers/formatting_helper.rb index 9e76f8bde..c1ede0496 100644 --- a/app/helpers/formatting_helper.rb +++ b/app/helpers/formatting_helper.rb @@ -5,10 +5,6 @@ module FormattingHelper HtmlAwareFormatter.new(text, local, options).to_s end - def quotify(html, status, text, local, options = {}) - QuoteFormatter.new(html, status, text, local, options).to_s - end - def linkify(text, options = {}) TextFormatter.new(text, options).to_s end @@ -19,7 +15,7 @@ module FormattingHelper module_function :extract_status_plain_text def status_content_format(status) - html_aware_format(status.text, status.local?, preloaded_accounts: [status.account] + (status.respond_to?(:active_mentions) ? status.active_mentions.map(&:account) : [])) + html_aware_format(status.text, status.local?, preloaded_accounts: [status.account] + (status.respond_to?(:active_mentions) ? status.active_mentions.map(&:account) : []),quote: status.respond_to?(:quote) && status.quote,) end def account_bio_format(account) diff --git a/app/lib/text_formatter.rb b/app/lib/text_formatter.rb index 48e2fc233..5bcd8eb90 100644 --- a/app/lib/text_formatter.rb +++ b/app/lib/text_formatter.rb @@ -31,7 +31,7 @@ class TextFormatter end def to_s - return ''.html_safe if text.blank? + return ''.html_safe if text.blank? & !quote? html = rewrite do |entity| if entity[:url] @@ -43,6 +43,8 @@ class TextFormatter end end + html += quotify if quote? + html = simple_format(html, {}, sanitize: false).delete("\n") if multiline? html.html_safe # rubocop:disable Rails/OutputSafety @@ -126,6 +128,14 @@ class TextFormatter HTML end + def render_quote + url = ActivityPub::TagManager.instance.url_for(status.quote) + link = encode_and_link_urls(url) + <<~HTML.squish +
QT: #{link}
" + HTML + end + def entity_cache @entity_cache ||= EntityCache.instance end