Class: Onebox::Engine::InstagramOnebox

Inherits:
Object
  • Object
show all
Includes:
Onebox::Engine, StandardEmbed, LayoutSupport
Defined in:
lib/onebox/engine/instagram_onebox.rb

Constant Summary

Constants included from Onebox::Engine

DEFAULT

Instance Attribute Summary

Attributes included from Onebox::Engine

#timeout, #uri, #url

Instance Method Summary collapse

Methods included from LayoutSupport

#layout, max_text, #to_html

Methods included from StandardEmbed

add_oembed_provider, add_opengraph_provider, #always_https?, oembed_providers, opengraph_providers, #raw

Methods included from Onebox::Engine

engines, included, #initialize, #options, #options=, #placeholder_html, #to_html

Instance Method Details

#clean_urlObject



13
14
15
# File 'lib/onebox/engine/instagram_onebox.rb', line 13

def clean_url
  url.scan(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/?(?:.*)\/p\/[a-zA-Z\d_-]+/).flatten.first
end

#dataObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/onebox/engine/instagram_onebox.rb', line 17

def data
  oembed = get_oembed
  permalink = clean_url.gsub("/#{oembed.author_name}/", "/")

  { link: permalink,
    title: "@#{oembed.author_name}",
    image: "#{permalink}/media/?size=l",
    description: Onebox::Helpers.truncate(oembed.title, 250)
  }
end