Files
danbooru/app/controllers/iqdb_queries_controller.rb
evazion d8142a6c21 iqdb_queries_controller.rb: simplify show / check actions.
* Combine create_by_post + create_by_url. Rename to find_similar.
* Move iqdb enabled check to find_similar.
2018-04-07 18:03:01 -05:00

30 lines
751 B
Ruby

# todo: move this to iqdbs
class IqdbQueriesController < ApplicationController
respond_to :html, :json, :xml
def show
@results = find_similar
respond_with(@results) do |fmt|
fmt.html { render :layout => false, :action => "create_by_url" }
fmt.js { render :layout => false, :action => "create_by_post" }
end
end
def check
@results = find_similar
respond_with(@results)
end
# Support both POST /iqdb_queries and GET /iqdb_queries.
alias_method :create, :show
protected
def find_similar
return [] if params[:url].blank? && params[:post_id].blank?
params[:url] = Post.find(params[:post_id]).preview_file_url if params[:post_id].present?
Iqdb::Download.find_similar(params[:url])
end
end