forked from cybrespace/mastodon
Hotlink twitter mentions
Differentiate twitter mentions from normal mentions
This commit is contained in:
parent
ba06a5f485
commit
99b3c18b28
|
@ -212,8 +212,9 @@ class Formatter
|
|||
|
||||
def link_to_mention(entity, linkable_accounts)
|
||||
acct = entity[:screen_name]
|
||||
username, domain = acct.split('@')
|
||||
|
||||
return link_to_account(acct) unless linkable_accounts
|
||||
return link_to_account(acct) unless linkable_accounts and domain != "twitter.com"
|
||||
|
||||
account = linkable_accounts.find { |item| TagManager.instance.same_acct?(item.acct, acct) }
|
||||
account ? mention_html(account) : "@#{encode(acct)}"
|
||||
|
@ -222,6 +223,10 @@ class Formatter
|
|||
def link_to_account(acct)
|
||||
username, domain = acct.split('@')
|
||||
|
||||
if domain == "twitter.com"
|
||||
return mention_twitter_html(username)
|
||||
end
|
||||
|
||||
domain = nil if TagManager.instance.local_domain?(domain)
|
||||
account = EntityCache.instance.mention(username, domain)
|
||||
|
||||
|
@ -249,4 +254,8 @@ class Formatter
|
|||
def mention_html(account)
|
||||
"<span class=\"h-card\"><a href=\"#{encode(TagManager.instance.url_for(account))}\" class=\"u-url mention\">@<span>#{encode(account.username)}</span></a></span>"
|
||||
end
|
||||
|
||||
def mention_twitter_html(username)
|
||||
"<span class=\"h-card\"><a href=\"https://twitter.com/#{username}\" class=\"u-url mention\">@<span>#{username}@twitter.com</span></a></span>"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue