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
|
class IqdbQueriesController < ApplicationController
|
||||||
respond_to :html, :json
|
respond_to :html, :json, :xml, :js
|
||||||
before_action :detect_xhr
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if params[:url]
|
if params[:url]
|
||||||
@@ -16,22 +15,6 @@ class IqdbQueriesController < ApplicationController
|
|||||||
@matches = IqdbProxy.decorate_posts(JSON.parse(params[:matches]))
|
@matches = IqdbProxy.decorate_posts(JSON.parse(params[:matches]))
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_with(@matches) do |fmt|
|
respond_with(@matches)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ Upload.validate_upload = function (e) {
|
|||||||
|
|
||||||
Upload.initialize_iqdb_source = function() {
|
Upload.initialize_iqdb_source = function() {
|
||||||
if (/^https?:\/\//.test($("#upload_source").val())) {
|
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