sources: add methods for customizing new artist entries.
* Rename `unique_id` to `tag_name`. * Add `other_names` and `profile_urls` methods that sources can override to provide extra names or urls when creating new artist entries.
This commit is contained in:
@@ -101,13 +101,33 @@ module Sources
|
|||||||
page_url || image_url
|
page_url || image_url
|
||||||
end
|
end
|
||||||
|
|
||||||
# A link to the artist's profile page on the site.
|
# A name to suggest as the artist's tag name when creating a new artist.
|
||||||
def profile_url
|
# This should usually be the artist's account name.
|
||||||
""
|
def tag_name
|
||||||
|
artist_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# The artists's primary name. If an artist has both a display name and an
|
||||||
|
# account name, this should be the display name.
|
||||||
def artist_name
|
def artist_name
|
||||||
""
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# A list of all names associated with the artist. These names will be suggested
|
||||||
|
# as other names when creating a new artist.
|
||||||
|
def other_names
|
||||||
|
[artist_name, tag_name].compact.uniq
|
||||||
|
end
|
||||||
|
|
||||||
|
# A link to the artist's profile page on the site.
|
||||||
|
def profile_url
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# A list of all profile urls associated with the artist. These urls will
|
||||||
|
# be suggested when creating a new artist.
|
||||||
|
def profile_urls
|
||||||
|
[normalize_for_artist_finder]
|
||||||
end
|
end
|
||||||
|
|
||||||
def artist_commentary_title
|
def artist_commentary_title
|
||||||
@@ -157,11 +177,6 @@ module Sources
|
|||||||
profile_url.presence || url
|
profile_url.presence || url
|
||||||
end
|
end
|
||||||
|
|
||||||
# A unique identifier for the artist. This is used for artist creation.
|
|
||||||
def unique_id
|
|
||||||
artist_name
|
|
||||||
end
|
|
||||||
|
|
||||||
def artists
|
def artists
|
||||||
Artist.find_artists(normalize_for_artist_finder)
|
Artist.find_artists(normalize_for_artist_finder)
|
||||||
end
|
end
|
||||||
@@ -170,9 +185,9 @@ module Sources
|
|||||||
# exist. Used in Artist.new_with_defaults to prefill the new artist form.
|
# exist. Used in Artist.new_with_defaults to prefill the new artist form.
|
||||||
def new_artist
|
def new_artist
|
||||||
Artist.new(
|
Artist.new(
|
||||||
name: unique_id,
|
name: tag_name,
|
||||||
other_names: [artist_name],
|
other_names: other_names,
|
||||||
url_string: [profile_url, normalize_for_artist_finder].sort.uniq.join("\n")
|
url_string: profile_urls.join("\n")
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -249,9 +264,14 @@ module Sources
|
|||||||
|
|
||||||
def to_h
|
def to_h
|
||||||
return {
|
return {
|
||||||
:artist_name => artist_name,
|
:artist => {
|
||||||
|
:name => artist_name,
|
||||||
|
:tag_name => tag_name,
|
||||||
|
:other_names => other_names,
|
||||||
|
:profile_url => profile_url,
|
||||||
|
:profile_urls => profile_urls,
|
||||||
|
},
|
||||||
:artists => artists.as_json(include: :sorted_urls),
|
:artists => artists.as_json(include: :sorted_urls),
|
||||||
:profile_url => profile_url,
|
|
||||||
:image_url => image_url,
|
:image_url => image_url,
|
||||||
:image_urls => image_urls,
|
:image_urls => image_urls,
|
||||||
:page_url => page_url,
|
:page_url => page_url,
|
||||||
@@ -260,7 +280,6 @@ module Sources
|
|||||||
:tags => tags,
|
:tags => tags,
|
||||||
:normalized_tags => normalized_tags,
|
:normalized_tags => normalized_tags,
|
||||||
:translated_tags => translated_tags,
|
:translated_tags => translated_tags,
|
||||||
:unique_id => unique_id,
|
|
||||||
:artist_commentary => {
|
:artist_commentary => {
|
||||||
:title => artist_commentary_title,
|
:title => artist_commentary_title,
|
||||||
:description => artist_commentary_desc,
|
:description => artist_commentary_desc,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ module Sources
|
|||||||
URL_SLUG = %r!/(?:yande\.re%20|Konachan\.com%20-%20)(?<id>\d+).*!i
|
URL_SLUG = %r!/(?:yande\.re%20|Konachan\.com%20-%20)(?<id>\d+).*!i
|
||||||
IMAGE_URL = %r!#{BASE_URL}/(?<type>image|jpeg|sample)/(?<md5>\h{32})#{URL_SLUG}?\.(?<ext>jpg|jpeg|png|gif)\z!i
|
IMAGE_URL = %r!#{BASE_URL}/(?<type>image|jpeg|sample)/(?<md5>\h{32})#{URL_SLUG}?\.(?<ext>jpg|jpeg|png|gif)\z!i
|
||||||
|
|
||||||
delegate :artist_name, :profile_url, :unique_id, :artist_commentary_title, :artist_commentary_desc, :dtext_artist_commentary_title, :dtext_artist_commentary_desc, to: :sub_strategy, allow_nil: true
|
delegate :artist_name, :profile_url, :tag_name, :artist_commentary_title, :artist_commentary_desc, :dtext_artist_commentary_title, :dtext_artist_commentary_desc, to: :sub_strategy, allow_nil: true
|
||||||
|
|
||||||
def domains
|
def domains
|
||||||
["yande.re", "konachan.com"]
|
["yande.re", "konachan.com"]
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ module Sources
|
|||||||
"#{profile_url}/"
|
"#{profile_url}/"
|
||||||
end
|
end
|
||||||
|
|
||||||
def unique_id
|
def tag_name
|
||||||
"nicoseiga#{api_client.user_id}"
|
"nicoseiga#{api_client.user_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ module Sources
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unique_id
|
def tag_name
|
||||||
"nijie" + artist_id.to_s
|
"nijie" + artist_id.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,6 @@ module Sources
|
|||||||
def normalize_for_artist_finder
|
def normalize_for_artist_finder
|
||||||
url
|
url
|
||||||
end
|
end
|
||||||
|
|
||||||
def unique_id
|
|
||||||
url
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ module Sources
|
|||||||
illust_id.present? || novel_id.present? || fanbox_id.present? || fanbox_account_id.present?
|
illust_id.present? || novel_id.present? || fanbox_id.present? || fanbox_account_id.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def unique_id
|
def tag_name
|
||||||
moniker
|
moniker
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user