mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge branch 'whitespace-cleanese' of git://github.com/goshakkk/discourse
Conflicts: lib/oneboxer.rb lib/oneboxer/whitelist.rb spec/controllers/robots_txt_controller_spec.rb
This commit is contained in:
@@ -2,8 +2,8 @@ require 'open-uri'
|
||||
|
||||
require_dependency 'oneboxer/base'
|
||||
require_dependency 'oneboxer/whitelist'
|
||||
Dir["#{Rails.root}/lib/oneboxer/*_onebox.rb"].each {|f|
|
||||
require_dependency(f.split('/')[-2..-1].join('/'))
|
||||
Dir["#{Rails.root}/lib/oneboxer/*_onebox.rb"].each {|f|
|
||||
require_dependency(f.split('/')[-2..-1].join('/'))
|
||||
}
|
||||
|
||||
module Oneboxer
|
||||
@@ -30,7 +30,7 @@ module Oneboxer
|
||||
def self.onebox_nocache(url)
|
||||
oneboxer = onebox_for_url(url)
|
||||
return oneboxer.onebox if oneboxer.present?
|
||||
|
||||
|
||||
whitelist_entry = Whitelist.entry_for_url(url)
|
||||
|
||||
if whitelist_entry.present?
|
||||
@@ -44,7 +44,7 @@ module Oneboxer
|
||||
return OembedOnebox.new(oembed[:href]).onebox
|
||||
end
|
||||
(doc/"link[@type='text/json+oembed']").each do |oembed|
|
||||
return OembedOnebox.new(oembed[:href]).onebox
|
||||
return OembedOnebox.new(oembed[:href]).onebox
|
||||
end
|
||||
end
|
||||
|
||||
@@ -78,7 +78,7 @@ module Oneboxer
|
||||
|
||||
def self.create_post_reference(result, args={})
|
||||
result.post_onebox_renders.create(post_id: args[:post_id]) if args[:post_id].present?
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
end
|
||||
|
||||
def self.render_from_cache(url, args={})
|
||||
@@ -89,7 +89,7 @@ module Oneboxer
|
||||
create_post_reference(result, args)
|
||||
return result
|
||||
end
|
||||
nil
|
||||
nil
|
||||
end
|
||||
|
||||
# Cache results from a onebox call
|
||||
@@ -103,13 +103,13 @@ module Oneboxer
|
||||
render = OneboxRender.create(url: url, preview: preview, cooked: cooked, expires_at: Oneboxer.default_expiry.from_now)
|
||||
create_post_reference(render, args)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
[cooked, preview]
|
||||
[cooked, preview]
|
||||
end
|
||||
|
||||
# Retrieve a preview of a onebox, caching the result for performance
|
||||
# Retrieve a preview of a onebox, caching the result for performance
|
||||
def self.preview(url, args={})
|
||||
cached = render_from_cache(url, args) unless args[:no_cache].present?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user