Merge pull request #814 from ZogStriP/keep-reloaders-happy
prevent warning message about already defined constants
This commit is contained in:
commit
d4a0d4f5dd
|
@ -5,7 +5,9 @@ module Oneboxer
|
||||||
|
|
||||||
class HandlebarsOnebox < BaseOnebox
|
class HandlebarsOnebox < BaseOnebox
|
||||||
|
|
||||||
|
unless defined? MAX_TEXT
|
||||||
MAX_TEXT = 500
|
MAX_TEXT = 500
|
||||||
|
end
|
||||||
|
|
||||||
def self.template_path(template_name)
|
def self.template_path(template_name)
|
||||||
"#{Rails.root}/lib/oneboxer/templates/#{template_name}.hbrs"
|
"#{Rails.root}/lib/oneboxer/templates/#{template_name}.hbrs"
|
||||||
|
|
|
@ -5,8 +5,6 @@ module Oneboxer
|
||||||
|
|
||||||
class OembedOnebox < HandlebarsOnebox
|
class OembedOnebox < HandlebarsOnebox
|
||||||
|
|
||||||
MAX_TEXT = 500
|
|
||||||
|
|
||||||
def oembed_endpoint
|
def oembed_endpoint
|
||||||
@url
|
@url
|
||||||
end
|
end
|
||||||
|
@ -16,12 +14,10 @@ module Oneboxer
|
||||||
end
|
end
|
||||||
|
|
||||||
def onebox
|
def onebox
|
||||||
|
|
||||||
parsed = JSON.parse(open(oembed_endpoint).read)
|
parsed = JSON.parse(open(oembed_endpoint).read)
|
||||||
|
|
||||||
# If it's a video, just embed the iframe
|
# If it's a video, just embed the iframe
|
||||||
if %w(video rich).include?(parsed['type'])
|
if %w(video rich).include?(parsed['type'])
|
||||||
|
|
||||||
# Return a preview of the thumbnail url, since iframes don't do well on previews
|
# Return a preview of the thumbnail url, since iframes don't do well on previews
|
||||||
preview = nil
|
preview = nil
|
||||||
preview = "<img src='#{parsed['thumbnail_url']}'>" if parsed['thumbnail_url'].present?
|
preview = "<img src='#{parsed['thumbnail_url']}'>" if parsed['thumbnail_url'].present?
|
||||||
|
@ -35,7 +31,6 @@ module Oneboxer
|
||||||
parsed['html'] ||= parsed['abstract']
|
parsed['html'] ||= parsed['abstract']
|
||||||
parsed['host'] = nice_host
|
parsed['host'] = nice_host
|
||||||
|
|
||||||
|
|
||||||
Mustache.render(File.read(template), parsed)
|
Mustache.render(File.read(template), parsed)
|
||||||
rescue OpenURI::HTTPError
|
rescue OpenURI::HTTPError
|
||||||
nil
|
nil
|
||||||
|
|
Loading…
Reference in New Issue