#1866: Normalize urls in artist finder
This commit is contained in:
@@ -247,7 +247,7 @@
|
|||||||
Danbooru.RelatedTag.find_artist = function(e) {
|
Danbooru.RelatedTag.find_artist = function(e) {
|
||||||
$("#artist-tags").html("<em>Loading...</em>");
|
$("#artist-tags").html("<em>Loading...</em>");
|
||||||
var url = $("#upload_source,#post_source");
|
var url = $("#upload_source,#post_source");
|
||||||
$.get("/artists.json", {"limit": 20, "search[name]": url.val()}).success(Danbooru.RelatedTag.process_artist);
|
$.get("/artists/finder.json", {"url": url.val()}).success(Danbooru.RelatedTag.process_artist);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,4 +110,24 @@ class ArtistsController < ApplicationController
|
|||||||
redirect_to new_artist_path(:name => params[:name])
|
redirect_to new_artist_path(:name => params[:name])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def finder
|
||||||
|
url = params[:url]
|
||||||
|
headers = {
|
||||||
|
"User-Agent" => "#{Danbooru.config.safe_app_name}/#{Danbooru.config.version}"
|
||||||
|
}
|
||||||
|
Downloads::Strategies::Base.strategies.each do |strategy|
|
||||||
|
url, headers = strategy.new.rewrite(url, headers)
|
||||||
|
end
|
||||||
|
|
||||||
|
@artists = Artist.url_matches(url).order("id desc").limit(20)
|
||||||
|
respond_with(@artists) do |format|
|
||||||
|
format.xml do
|
||||||
|
render :xml => @artists.to_xml(:include => [:urls], :root => "artists")
|
||||||
|
end
|
||||||
|
format.json do
|
||||||
|
render :json => @artists.to_json(:include => [:urls])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<%= error_messages_for "upload" %>
|
<%= error_messages_for "upload" %>
|
||||||
|
|
||||||
<%= form_for(@upload, :html => {:multipart => true, :class => "simple_form", :id => 'form'}) do |f| %>
|
<%= form_for(@upload, :html => {:multipart => true, :class => "simple_form", :id => "form"}) do |f| %>
|
||||||
<% if CurrentUser.is_contributor? %>
|
<% if CurrentUser.is_contributor? %>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<label for="upload_as_pending">
|
<label for="upload_as_pending">
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ Danbooru::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_versions, :only => [:index] do
|
resources :artist_versions, :only => [:index] do
|
||||||
|
|||||||
Reference in New Issue
Block a user