Files
danbooru/app/controllers/iqdb_queries_controller.rb
evazion ca54e2d67b iqdb: simplify ajax call.
Also add support for .xml responses to /iqdb_queries.
2019-10-14 21:16:04 -05:00

21 lines
493 B
Ruby

class IqdbQueriesController < ApplicationController
respond_to :html, :json, :xml, :js
def show
if params[:url]
strategy = Sources::Strategies.find(params[:url])
@matches = IqdbProxy.query(strategy.image_url)
end
if params[:post_id]
@matches = IqdbProxy.query(Post.find(params[:post_id]).preview_file_url)
end
if params[:matches]
@matches = IqdbProxy.decorate_posts(JSON.parse(params[:matches]))
end
respond_with(@matches)
end
end