prevent warning message about already defined constants

This commit is contained in:
Régis Hanol 2013-05-04 01:06:05 +02:00
parent 52942d2de6
commit bda04664b0
2 changed files with 3 additions and 6 deletions

View File

@ -5,7 +5,9 @@ module Oneboxer
class HandlebarsOnebox < BaseOnebox
MAX_TEXT = 500
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