Class: Onebox::Engine::InstagramOnebox
- Inherits:
-
Object
- Object
- Onebox::Engine::InstagramOnebox
- Includes:
- Onebox::Engine, StandardEmbed, LayoutSupport
- Defined in:
- lib/onebox/engine/instagram_onebox.rb
Constant Summary
Constants included from Onebox::Engine
Instance Attribute Summary
Attributes included from Onebox::Engine
Instance Method Summary collapse
Methods included from LayoutSupport
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_url ⇒ Object
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 |
#data ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/onebox/engine/instagram_onebox.rb', line 17 def data = permalink = clean_url.gsub("/#{.}/", "/") description = .title type = if description =~ /^Photos by/ "album" elsif description =~ /^Video by/ "video" else "photo" end title = if type == "album" "[Album] @#{.}" else "@#{.}" end result = { link: permalink, title: title, image: "#{permalink}/media/?size=l", description: Onebox::Helpers.truncate(description, 250) } result[:video_link] = permalink if type == "video" result end |