This commit is contained in:
YoheiZuho 2022-05-16 13:09:28 +09:00
parent 533b81d2d0
commit 908ad46f30
2 changed files with 12 additions and 6 deletions

View File

@ -5,10 +5,6 @@ module FormattingHelper
HtmlAwareFormatter.new(text, local, options).to_s HtmlAwareFormatter.new(text, local, options).to_s
end end
def quotify(html, status, text, local, options = {})
QuoteFormatter.new(html, status, text, local, options).to_s
end
def linkify(text, options = {}) def linkify(text, options = {})
TextFormatter.new(text, options).to_s TextFormatter.new(text, options).to_s
end end
@ -19,7 +15,7 @@ module FormattingHelper
module_function :extract_status_plain_text module_function :extract_status_plain_text
def status_content_format(status) 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 end
def account_bio_format(account) def account_bio_format(account)

View File

@ -31,7 +31,7 @@ class TextFormatter
end end
def to_s def to_s
return ''.html_safe if text.blank? return ''.html_safe if text.blank? & !quote?
html = rewrite do |entity| html = rewrite do |entity|
if entity[:url] if entity[:url]
@ -43,6 +43,8 @@ class TextFormatter
end end
end end
html += quotify if quote?
html = simple_format(html, {}, sanitize: false).delete("\n") if multiline? html = simple_format(html, {}, sanitize: false).delete("\n") if multiline?
html.html_safe # rubocop:disable Rails/OutputSafety html.html_safe # rubocop:disable Rails/OutputSafety
@ -126,6 +128,14 @@ class TextFormatter
HTML HTML
end end
def render_quote
url = ActivityPub::TagManager.instance.url_for(status.quote)
link = encode_and_link_urls(url)
<<~HTML.squish
<span class="quote-inline"><br/>QT: #{link}</span>"
HTML
end
def entity_cache def entity_cache
@entity_cache ||= EntityCache.instance @entity_cache ||= EntityCache.instance
end end