correct hack and move to oneboxer

This commit is contained in:
Sam
2015-09-25 20:14:38 +10:00
parent 5a297fe31c
commit 57870b970d
3 changed files with 21 additions and 15 deletions

View File

@ -245,19 +245,7 @@ class CookedPostProcessor
}
# apply oneboxes
Oneboxer.apply(@doc) { |url|
# hack urls to create proper expansions
if url =~ Regexp.new("^#{Discourse.base_url.gsub(".","\\.")}.*$", true)
uri = URI.parse(url) rescue nil
if uri && uri.path
route = Rails.application.routes.recognize_path(uri.path) rescue nil
if route && route[:controller] == 'topics'
url += (url =~ /\?/ ? "&" : "?") + "&source_topic_id=#{@post.topic_id}"
end
end
end
Oneboxer.apply(@doc, topic_id: @post.topic_id) { |url|
Oneboxer.onebox(url, args)
}