From 694ee30e86b531ad63721a4da10bec1cd374920d Mon Sep 17 00:00:00 2001 From: riking Date: Tue, 21 Apr 2015 23:06:40 -0700 Subject: [PATCH 1/2] FIX: Uploaded files could not be oneboxed --- lib/onebox/engine/discourse_local_onebox.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/onebox/engine/discourse_local_onebox.rb b/lib/onebox/engine/discourse_local_onebox.rb index 7857f5555..d8bf15376 100644 --- a/lib/onebox/engine/discourse_local_onebox.rb +++ b/lib/onebox/engine/discourse_local_onebox.rb @@ -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) From 3681674ec4dfc01ace08276c224faad5dd2befe8 Mon Sep 17 00:00:00 2001 From: riking Date: Tue, 21 Apr 2015 23:11:25 -0700 Subject: [PATCH 2/2] FIX: Don't cache-bust onebox requests --- app/assets/javascripts/discourse/lib/onebox.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/onebox.js b/app/assets/javascripts/discourse/lib/onebox.js index bb282ce15..e39635bea 100644 --- a/app/assets/javascripts/discourse/lib/onebox.js +++ b/app/assets/javascripts/discourse/lib/onebox.js @@ -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