FIX: Minor Twitter onebox improvements (#22387)
This commit is contained in:
parent
de192b1fbd
commit
77732cd2b4
|
@ -679,6 +679,11 @@ aside.onebox.twitterstatus .onebox-body {
|
|||
margin-right: 0.25em;
|
||||
}
|
||||
}
|
||||
|
||||
.is-reply {
|
||||
color: var(--primary-medium);
|
||||
margin-right: 0.25em;
|
||||
}
|
||||
}
|
||||
|
||||
// Onebox - Imgur/Flickr - Album
|
||||
|
|
|
@ -141,6 +141,12 @@ module Onebox
|
|||
end
|
||||
end
|
||||
|
||||
def is_reply
|
||||
if twitter_api_credentials_present?
|
||||
raw.dig(:data, :referenced_tweets)&.any? { |tweet| tweet.dig(:type) == "replied_to" }
|
||||
end
|
||||
end
|
||||
|
||||
def quoted_full_name
|
||||
if twitter_api_credentials_present? && quoted_tweet_author.present?
|
||||
quoted_tweet_author[:name]
|
||||
|
@ -216,6 +222,7 @@ module Onebox
|
|||
avatar: avatar,
|
||||
likes: likes,
|
||||
retweets: retweets,
|
||||
is_reply: is_reply,
|
||||
quoted_text: quoted_text,
|
||||
quoted_full_name: quoted_full_name,
|
||||
quoted_screen_name: quoted_screen_name,
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
<div class="twitter-screen-name"><a href="{{link}}" target="_blank" rel="noopener">@{{screen_name}}</a></div>
|
||||
|
||||
<div class="tweet">
|
||||
{{#is_reply}}
|
||||
<span class="is-reply">
|
||||
<svg class="fa d-icon d-icon-reply svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use href="#reply"></use></svg>
|
||||
</span>
|
||||
{{/is_reply}}
|
||||
<span class="tweet-description">{{{tweet}}}</span>
|
||||
{{#quoted_text}}
|
||||
<div class="quoted">
|
||||
|
|
|
@ -15,15 +15,17 @@ class TwitterApi
|
|||
text = tweet[:data][:text].dup.to_s
|
||||
if (entities = tweet[:data][:entities]) && (urls = entities[:urls])
|
||||
urls.each do |url|
|
||||
text.gsub!(
|
||||
url[:url],
|
||||
"<a target='_blank' href='#{url[:expanded_url]}'>#{url[:display_url]}</a>",
|
||||
)
|
||||
if !url[:display_url].start_with?("pic.twitter.com")
|
||||
text.gsub!(
|
||||
url[:url],
|
||||
"<a target='_blank' href='#{url[:expanded_url]}'>#{url[:display_url]}</a>",
|
||||
)
|
||||
else
|
||||
text.gsub!(url[:url], "")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
text = link_hashtags_in link_handles_in text
|
||||
|
||||
result = Rinku.auto_link(text, :all, 'target="_blank"').to_s
|
||||
|
||||
if tweet[:includes] && media = tweet[:includes][:media]
|
||||
|
|
Loading…
Reference in New Issue