Merge pull request #3716 from r888888888/inactive-artist-urls

Artist urls can be prepended with a '-' to mark as inactive
This commit is contained in:
Albert Yi
2018-05-22 15:17:20 -07:00
committed by GitHub
8 changed files with 55 additions and 9 deletions

View File

@@ -142,7 +142,11 @@
tags.push(["BANNED_ARTIST", "banned"]);
}
$.each(Danbooru.RelatedTag.recent_artists[0].sorted_urls, function(i, url) {
tags.push([" " + url.url, 0]);
var x = url.url;
if (!url.is_active) {
x = "-" + x;
}
tags.push([" " + x, 0]);
});
} else if (Danbooru.RelatedTag.recent_artists.length >= 10) {
tags.push([" none", 0]);
@@ -226,7 +230,15 @@
);
} else {
var text = tag[0];
if (text.match(/^ http/)) {
if (text.match(/^ -http/)) {
text = text.substring(1, 1000);
var desc = text.replace(/^-https?:\/\//, "");
if (desc.length > 30) {
desc = desc.substring(0, 30) + "...";
}
var $del = $("<del/>").text(desc);
$ul.append($("<li/>").html($del));
} else if (text.match(/^ http/)) {
text = text.substring(1, 1000);
var $url = $("<a/>");
var desc = text.replace(/^https?:\/\//, "");

View File

@@ -1,4 +1,5 @@
class ArtistUrl < ApplicationRecord
before_validation :parse_prefix
before_save :initialize_normalized_url, on: [ :create ]
before_save :normalize
validates_presence_of :url
@@ -58,6 +59,13 @@ class ArtistUrl < ApplicationRecord
url = url.gsub(/^http:\/\/i\d+\.pixiv\.net\/img\d+/, "http://*.pixiv.net/img*")
end
def parse_prefix
if url && url[0] == "-"
self.url = url[1..-1]
self.is_active = false
end
end
def priority
if normalized_url =~ /pixiv\.net\/member\.php/
10
@@ -66,7 +74,7 @@ class ArtistUrl < ApplicationRecord
10
elsif normalized_url =~ /twitter\.com/ && normalized_url !~ /status/
10
15
elsif normalized_url =~ /tumblr|patreon|deviantart|artstation/
20
@@ -89,7 +97,11 @@ class ArtistUrl < ApplicationRecord
end
def to_s
url
if is_active?
url
else
"-#{url}"
end
end
def validate_url_format

View File

@@ -16,7 +16,7 @@
</div>
<%= f.input :other_names_comma, :hint => "Separate with commas", :as => :text, :label => "Other names" %>
<%= f.input :group_name %>
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5", :value => params.dig(:artist, :url_string) || @artist.url_array.join("\n")} %>
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5", :value => params.dig(:artist, :url_string) || @artist.urls.join("\n")} %>
<%= dtext_field "artist", "notes" %>
<%= f.button :submit, "Submit" %>

View File

@@ -30,9 +30,9 @@
<ul>
<% artist.urls.each do |url| %>
<li>
<%= link_to h(url.to_s), h(url.to_s) %>
<%= link_to h(url.to_s), h(url) %>
<% if CurrentUser.user.is_moderator? %>
[<%= link_to("mass edit", edit_moderator_tag_path(:antecedent => "-#{artist.name} source:#{ArtistUrl.normalize_for_search(url.to_s)}", :consequent => artist.name)) %>]
[<%= link_to("mass edit", edit_moderator_tag_path(:antecedent => "-#{artist.name} source:#{ArtistUrl.normalize_for_search(url.url)}", :consequent => artist.name)) %>]
<% end %>
</li>
<% end %>