Sha256: 395c6b24f971ff9d510711871731a42f1e900f48d9221b6806a5b9aef26e905c

Contents?: true

Size: 922 Bytes

Versions: 41

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true

require 'htmlentities'

module Onebox
  module Engine
    class InstagramOnebox
      include Engine
      include StandardEmbed
      include LayoutSupport

      matches_regexp(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/?(?:.*)\/p\//)
      always_https

      def data
        og = get_opengraph
        title = og.title.split(":")[0].strip.gsub(" on Instagram", "")

        json_data = html_doc.xpath('//script[contains(text(),"window._sharedData")]').text.to_s
        title = "[Album] #{title}" if json_data =~ /"edge_sidecar_to_children"/

        result = { link: og.url,
                   title: Onebox::Helpers.truncate(title, 80),
                   description: og.description(250)
                  }

        result[:image] = og.image if !og.image.nil?
        result[:video_link] = og.url if !og.video_secure_url.nil?

        result
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
onebox-1.9.10 lib/onebox/engine/instagram_onebox.rb
onebox-1.9.9 lib/onebox/engine/instagram_onebox.rb
onebox-1.9.8 lib/onebox/engine/instagram_onebox.rb
onebox-1.9.7 lib/onebox/engine/instagram_onebox.rb
onebox-1.9.6 lib/onebox/engine/instagram_onebox.rb
onebox-1.9.5 lib/onebox/engine/instagram_onebox.rb
onebox-1.9.4 lib/onebox/engine/instagram_onebox.rb
onebox-1.9.3 lib/onebox/engine/instagram_onebox.rb
onebox-1.9.2 lib/onebox/engine/instagram_onebox.rb
onebox-1.9.1 lib/onebox/engine/instagram_onebox.rb
onebox-1.9.0 lib/onebox/engine/instagram_onebox.rb
onebox-1.8.99 lib/onebox/engine/instagram_onebox.rb
onebox-1.8.98 lib/onebox/engine/instagram_onebox.rb
onebox-1.8.97 lib/onebox/engine/instagram_onebox.rb
onebox-1.8.96 lib/onebox/engine/instagram_onebox.rb
onebox-1.8.95 lib/onebox/engine/instagram_onebox.rb
onebox-1.8.94 lib/onebox/engine/instagram_onebox.rb
onebox-1.8.93 lib/onebox/engine/instagram_onebox.rb
onebox-1.8.92 lib/onebox/engine/instagram_onebox.rb
onebox-1.8.91 lib/onebox/engine/instagram_onebox.rb