Merge pull request #3387 from riking/fix-uploaded-onebox

FIX: Local files never oneboxed, onebox requests cache-busted
This commit is contained in:
Robin Ward 2015-04-22 10:37:09 -04:00
commit afc12da2f9
2 changed files with 21 additions and 1 deletions

View file

@ -51,7 +51,8 @@ Discourse.Onebox = {
// Retrieve the onebox
var promise = Discourse.ajax("/onebox", {
dataType: 'html',
data: { url: url, refresh: refresh }
data: { url: url, refresh: refresh },
cache: true
});
// We can call this when loading is complete

View file

@ -10,6 +10,25 @@ module Onebox
1
end
def self.===(other)
if other.kind_of?(URI)
uri = other
begin
route = Rails.application.routes.recognize_path(uri.path)
case route[:controller]
when 'topics'
true
else
false
end
rescue ActionController::RoutingError
false
end
else
super
end
end
def to_html
uri = URI::parse(@url)
route = Rails.application.routes.recognize_path(uri.path)