support json for iqdb query actions
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
class IqdbQueriesController < ApplicationController
|
class IqdbQueriesController < ApplicationController
|
||||||
respond_to :html, :json, :xml
|
respond_to :html, :json
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if params[:url]
|
if params[:url]
|
||||||
url = URI.parse(Danbooru.config.iqdbs_server)
|
url = URI.parse(Danbooru.config.iqdbs_server)
|
||||||
url.path = "/similar"
|
url.path = "/similar"
|
||||||
url.query = {callback: iqdb_queries_url, url: params[:url]}.to_query
|
url.query = {callback: iqdb_queries_url(format: params[:format]), url: params[:url]}.to_query
|
||||||
redirect_to url.to_s
|
redirect_to url.to_s
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -14,7 +14,7 @@ class IqdbQueriesController < ApplicationController
|
|||||||
post = Post.find(params[:post_id])
|
post = Post.find(params[:post_id])
|
||||||
url = URI.parse(Danbooru.config.iqdbs_server)
|
url = URI.parse(Danbooru.config.iqdbs_server)
|
||||||
url.path = "/similar"
|
url.path = "/similar"
|
||||||
url.query = {callback: iqdb_queries_url, url: post.preview_file_url}.to_query
|
url.query = {callback: iqdb_queries_url(format: params[:format]), url: post.preview_file_url}.to_query
|
||||||
redirect_to url.to_s
|
redirect_to url.to_s
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
var html = '';
|
|
||||||
<% if @results.any? %>
|
|
||||||
<% @results.each do |match| %>
|
|
||||||
html += '<%= j PostPresenter.preview(match[:post], :tags => "status:any") %>';
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
html += '<p>No matches found</p>';
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
$("<div></div>").html(html).dialog({title: "Similar Posts", modal: true, width: "600px"});
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<% if @results.any? %>
|
|
||||||
<h3>Similar</h3>
|
|
||||||
<% @results.each do |match| %>
|
|
||||||
<%= PostPresenter.preview(match[:post], :tags => "status:any", :size => true, :similarity => match[:score]) %>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
<h3>Similar</h3>
|
|
||||||
<p>No matches found</p>
|
|
||||||
<% end %>
|
|
||||||
3
app/views/iqdb_queries/show.json.erb
Normal file
3
app/views/iqdb_queries/show.json.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<% if @matches %>
|
||||||
|
<%= raw @matches.to_json %>
|
||||||
|
<% end %>
|
||||||
Reference in New Issue
Block a user