mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-11 14:30:35 +00:00
Merge commit '129e72b91494f30777cf4fa8a0905de2dccedba7' into glitch-soc/merge-upstream
Conflicts: - `app/helpers/formatting_helper.rb`: Upstream removed OTel instrumentation around some code modified in glitch-soc because of the Markdown rendering feature. Removed the OTel instrumentation as upstream did.
This commit is contained in:
@@ -27,10 +27,6 @@ Metrics/CyclomaticComplexity:
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 27
|
||||
|
||||
Rails/OutputSafety:
|
||||
Exclude:
|
||||
- 'config/initializers/simple_form.rb'
|
||||
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowedVars.
|
||||
Style/FetchEnvVar:
|
||||
|
||||
@@ -27,14 +27,7 @@ module FormattingHelper
|
||||
module_function :extract_status_plain_text
|
||||
|
||||
def status_content_format(status)
|
||||
MastodonOTELTracer.in_span('HtmlAwareFormatter rendering') do |span|
|
||||
span.add_attributes(
|
||||
'app.formatter.content.type' => 'status',
|
||||
'app.formatter.content.origin' => status.local? ? 'local' : 'remote'
|
||||
)
|
||||
|
||||
html_aware_format(status.text, status.local?, preloaded_accounts: [status.account] + (status.respond_to?(:active_mentions) ? status.active_mentions.map(&:account) : []), content_type: status.content_type)
|
||||
end
|
||||
html_aware_format(status.text, status.local?, preloaded_accounts: [status.account] + (status.respond_to?(:active_mentions) ? status.active_mentions.map(&:account) : []), content_type: status.content_type)
|
||||
end
|
||||
|
||||
def rss_status_content_format(status)
|
||||
@@ -46,14 +39,7 @@ module FormattingHelper
|
||||
end
|
||||
|
||||
def account_bio_format(account)
|
||||
MastodonOTELTracer.in_span('HtmlAwareFormatter rendering') do |span|
|
||||
span.add_attributes(
|
||||
'app.formatter.content.type' => 'account_bio',
|
||||
'app.formatter.content.origin' => account.local? ? 'local' : 'remote'
|
||||
)
|
||||
|
||||
html_aware_format(account.note, account.local?)
|
||||
end
|
||||
html_aware_format(account.note, account.local?)
|
||||
end
|
||||
|
||||
def account_field_value_format(field, with_rel_me: true)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"about.blocks": "Moderated servers",
|
||||
"about.contact": "Contact:",
|
||||
"about.default_locale": "Default",
|
||||
"about.disclaimer": "Mastodon is free, open-source software, and a trademark of Mastodon gGmbH.",
|
||||
"about.domain_blocks.no_reason_available": "Reason not available",
|
||||
"about.domain_blocks.preamble": "Mastodon generally allows you to view content from and interact with users from any other server in the Fediverse. These are the exceptions that have been made on this particular server.",
|
||||
@@ -8,6 +9,7 @@
|
||||
"about.domain_blocks.silenced.title": "Limited",
|
||||
"about.domain_blocks.suspended.explanation": "No data from this server will be processed, stored or exchanged, making any interaction or communication with users from this server impossible.",
|
||||
"about.domain_blocks.suspended.title": "Suspended",
|
||||
"about.language_label": "Language",
|
||||
"about.not_available": "This information has not been made available on this server.",
|
||||
"about.powered_by": "Decentralised social media powered by {mastodon}",
|
||||
"about.rules": "Server rules",
|
||||
@@ -19,10 +21,12 @@
|
||||
"account.block_domain": "Block domain {domain}",
|
||||
"account.block_short": "Block",
|
||||
"account.blocked": "Blocked",
|
||||
"account.blocking": "Blocking",
|
||||
"account.cancel_follow_request": "Cancel follow",
|
||||
"account.copy": "Copy link to profile",
|
||||
"account.direct": "Privately mention @{name}",
|
||||
"account.disable_notifications": "Stop notifying me when @{name} posts",
|
||||
"account.domain_blocking": "Blocking domain",
|
||||
"account.edit_profile": "Edit profile",
|
||||
"account.enable_notifications": "Notify me when @{name} posts",
|
||||
"account.endorse": "Feature on profile",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"about.blocks": "Servidores moderados",
|
||||
"about.contact": "Contacto:",
|
||||
"about.default_locale": "Padrão",
|
||||
"about.disclaimer": "O Mastodon é um software livre, de código aberto e uma marca registada de Mastodon gGmbH.",
|
||||
"about.domain_blocks.no_reason_available": "Motivo não disponível",
|
||||
"about.domain_blocks.preamble": "O Mastodon geralmente permite ver e interagir com o conteúdo de utilizadores de qualquer outra instância no fediverso. Estas são as exceções desta instância em específico.",
|
||||
@@ -8,6 +9,7 @@
|
||||
"about.domain_blocks.silenced.title": "Limitados",
|
||||
"about.domain_blocks.suspended.explanation": "Nenhum dado deste servidor será processado, armazenado ou trocado, tornando impossível qualquer interação ou comunicação com os utilizadores a partir deste servidor.",
|
||||
"about.domain_blocks.suspended.title": "Suspensos",
|
||||
"about.language_label": "Idioma",
|
||||
"about.not_available": "Esta informação não foi disponibilizada neste servidor.",
|
||||
"about.powered_by": "Rede social descentralizada baseada no {mastodon}",
|
||||
"about.rules": "Regras do servidor",
|
||||
@@ -308,6 +310,8 @@
|
||||
"emoji_button.search_results": "Resultados da pesquisa",
|
||||
"emoji_button.symbols": "Símbolos",
|
||||
"emoji_button.travel": "Viagens e lugares",
|
||||
"empty_column.account_featured.me": "Ainda não colocou nada em destaque. Sabia que pode destacar as etiquetas que mais utiliza e até as contas dos seus amigos no seu perfil?",
|
||||
"empty_column.account_featured.other": "{acct} ainda não colocou nada em destaque. Sabia que pode destacar as etiquetas que mais utiliza e até as contas dos seus amigos no seu perfil?",
|
||||
"empty_column.account_featured_other.unknown": "Esta conta ainda não colocou nada em destaque.",
|
||||
"empty_column.account_hides_collections": "Este utilizador escolheu não disponibilizar esta informação",
|
||||
"empty_column.account_suspended": "Conta suspensa",
|
||||
@@ -341,6 +345,11 @@
|
||||
"explore.trending_links": "Notícias",
|
||||
"explore.trending_statuses": "Publicações",
|
||||
"explore.trending_tags": "#Etiquetas",
|
||||
"featured_carousel.header": "{count, plural, one {Publicação Afixada} other {Publicações Afixadas}}",
|
||||
"featured_carousel.next": "Seguinte",
|
||||
"featured_carousel.post": "Publicação",
|
||||
"featured_carousel.previous": "Anterior",
|
||||
"featured_carousel.slide": "{index} de {total}",
|
||||
"filter_modal.added.context_mismatch_explanation": "Esta categoria de filtro não se aplica ao contexto em que acedeste a esta publicação. Se pretenderes que esta publicação seja filtrada também neste contexto, terás que editar o filtro.",
|
||||
"filter_modal.added.context_mismatch_title": "O contexto não coincide!",
|
||||
"filter_modal.added.expired_explanation": "Esta categoria de filtro expirou, tens de alterar a data de validade para que ele seja aplicado.",
|
||||
|
||||
@@ -33,24 +33,17 @@ class TextFormatter
|
||||
def to_s
|
||||
return ''.html_safe if text.blank?
|
||||
|
||||
html = nil
|
||||
MastodonOTELTracer.in_span('TextFormatter#to_s extract_and_rewrite') do
|
||||
html = rewrite do |entity|
|
||||
if entity[:url]
|
||||
link_to_url(entity)
|
||||
elsif entity[:hashtag]
|
||||
link_to_hashtag(entity)
|
||||
elsif entity[:screen_name]
|
||||
link_to_mention(entity)
|
||||
end
|
||||
html = rewrite do |entity|
|
||||
if entity[:url]
|
||||
link_to_url(entity)
|
||||
elsif entity[:hashtag]
|
||||
link_to_hashtag(entity)
|
||||
elsif entity[:screen_name]
|
||||
link_to_mention(entity)
|
||||
end
|
||||
end
|
||||
|
||||
if multiline?
|
||||
MastodonOTELTracer.in_span('TextFormatter#to_s simple_format') do
|
||||
html = simple_format(html, {}, sanitize: false).delete("\n")
|
||||
end
|
||||
end
|
||||
html = simple_format(html, {}, sanitize: false).delete("\n") if multiline?
|
||||
|
||||
html.html_safe # rubocop:disable Rails/OutputSafety
|
||||
end
|
||||
@@ -106,54 +99,48 @@ class TextFormatter
|
||||
end
|
||||
|
||||
def link_to_url(entity)
|
||||
MastodonOTELTracer.in_span('TextFormatter#link_to_url') do
|
||||
TextFormatter.shortened_link(entity[:url], rel_me: with_rel_me?)
|
||||
end
|
||||
TextFormatter.shortened_link(entity[:url], rel_me: with_rel_me?)
|
||||
end
|
||||
|
||||
def link_to_hashtag(entity)
|
||||
MastodonOTELTracer.in_span('TextFormatter#link_to_hashtag') do
|
||||
hashtag = entity[:hashtag]
|
||||
url = tag_url(hashtag)
|
||||
hashtag = entity[:hashtag]
|
||||
url = tag_url(hashtag)
|
||||
|
||||
<<~HTML.squish
|
||||
<a href="#{h(url)}" class="mention hashtag" rel="tag">#<span>#{h(hashtag)}</span></a>
|
||||
HTML
|
||||
end
|
||||
<<~HTML.squish
|
||||
<a href="#{h(url)}" class="mention hashtag" rel="tag">#<span>#{h(hashtag)}</span></a>
|
||||
HTML
|
||||
end
|
||||
|
||||
def link_to_mention(entity)
|
||||
MastodonOTELTracer.in_span('TextFormatter#link_to_mention') do
|
||||
username, domain = entity[:screen_name].split('@')
|
||||
domain = nil if local_domain?(domain)
|
||||
account = nil
|
||||
username, domain = entity[:screen_name].split('@')
|
||||
domain = nil if local_domain?(domain)
|
||||
account = nil
|
||||
|
||||
if preloaded_accounts?
|
||||
same_username_hits = 0
|
||||
if preloaded_accounts?
|
||||
same_username_hits = 0
|
||||
|
||||
preloaded_accounts.each do |other_account|
|
||||
same_username = other_account.username.casecmp(username).zero?
|
||||
same_domain = other_account.domain.nil? ? domain.nil? : other_account.domain.casecmp(domain)&.zero?
|
||||
preloaded_accounts.each do |other_account|
|
||||
same_username = other_account.username.casecmp(username).zero?
|
||||
same_domain = other_account.domain.nil? ? domain.nil? : other_account.domain.casecmp(domain)&.zero?
|
||||
|
||||
if same_username && !same_domain
|
||||
same_username_hits += 1
|
||||
elsif same_username && same_domain
|
||||
account = other_account
|
||||
end
|
||||
if same_username && !same_domain
|
||||
same_username_hits += 1
|
||||
elsif same_username && same_domain
|
||||
account = other_account
|
||||
end
|
||||
else
|
||||
account = entity_cache.mention(username, domain)
|
||||
end
|
||||
|
||||
return "@#{h(entity[:screen_name])}" if account.nil?
|
||||
|
||||
url = ActivityPub::TagManager.instance.url_for(account)
|
||||
display_username = same_username_hits&.positive? || with_domains? ? account.pretty_acct : account.username
|
||||
|
||||
<<~HTML.squish
|
||||
<span class="h-card" translate="no"><a href="#{h(url)}" class="u-url mention">@<span>#{h(display_username)}</span></a></span>
|
||||
HTML
|
||||
else
|
||||
account = entity_cache.mention(username, domain)
|
||||
end
|
||||
|
||||
return "@#{h(entity[:screen_name])}" if account.nil?
|
||||
|
||||
url = ActivityPub::TagManager.instance.url_for(account)
|
||||
display_username = same_username_hits&.positive? || with_domains? ? account.pretty_acct : account.username
|
||||
|
||||
<<~HTML.squish
|
||||
<span class="h-card" translate="no"><a href="#{h(url)}" class="u-url mention">@<span>#{h(display_username)}</span></a></span>
|
||||
HTML
|
||||
end
|
||||
|
||||
def entity_cache
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
module AppendComponent
|
||||
def append(_wrapper_options = nil)
|
||||
@append ||= begin
|
||||
options[:append].to_s.html_safe if options[:append].present?
|
||||
options[:append].to_s.html_safe if options[:append].present? # rubocop:disable Rails/OutputSafety
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -24,7 +24,7 @@ end
|
||||
module WarningHintComponent
|
||||
def warning_hint(_wrapper_options = nil)
|
||||
@warning_hint ||= begin
|
||||
options[:warning_hint].to_s.html_safe if options[:warning_hint].present?
|
||||
options[:warning_hint].to_s.html_safe if options[:warning_hint].present? # rubocop:disable Rails/OutputSafety
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user