sources: add artist profile links to fetch source data box.

Add site icons linking to all the artist's sites in the fetch source
data box.

Some artist entries have a large number of URLs. Various heuristics are
applied to try to present the most useful URLs first. Dead URLs and
redundant URLs (Pixiv stacc and Twitter intent URLs) are filtered out.
Remaining URLs are sorted first by site (to put sites like Pixiv and
Twitter first), then by URL (to break ties when an artist has multiple
accounts on the same site).

Some sites have shitty hard-to-read icons. It can't be helped. The icons
are the official favicons of each site.
This commit is contained in:
evazion
2021-02-26 01:04:44 -06:00
parent e1ef94faf7
commit 7b60a476e5
35 changed files with 248 additions and 64 deletions

View File

@@ -60,7 +60,47 @@ module Sources
end
def site_name
Addressable::URI.heuristic_parse(url)&.host
host = Addressable::URI.heuristic_parse(url)&.host
# XXX should go in dedicated strategies.
case host
when /bcy\.net\z/i
"BCY"
when /booth\.pm\z/i
"Booth.pm"
when /circle\.ms\z/i
"Circle.ms"
when /dlsite\.(com|net)\z/i
"DLSite"
when /facebook\.com\z/i
"Facebook"
when /fantia\.jp\z/i
"Fantia"
when /fc2\.com\z/i
"FC2"
when /gumroad\.com\z/i
"Gumroad"
when /instagram\.com\z/i
"Instagram"
when /lofter\.com\z/i
"Lofter"
when /melonbooks\.co\.jp\z/i
"Melonbooks"
when /patreon\.com\z/i
"Patreon"
when /privatter\.net\z/i
"Privatter"
when /skeb\.jp\z/i
"Skeb"
when /tinami\.com\z/i
"Tinami"
when /toranoana\.(jp|shop)\z/i
"Toranoana"
when /youtube\.com\z/i
"Youtube"
else
host
end
rescue Addressable::URI::InvalidURIError
nil
end

View File

@@ -90,7 +90,12 @@ module Sources
end
def site_name
"Pixiv"
# XXX pixiv sketch should be in a separate strategy
if parsed_url.host.in?(%w[sketch.pixiv.net img-sketch.pixiv.net img-sketch.pximg.net])
"Pixiv Sketch"
else
"Pixiv"
end
end
def image_urls