Module: Onebox::Engine::StandardEmbed
- Included in:
- AllowlistedGenericOnebox, AsciinemaOnebox, AudioboomOnebox, BandCampOnebox, CloudAppOnebox, CoubOnebox, FacebookMediaOnebox, FiveHundredPxOnebox, FlickrOnebox, FlickrShortenedOnebox, GiphyOnebox, GithubFolderOnebox, GoogleDocsOnebox, GoogleDriveOnebox, GooglePhotosOnebox, ImgurOnebox, InstagramOnebox, KalturaOnebox, MixcloudOnebox, RedditMediaOnebox, ReplitOnebox, SimplecastOnebox, SketchFabOnebox, SlidesOnebox, SoundCloudOnebox, SteamStoreOnebox, TrelloOnebox, VimeoOnebox, WistiaOnebox, YoutubeOnebox
- Defined in:
- lib/onebox/engine/standard_embed.rb
Class Method Summary collapse
- .add_oembed_provider(regexp, endpoint) ⇒ Object
- .add_opengraph_provider(regexp) ⇒ Object
- .oembed_providers ⇒ Object
- .opengraph_providers ⇒ Object
Instance Method Summary collapse
Class Method Details
.add_oembed_provider(regexp, endpoint) ⇒ Object
14 15 16 |
# File 'lib/onebox/engine/standard_embed.rb', line 14 def self.(regexp, endpoint) [regexp] = endpoint end |
.add_opengraph_provider(regexp) ⇒ Object
22 23 24 |
# File 'lib/onebox/engine/standard_embed.rb', line 22 def self.add_opengraph_provider(regexp) opengraph_providers << regexp end |
.oembed_providers ⇒ Object
10 11 12 |
# File 'lib/onebox/engine/standard_embed.rb', line 10 def self. @@oembed_providers ||= {} end |
.opengraph_providers ⇒ Object
18 19 20 |
# File 'lib/onebox/engine/standard_embed.rb', line 18 def self.opengraph_providers @@opengraph_providers ||= [] end |
Instance Method Details
#always_https? ⇒ Boolean
34 35 36 |
# File 'lib/onebox/engine/standard_embed.rb', line 34 def always_https? AllowlistedGenericOnebox.host_matches(uri, AllowlistedGenericOnebox.https_hosts) || super end |
#raw ⇒ Object
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 63 64 |
# File 'lib/onebox/engine/standard_embed.rb', line 38 def raw return @raw if defined?(@raw) og = get_opengraph twitter = get_twitter = @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) } .data.each do |k, v| v = .send(k) @raw[k] ||= v unless v.nil? end favicon = get_favicon @raw["favicon".to_sym] = favicon unless Onebox::Helpers::blank?(favicon) @raw end |