discourse/app/controllers/onebox_controller.rb

18 lines
378 B
Ruby
Raw Normal View History

2013-02-06 03:16:51 +08:00
require_dependency 'oneboxer'
class OneboxController < ApplicationController
def show
2013-03-22 08:47:44 +08:00
result = Oneboxer.preview(params[:url], invalidate_oneboxes: params[:refresh] == 'true')
result.strip! if result.present?
# If there is no result, return a 404
if result.blank?
render nothing: true, status: 404
else
render text: result
end
2013-02-06 03:16:51 +08:00
end
end