Module: Onebox::Engine::StandardEmbed

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_oembed_provider(regexp, endpoint) ⇒ Object


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

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

.add_opengraph_provider(regexp) ⇒ Object


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

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

.oembed_providersObject


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

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

.opengraph_providersObject


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

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

Instance Method Details

#always_https?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'lib/onebox/engine/standard_embed.rb', line 30

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

#rawObject


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/onebox/engine/standard_embed.rb', line 34

def raw
  return @raw if @raw

  og = get_opengraph
  twitter = get_twitter
  oembed = get_oembed

  @raw = {}

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

  @raw
end