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