artist_url.rb: remove legacy artist url normalization code.

* `legacy_normalize` came from c6012535, which is no longer a problem.

* `normalize_for_search` is only used for "[mass edit]" links
in artist entries. These links are a shortcut for performing a
`-artist_name source:<artist_url> -> artist_name` mass edit to tag
untagged artists, but this won't work for most sites these days.
This commit is contained in:
evazion
2018-09-07 12:32:02 -05:00
parent 8e7dd9e97f
commit 99a5e885e0
3 changed files with 0 additions and 36 deletions

View File

@@ -45,35 +45,6 @@ class ArtistUrl < ApplicationRecord
end
end
def self.legacy_normalize(url)
if url.nil?
nil
else
url = url.gsub(%r!^https://!, "http://")
url = url.gsub(%r!^http://blog\d+\.fc2!, "http://blog.fc2")
url = url.gsub(%r!^http://blog-imgs-\d+\.fc2!, "http://blog.fc2")
url = url.gsub(%r!^http://blog-imgs-\d+-\w+\.fc2!, "http://blog.fc2")
url = url.gsub(%r!^http://img\d+\.pixiv\.net!, "http://img.pixiv.net")
url = url.gsub(%r!^http://i\d+\.pixiv\.net/img\d+!, "http://img.pixiv.net")
url = url.gsub(%r!/+\Z!, "")
url + "/"
end
end
def self.normalize_for_search(url)
if url =~ /\.\w+\Z/ && url =~ /\w\/\w/
url = File.dirname(url)
end
url = url.gsub(%r!^https://!, "http://")
url = url.gsub(%r!^http://blog\d+\.fc2!, "http://blog*.fc2")
url = url.gsub(%r!^http://blog-imgs-\d+\.fc2!, "http://blog*.fc2")
url = url.gsub(%r!^http://blog-imgs-\d+-\w+\.fc2!, "http://blog*.fc2")
url = url.gsub(%r!^http://img\d+\.pixiv\.net!, "http://img*.pixiv.net")
url = url.gsub(%r!^http://i\d+\.pixiv\.net/img\d+!, "http://*.pixiv.net/img*")
url
end
def parse_prefix
case url
when /^-/

View File

@@ -60,10 +60,6 @@ class ArtistVersion < ApplicationRecord
new_urls = url_array
old_urls = version.present? ? version.url_array : []
latest_urls = latest_urls.map {|url| ArtistUrl.legacy_normalize(url)}
new_urls = new_urls.map {|url| ArtistUrl.legacy_normalize(url)}
old_urls = old_urls.map {|url| ArtistUrl.legacy_normalize(url)}
added_urls = new_urls - old_urls
removed_urls = old_urls - new_urls

View File

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