artists: replace artist finder with fetch source data.

* On posts, automatically trigger "Fetch source data" when clicking the
  Edit tab, instead of triggering the artist finder button. This way we
  find both the artist and the translated tags in one ajax call.

* Remove the "Artist" finder button next to the source field. This isn't
  necessary given that "Fetch source data" finds the artist itself.

* Remove the /artists/finder.json API endpoint. This is no longer used
  after removing the "Artist" finder button.
This commit is contained in:
evazion
2018-09-08 15:39:50 -05:00
parent a5df178bcc
commit 10ca4dd3ad
7 changed files with 5 additions and 39 deletions

View File

@@ -92,20 +92,6 @@ class ArtistsController < ApplicationController
end end
end end
def finder
@artists = Artist.find_artists(params[:url], params[:referer_url])
respond_with(@artists) do |format|
format.xml do
render :xml => @artists.to_xml(:include => [:sorted_urls], :root => "artists")
end
format.json do
render :json => @artists.to_json(:include => [:sorted_urls])
expires_in params[:expiry].to_i.days if params[:expiry]
end
end
end
private private
def load_artist def load_artist

View File

@@ -441,7 +441,7 @@ Post.initialize_post_sections = function() {
$("#share").hide(); $("#share").hide();
$("#post_tag_string").focus().selectEnd().height($("#post_tag_string")[0].scrollHeight); $("#post_tag_string").focus().selectEnd().height($("#post_tag_string")[0].scrollHeight);
$("#related-tags-button").trigger("click"); $("#related-tags-button").trigger("click");
$("#find-artist-button").trigger("click"); $("#fetch-data-manual").trigger("click");
$("#recommended").hide(); $("#recommended").hide();
} else if (e.target.hash === "#recommended") { } else if (e.target.hash === "#recommended") {
$("#comments").hide(); $("#comments").hide();

View File

@@ -1,3 +1,4 @@
import Upload from './uploads';
import Utility from './utility'; import Utility from './utility';
import Cookie from './cookie'; import Cookie from './cookie';
@@ -16,7 +17,6 @@ RelatedTag.initialize_buttons = function() {
<% TagCategory.related_button_list.each do |category| %> <% TagCategory.related_button_list.each do |category| %>
RelatedTag.common_bind("#related-<%= category %>-button", "<%= category %>"); // eslint-disable-line indent RelatedTag.common_bind("#related-<%= category %>-button", "<%= category %>"); // eslint-disable-line indent
<% end %> <% end %>
$("#find-artist-button").on("click.danbooru", RelatedTag.find_artist);
} }
RelatedTag.tags_include = function(name) { RelatedTag.tags_include = function(name) {
@@ -281,21 +281,6 @@ RelatedTag.toggle_tag = function(e) {
e.preventDefault(); e.preventDefault();
} }
RelatedTag.find_artist = function(e) {
$("#artist-tags").html("<em>Loading...</em>");
var url = $("#upload_source,#post_source");
var referer_url = $("#upload_referer_url");
$.get("/artists/finder.json", {"url": url.val(), "referer_url": referer_url.val()}, RelatedTag.process_artist);
if (e) {
e.preventDefault();
}
}
RelatedTag.process_artist = function(data) {
RelatedTag.recent_artists = data;
RelatedTag.build_all();
}
RelatedTag.toggle = function() { RelatedTag.toggle = function() {
if ($("#related-tags").is(":visible")) { if ($("#related-tags").is(":visible")) {
RelatedTag.hide(); RelatedTag.hide();
@@ -332,7 +317,7 @@ RelatedTag.disable_artist_url = function(e) {
is_active: false is_active: false
} }
} }
}).done(RelatedTag.find_artist); }).done(Upload.fetch_data_manual);
} }
}); });
return false; return false;

View File

@@ -69,7 +69,6 @@
<%= f.label :source %> <%= f.label :source %>
<%= f.text_field :source %> <%= f.text_field :source %>
<%= button_tag "Similar", :id => "similar-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %> <%= button_tag "Similar", :id => "similar-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
<%= button_tag "Artist", :id => "find-artist-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
</div> </div>
<% if Danbooru.config.iqdbs_server %> <% if Danbooru.config.iqdbs_server %>

View File

@@ -43,7 +43,6 @@
<%= f.label :source %> <%= f.label :source %>
<%= f.text_field :source, :size => 50, :value => params[:url] %> <%= f.text_field :source, :size => 50, :value => params[:url] %>
<%= button_tag "Similar", :id => "similar-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %> <%= button_tag "Similar", :id => "similar-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
<%= button_tag "Artist", :id => "find-artist-button", :type => "button", :class => "ui-button ui-widget ui-corner-all sub gradient" %>
<span class="hint">You can enter a URL to have <%= Danbooru.config.app_name %> automatically download and process it</span> <span class="hint">You can enter a URL to have <%= Danbooru.config.app_name %> automatically download and process it</span>
</div> </div>

View File

@@ -79,7 +79,6 @@ Rails.application.routes.draw do
collection do collection do
get :show_or_new get :show_or_new
get :banned get :banned
get :finder
end end
end end
resources :artist_urls, only: [:update] resources :artist_urls, only: [:update]

View File

@@ -3,7 +3,7 @@ require 'test_helper'
class ArtistsControllerTest < ActionDispatch::IntegrationTest class ArtistsControllerTest < ActionDispatch::IntegrationTest
def assert_artist_found(expected_artist, source_url = nil) def assert_artist_found(expected_artist, source_url = nil)
if source_url if source_url
get_auth finder_artists_path(format: "json", url: source_url), @user get_auth artists_path(format: "json", search: { url_matches: source_url }), @user
if response.body =~ /Net::OpenTimeout/ if response.body =~ /Net::OpenTimeout/
skip "Remote connection to #{source_url} failed" skip "Remote connection to #{source_url} failed"
return return
@@ -16,9 +16,7 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest
end end
def assert_artist_not_found(source_url) def assert_artist_not_found(source_url)
tries = 0 get_auth artists_path(format: "json", search: { url_matches: source_url }), @user
get_auth finder_artists_path(format: "json", url: source_url), @user
if response.body =~ /Net::OpenTimeout/ if response.body =~ /Net::OpenTimeout/
skip "Remote connection to #{source_url} failed" skip "Remote connection to #{source_url} failed"
return return