refactor iqdb query support
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
<div id="c-iqdb-queries">
|
||||
<div id="a-check">
|
||||
<h1>IQDB Queries</h1>
|
||||
<section>
|
||||
<%= form_tag(check_iqdb_queries_path, :method => :get, :class => "simple_form inline-form" ) do %>
|
||||
<div class="input string optional">
|
||||
<%= label_tag "url", "URL", class: "string optional" %>
|
||||
<%= text_field_tag "url", params[:url] %>
|
||||
</div>
|
||||
<div class="input string optional">
|
||||
<%= label_tag "post_id", "Post ID", class: "string optional" %>
|
||||
<%= text_field_tag "post_id", params[:post_id] %>
|
||||
</div>
|
||||
<%= submit_tag "Check" %>
|
||||
<% end %>
|
||||
</section>
|
||||
<% if params[:url].present? || params[:post_id].present? %>
|
||||
<section>
|
||||
<h2>Similar results</h2>
|
||||
<% if @results.any? %>
|
||||
<% @results.each do |match| %>
|
||||
<%= PostPresenter.preview(match[:post], :tags => "status:any", :size => true, :similarity => match[:score]) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p>No matches found</p>
|
||||
<% end %>
|
||||
</section>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
IQDB Queries - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
78
app/views/iqdb_queries/show.html.erb
Normal file
78
app/views/iqdb_queries/show.html.erb
Normal file
@@ -0,0 +1,78 @@
|
||||
<div id="c-iqdb-queries">
|
||||
<div id="a-check">
|
||||
<h1>Similar Images Search</h1>
|
||||
<section>
|
||||
<p>You can upload a file or paste a URL to perform an image similarity search with every upload on <%= Danbooru.config.app_name %>. Note that this page will redirect you to <%= link_to "IQDBS", Danbooru.config.iqdbs_server %>. You will be redirected back here once the search is executed.</p>
|
||||
|
||||
<%= form_tag("#{Danbooru.config.iqdbs_server}/similar", method: :post, class: "simple_form", multipart: true ) do %>
|
||||
<%= hidden_field_tag "callback", iqdb_queries_url %>
|
||||
|
||||
<div class="input string optional">
|
||||
<%= label_tag "url", "URL", class: "string optional" %>
|
||||
<%= text_field_tag "url", params[:url] %>
|
||||
</div>
|
||||
|
||||
<div class="input string optional fallback">
|
||||
<%= label_tag "file", "File", class: "string optional" %>
|
||||
<%= file_field_tag :file, :size => 50 %>
|
||||
</div>
|
||||
|
||||
<div id="filedropzone">
|
||||
<span class="hint">Drag and drop a file here</span>
|
||||
</div>
|
||||
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</section>
|
||||
|
||||
<% if @matches %>
|
||||
<section>
|
||||
<h2>Similar results</h2>
|
||||
<% if @matches.any? %>
|
||||
<% @matches.each do |post, score| %>
|
||||
<%= PostPresenter.preview(post, :tags => "status:any", :size => true, :similarity => score) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p>No matches found</p>
|
||||
<% end %>
|
||||
</section>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Similar Images Search - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:html_header) do %>
|
||||
<script async src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.4.0/min/dropzone.min.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#filedropzone").dropzone({
|
||||
paramName: "file",
|
||||
url: "/iqdb_queries",
|
||||
createImageThumbnails: false,
|
||||
addRemoveLinks: false,
|
||||
maxFiles: 1,
|
||||
acceptedFiles: "image/jpeg,image/png,image/gif",
|
||||
previewTemplate: '<div class="dz-preview dz-file-preview"><div class="dz-details"><div class="dz-filename"><span data-dz-name></span></div><div class="dz-size" data-dz-size></div></div><div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div><div class="dz-error-message"><span data-dz-errormessage></span></div></div>',
|
||||
init: function() {
|
||||
$(".fallback").hide();
|
||||
|
||||
this.on("drop", function(event) {
|
||||
$("#filedropzone .placeholder").hide();
|
||||
});
|
||||
this.on("complete", function(file) {
|
||||
$("#filedropzone .dz-progress").hide();
|
||||
});
|
||||
this.on("success", function(file) {
|
||||
$("#filedropzone").addClass("success");
|
||||
});
|
||||
this.on("error", function(file, msg) {
|
||||
$("#filedropzone").addClass("error");
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
||||
@@ -16,6 +16,7 @@
|
||||
<% if CurrentUser.is_moderator? %>
|
||||
<li><%= link_to("Mass Edit", edit_moderator_tag_path) %></li>
|
||||
<% end %>
|
||||
<li><%= link_to("Similar Images Search", iqdb_queries_path) %></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><h1>Post Events</h1></li>
|
||||
@@ -33,7 +34,6 @@
|
||||
<li><%= link_to("Bookmarklet", bookmarklet_path) %></li>
|
||||
<li><%= link_to("User Scripts", wiki_pages_path(title: "about:userscripts")) %></li>
|
||||
<li><%= link_to("API Documentation", wiki_pages_path(:title => "help:api")) %></li>
|
||||
<li><%= link_to("IQDB Queries", check_iqdb_queries_path) %></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><h1>Artists</h1></li>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<li><%= link_to "Listing", uploads_path %></li>
|
||||
<li><%= link_to "New", new_upload_path %></li>
|
||||
<li><%= link_to "Batch Upload", batch_uploads_path %></li>
|
||||
<li><%= link_to "IQDB", check_iqdb_queries_path %></li>
|
||||
<li><%= link_to "Similar Images Search", iqdb_queries_path %></li>
|
||||
<li><%= link_to "Help", wiki_pages_path(search: { title: "help:upload" }) %></li>
|
||||
</menu>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user