iqdb: simplify ajax call.

Also add support for .xml responses to /iqdb_queries.
This commit is contained in:
evazion
2019-10-14 21:16:04 -05:00
parent ccf32aa7a4
commit ca54e2d67b
4 changed files with 4 additions and 21 deletions

View File

@@ -1,6 +1,5 @@
class IqdbQueriesController < ApplicationController
respond_to :html, :json
before_action :detect_xhr
respond_to :html, :json, :xml, :js
def show
if params[:url]
@@ -16,22 +15,6 @@ class IqdbQueriesController < ApplicationController
@matches = IqdbProxy.decorate_posts(JSON.parse(params[:matches]))
end
respond_with(@matches) do |fmt|
fmt.html do |html|
html.xhr { render layout: false}
end
fmt.json do
render json: @matches
end
end
end
private
def detect_xhr
if request.xhr?
request.variant = :xhr
end
respond_with(@matches)
end
end

View File

@@ -68,7 +68,7 @@ Upload.validate_upload = function (e) {
Upload.initialize_iqdb_source = function() {
if (/^https?:\/\//.test($("#upload_source").val())) {
$.get("/iqdb_queries", {"url": $("#upload_source").val()}).done(function(html) {$("#iqdb-similar").html(html)});
$.get("/iqdb_queries.js", { url: $("#upload_source").val() });
}
}

View File

@@ -1 +0,0 @@
<%= render "iqdb_queries/matches" %>

View File

@@ -0,0 +1 @@
$("#iqdb-similar").html("<%= j render "iqdb_queries/matches" %>");