mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:44:49 +08:00
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;
|
margin-right: 0.25em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.is-reply {
|
||||||
|
color: var(--primary-medium);
|
||||||
|
margin-right: 0.25em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Onebox - Imgur/Flickr - Album
|
// Onebox - Imgur/Flickr - Album
|
||||||
|
|
|
@ -141,6 +141,12 @@ module Onebox
|
||||||
end
|
end
|
||||||
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
|
def quoted_full_name
|
||||||
if twitter_api_credentials_present? && quoted_tweet_author.present?
|
if twitter_api_credentials_present? && quoted_tweet_author.present?
|
||||||
quoted_tweet_author[:name]
|
quoted_tweet_author[:name]
|
||||||
|
@ -216,6 +222,7 @@ module Onebox
|
||||||
avatar: avatar,
|
avatar: avatar,
|
||||||
likes: likes,
|
likes: likes,
|
||||||
retweets: retweets,
|
retweets: retweets,
|
||||||
|
is_reply: is_reply,
|
||||||
quoted_text: quoted_text,
|
quoted_text: quoted_text,
|
||||||
quoted_full_name: quoted_full_name,
|
quoted_full_name: quoted_full_name,
|
||||||
quoted_screen_name: quoted_screen_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="twitter-screen-name"><a href="{{link}}" target="_blank" rel="noopener">@{{screen_name}}</a></div>
|
||||||
|
|
||||||
<div class="tweet">
|
<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>
|
<span class="tweet-description">{{{tweet}}}</span>
|
||||||
{{#quoted_text}}
|
{{#quoted_text}}
|
||||||
<div class="quoted">
|
<div class="quoted">
|
||||||
|
|
|
@ -15,15 +15,17 @@ class TwitterApi
|
||||||
text = tweet[:data][:text].dup.to_s
|
text = tweet[:data][:text].dup.to_s
|
||||||
if (entities = tweet[:data][:entities]) && (urls = entities[:urls])
|
if (entities = tweet[:data][:entities]) && (urls = entities[:urls])
|
||||||
urls.each do |url|
|
urls.each do |url|
|
||||||
|
if !url[:display_url].start_with?("pic.twitter.com")
|
||||||
text.gsub!(
|
text.gsub!(
|
||||||
url[:url],
|
url[:url],
|
||||||
"<a target='_blank' href='#{url[:expanded_url]}'>#{url[:display_url]}</a>",
|
"<a target='_blank' href='#{url[:expanded_url]}'>#{url[:display_url]}</a>",
|
||||||
)
|
)
|
||||||
|
else
|
||||||
|
text.gsub!(url[:url], "")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
text = link_hashtags_in link_handles_in text
|
text = link_hashtags_in link_handles_in text
|
||||||
|
|
||||||
result = Rinku.auto_link(text, :all, 'target="_blank"').to_s
|
result = Rinku.auto_link(text, :all, 'target="_blank"').to_s
|
||||||
|
|
||||||
if tweet[:includes] && media = tweet[:includes][:media]
|
if tweet[:includes] && media = tweet[:includes][:media]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user