fixes #2993: Artist URL breakdown
This commit is contained in:
@@ -9,6 +9,10 @@ div#c-artists, div#excerpt {
|
||||
div#a-banned {
|
||||
}
|
||||
|
||||
ul ul {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
div#a-show {
|
||||
p.legend {
|
||||
margin-bottom: 2em;
|
||||
|
||||
@@ -88,6 +88,23 @@ class Artist < ActiveRecord::Base
|
||||
def url_string_changed?
|
||||
url_string.scan(/\S+/) != url_array
|
||||
end
|
||||
|
||||
def map_domain(x)
|
||||
case x
|
||||
when "pximg.net"
|
||||
"pixiv.net"
|
||||
|
||||
when "deviantart.net"
|
||||
"deviantart.com"
|
||||
|
||||
else
|
||||
x
|
||||
end
|
||||
end
|
||||
|
||||
def domains
|
||||
Post.raw_tag_match(name).pluck(:source).map {|x| map_domain(Addressable::URI.parse(x).domain)}.inject(Hash.new(0)) {|h, x| h[x] += 1; h}
|
||||
end
|
||||
end
|
||||
|
||||
module NameMethods
|
||||
@@ -506,6 +523,10 @@ class Artist < ActiveRecord::Base
|
||||
super + [:other_names_index]
|
||||
end
|
||||
|
||||
def method_attributes
|
||||
super + [:domains]
|
||||
end
|
||||
|
||||
def legacy_api_hash
|
||||
return {
|
||||
:id => id,
|
||||
|
||||
@@ -28,13 +28,26 @@
|
||||
<% if @artist.members.any? %>
|
||||
<li><strong>Members</strong> <%= link_to_artists(@artist.members.map(&:name)) %></li>
|
||||
<% end %>
|
||||
<% @artist.urls.each do |url| %>
|
||||
<li>
|
||||
URL: <%= link_to h(url.to_s), h(url.to_s) %>
|
||||
<% 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)) %>)
|
||||
<% if @artist.domains.any? %>
|
||||
<li><strong>Domains</strong></li>
|
||||
<ul>
|
||||
<% @artist.domains.each do |url, count| %>
|
||||
<li><%= url %>: <%= count %></li>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if @artist.urls.any? %>
|
||||
<li><strong>URLs</strong></li>
|
||||
<ul>
|
||||
<% @artist.urls.each do |url| %>
|
||||
<li>
|
||||
<%= link_to h(url.to_s), h(url.to_s) %>
|
||||
<% 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)) %>]
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user