fixes #3300
This commit is contained in:
@@ -138,7 +138,7 @@
|
||||
if (Danbooru.RelatedTag.recent_artists[0].is_banned === true) {
|
||||
tags.push(["BANNED_ARTIST", "banned"]);
|
||||
}
|
||||
$.each(Danbooru.RelatedTag.recent_artists[0].urls, function(i, url) {
|
||||
$.each(Danbooru.RelatedTag.recent_artists[0].sorted_urls, function(i, url) {
|
||||
tags.push([" " + url.url, 0]);
|
||||
});
|
||||
} else if (Danbooru.RelatedTag.recent_artists.length >= 10) {
|
||||
|
||||
@@ -102,7 +102,7 @@ class ArtistsController < ApplicationController
|
||||
|
||||
def finder
|
||||
begin
|
||||
@artists = Artist.url_matches(params[:url]).order("id desc").limit(20)
|
||||
@artists = Artist.url_matches(params[:url]).order("id desc").limit(10)
|
||||
if @artists.empty? && params[:referer_url].present? && params[:referer_url] != params[:url]
|
||||
@artists = Artist.url_matches(params[:referer_url]).order("id desc").limit(20)
|
||||
end
|
||||
@@ -112,10 +112,10 @@ class ArtistsController < ApplicationController
|
||||
|
||||
respond_with(@artists) do |format|
|
||||
format.xml do
|
||||
render :xml => @artists.to_xml(:include => [:urls], :root => "artists")
|
||||
render :xml => @artists.to_xml(:include => [:sorted_urls], :root => "artists")
|
||||
end
|
||||
format.json do
|
||||
render :json => @artists.to_json(:include => [:urls])
|
||||
render :json => @artists.to_json(:include => [:sorted_urls])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,6 +60,10 @@ class Artist < ApplicationRecord
|
||||
memoize :domains
|
||||
end
|
||||
|
||||
def sorted_urls
|
||||
urls.sort {|a, b| a.priority <=> b.priority}
|
||||
end
|
||||
|
||||
def url_array
|
||||
urls.map(&:url)
|
||||
end
|
||||
|
||||
@@ -53,6 +53,24 @@ class ArtistUrl < ApplicationRecord
|
||||
url = url.gsub(/^http:\/\/i\d+\.pixiv\.net\/img\d+/, "http://*.pixiv.net/img*")
|
||||
end
|
||||
|
||||
def priority
|
||||
if normalized_url =~ /pixiv\.net\/member\.php/
|
||||
10
|
||||
|
||||
elsif normalized_url =~ /seiga\.nicovideo\.jp\/user\/illust/
|
||||
10
|
||||
|
||||
elsif normalized_url =~ /twitter\.com/ && normalized_url !~ /status/
|
||||
10
|
||||
|
||||
elsif normalized_url =~ /tumblr|patreon|deviantart|artstation/
|
||||
20
|
||||
|
||||
else
|
||||
100
|
||||
end
|
||||
end
|
||||
|
||||
def normalize
|
||||
if !Sources::Site.new(normalized_url).normalized_for_artist_finder?
|
||||
self.normalized_url = self.class.normalize(url)
|
||||
|
||||
Reference in New Issue
Block a user