#1866: Normalize urls in artist finder

This commit is contained in:
Toks
2013-12-25 12:43:54 -05:00
parent 8055a7c64b
commit 3a9a6c6658
4 changed files with 23 additions and 2 deletions

View File

@@ -110,4 +110,24 @@ class ArtistsController < ApplicationController
redirect_to new_artist_path(:name => params[:name])
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