Merge remote-tracking branch 'cybrespace/feature_hotlink_twitter_mentions' into scalybiz
This commit is contained in:
commit
461c5d6d84
|
@ -183,8 +183,9 @@ class Formatter
|
||||||
|
|
||||||
def link_to_mention(entity, linkable_accounts)
|
def link_to_mention(entity, linkable_accounts)
|
||||||
acct = entity[:screen_name]
|
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 = linkable_accounts.find { |item| TagManager.instance.same_acct?(item.acct, acct) }
|
||||||
account ? mention_html(account) : "@#{acct}"
|
account ? mention_html(account) : "@#{acct}"
|
||||||
|
@ -193,6 +194,10 @@ class Formatter
|
||||||
def link_to_account(acct)
|
def link_to_account(acct)
|
||||||
username, domain = acct.split('@')
|
username, domain = acct.split('@')
|
||||||
|
|
||||||
|
if domain == "twitter.com"
|
||||||
|
return mention_twitter_html(username)
|
||||||
|
end
|
||||||
|
|
||||||
domain = nil if TagManager.instance.local_domain?(domain)
|
domain = nil if TagManager.instance.local_domain?(domain)
|
||||||
account = Account.find_remote(username, domain)
|
account = Account.find_remote(username, domain)
|
||||||
|
|
||||||
|
@ -220,4 +225,8 @@ class Formatter
|
||||||
def mention_html(account)
|
def mention_html(account)
|
||||||
"<span class=\"h-card\"><a href=\"#{TagManager.instance.url_for(account)}\" class=\"u-url mention\">@<span>#{account.username}</span></a></span>"
|
"<span class=\"h-card\"><a href=\"#{TagManager.instance.url_for(account)}\" class=\"u-url mention\">@<span>#{account.username}</span></a></span>"
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue