A bit of a hack to accept any webpage...

This commit is contained in:
Michael Ball 2020-07-10 21:22:10 -07:00
parent 7d2135f851
commit 74b77e132d

View file

@ -18,10 +18,16 @@ class Commercial < ApplicationRecord
resource = OEmbed::Providers.get(url, maxwidth: 560, maxheight: 315) resource = OEmbed::Providers.get(url, maxwidth: 560, maxheight: 315)
{ html: resource.html.html_safe } { html: resource.html.html_safe }
rescue StandardError => exception rescue StandardError => exception
{ error: exception.message } { html: iframe_fallback(url) }
# { error: exception.message }
end end
end end
def self.iframe_fallback(url)
# <br><a href='#{url}' target=_blank>Open in a new tab</a>
"<iframe src=\"#{url}\"></iframe>".html_safe
end
def self.read_file(file) def self.read_file(file)
errors = {} errors = {}
errors[:no_event] = [] errors[:no_event] = []
@ -67,11 +73,10 @@ class Commercial < ApplicationRecord
OEmbed::Providers::Instagram, OEmbed::Providers::Instagram,
speakerdeck speakerdeck
) )
# OEmbed::Providers.register_fallback(
OEmbed::Providers.register_fallback( # OEmbed::ProviderDiscovery,
OEmbed::ProviderDiscovery, # OEmbed::Providers::Noembed
OEmbed::Providers::Noembed # )
)
end end
def conference_id def conference_id