Merge pull request #814 from ZogStriP/keep-reloaders-happy

prevent warning message about already defined constants
This commit is contained in:
Sam 2013-05-05 17:52:22 -07:00
commit d4a0d4f5dd
2 changed files with 3 additions and 6 deletions

View file

@ -5,7 +5,9 @@ module Oneboxer
class HandlebarsOnebox < BaseOnebox
unless defined? MAX_TEXT
MAX_TEXT = 500
end
def self.template_path(template_name)
"#{Rails.root}/lib/oneboxer/templates/#{template_name}.hbrs"

View file

@ -5,8 +5,6 @@ module Oneboxer
class OembedOnebox < HandlebarsOnebox
MAX_TEXT = 500
def oembed_endpoint
@url
end
@ -16,12 +14,10 @@ module Oneboxer
end
def onebox
parsed = JSON.parse(open(oembed_endpoint).read)
# If it's a video, just embed the iframe
if %w(video rich).include?(parsed['type'])
# Return a preview of the thumbnail url, since iframes don't do well on previews
preview = nil
preview = "<img src='#{parsed['thumbnail_url']}'>" if parsed['thumbnail_url'].present?
@ -35,7 +31,6 @@ module Oneboxer
parsed['html'] ||= parsed['abstract']
parsed['host'] = nice_host
Mustache.render(File.read(template), parsed)
rescue OpenURI::HTTPError
nil