mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Merge pull request #814 from ZogStriP/keep-reloaders-happy
prevent warning message about already defined constants
This commit is contained in:
commit
d4a0d4f5dd
2 changed files with 3 additions and 6 deletions
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue