Class: Onebox::Engine::InstagramOnebox
Instance Attribute Summary
#errors, #options, #timeout, #uri, #url
Instance Method Summary
collapse
#layout, max_text
add_oembed_provider, add_opengraph_provider, #always_https?, oembed_providers, opengraph_providers, #raw
all_iframe_origins, engines, included, #initialize, origins_to_regexes
Instance Method Details
#clean_url ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/onebox/engine/instagram_onebox.rb', line 16
def clean_url
url
.scan(
%r{^https?://(?:www\.)?(?:instagram\.com|instagr\.am)/?(?:.*)/(?:p|tv)/[a-zA-Z\d_-]+},
)
.flatten
.first
end
|
#data ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/onebox/engine/instagram_onebox.rb', line 25
def data
@data ||=
begin
oembed = get_oembed
if oembed.data.empty?
raise "No oEmbed data found. Ensure 'facebook_app_access_token' is valid"
end
{
link: clean_url.gsub("/#{oembed.author_name}/", "/") + "/embed",
title: "@#{oembed.author_name}",
image: oembed.thumbnail_url,
image_width: oembed.data[:thumbnail_width],
image_height: oembed.data[:thumbnail_height],
description: Onebox::Helpers.truncate(oembed.title, 250),
}
end
end
|
#placeholder_html ⇒ Object
#to_html ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/onebox/engine/instagram_onebox.rb', line 48
def to_html
<<-HTML
<iframe
src="#{data[:link]}"
width="#{data[:image_width]}"
height="#{data[:image_height].to_i + 98}"
frameborder="0"
></iframe>
HTML
end
|