mirror of
https://github.com/discourse/discourse.git
synced 2025-02-09 21:04:48 +00:00
Merge pull request #4766 from davidtaylorhq/twitter_onebox_fixes
Twitter onebox improvements
This commit is contained in:
commit
0f9fb01c6b
@ -4,7 +4,7 @@ class TwitterApi
|
|||||||
class << self
|
class << self
|
||||||
|
|
||||||
def prettify_tweet(tweet)
|
def prettify_tweet(tweet)
|
||||||
text = tweet["text"].dup
|
text = tweet["full_text"].dup
|
||||||
if entities = tweet["entities"] and urls = entities["urls"]
|
if entities = tweet["entities"] and urls = entities["urls"]
|
||||||
urls.each do |url|
|
urls.each do |url|
|
||||||
text.gsub!(url["url"], "<a target='_blank' href='#{url["expanded_url"]}'>#{url["display_url"]}</a>")
|
text.gsub!(url["url"], "<a target='_blank' href='#{url["expanded_url"]}'>#{url["display_url"]}</a>")
|
||||||
@ -22,6 +22,10 @@ class TwitterApi
|
|||||||
if large = m['sizes']['large']
|
if large = m['sizes']['large']
|
||||||
result << "<img class='tweet-image' src='#{m['media_url_https']}' width='#{large['w']}' height='#{large['h']}'>"
|
result << "<img class='tweet-image' src='#{m['media_url_https']}' width='#{large['w']}' height='#{large['h']}'>"
|
||||||
end
|
end
|
||||||
|
elsif m['type'] == 'video'
|
||||||
|
if large = m['sizes']['large']
|
||||||
|
result << "<iframe class='tweet-video' src='https://twitter.com/i/videos/#{tweet['id_str']}' width='#{large['w']}' height='#{large['h']}' frameborder='0'></iframe>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
result << "</div>"
|
result << "</div>"
|
||||||
@ -81,7 +85,7 @@ class TwitterApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tweet_uri_for(id)
|
def tweet_uri_for(id)
|
||||||
URI.parse "#{BASE_URL}/1.1/statuses/show.json?id=#{id}"
|
URI.parse "#{BASE_URL}/1.1/statuses/show.json?id=#{id}&tweet_mode=extended"
|
||||||
end
|
end
|
||||||
|
|
||||||
unless defined? BASE_URL
|
unless defined? BASE_URL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user