Module: Onebox::Engine::StandardEmbed

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_oembed_provider(regexp, endpoint) ⇒ Object



12
13
14
# File 'lib/onebox/engine/standard_embed.rb', line 12

def self.add_oembed_provider(regexp, endpoint)
  oembed_providers[regexp] = endpoint
end

.add_opengraph_provider(regexp) ⇒ Object



20
21
22
# File 'lib/onebox/engine/standard_embed.rb', line 20

def self.add_opengraph_provider(regexp)
  opengraph_providers << regexp
end

.oembed_providersObject



8
9
10
# File 'lib/onebox/engine/standard_embed.rb', line 8

def self.oembed_providers
  @@oembed_providers ||= {}
end

.opengraph_providersObject



16
17
18
# File 'lib/onebox/engine/standard_embed.rb', line 16

def self.opengraph_providers
  @@opengraph_providers ||= []
end

Instance Method Details

#always_https?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/onebox/engine/standard_embed.rb', line 32

def always_https?
  WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.https_hosts) || super
end

#rawObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/onebox/engine/standard_embed.rb', line 36

def raw
  return @raw if @raw

  og = get_opengraph
  twitter = get_twitter
  oembed = get_oembed

  @raw = {}

  og.data.each do |k, v|
    next if k == "title_attr"
    v = og.send(k)
    @raw[k] ||= v unless v.nil?
  end

  twitter.each { |k, v| @raw[k] ||= v unless Onebox::Helpers::blank?(v) }

  oembed.data.each do |k, v|
    v = oembed.send(k)
    @raw[k] ||= v unless v.nil?
  end

  favicon = get_favicon
  @raw["favicon".to_sym] = favicon unless Onebox::Helpers::blank?(favicon)

  @raw
end