iqdb: simplify ajax call.
Also add support for .xml responses to /iqdb_queries.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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() });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<%= render "iqdb_queries/matches" %>
|
||||
1
app/views/iqdb_queries/show.js.erb
Normal file
1
app/views/iqdb_queries/show.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$("#iqdb-similar").html("<%= j render "iqdb_queries/matches" %>");
|
||||
Reference in New Issue
Block a user