Refactor sources

This commit is contained in:
Albert Yi
2018-08-06 17:39:25 -07:00
parent 54363ffecf
commit 762dc3da24
71 changed files with 2340 additions and 2430 deletions

View File

@@ -1682,7 +1682,11 @@ class Post < ApplicationRecord
module PixivMethods
def parse_pixiv_id
self.pixiv_id = Sources::Strategies::Pixiv.new(source).illust_id_from_url
self.pixiv_id = nil
if Sources::Strategies::Pixiv.match?(source)
self.pixiv_id = Sources::Strategies::Pixiv.new(source).illust_id
end
end
end
@@ -1790,10 +1794,8 @@ class Post < ApplicationRecord
return if has_tag?("artist_request") || has_tag?("official_art")
return if tags.any? { |t| t.category == Tag.categories.artist }
site = Sources::Site.new(source)
site = Sources::Strategies.find(source)
self.warnings[:base] << "Artist tag is required. Create a new tag with [[artist:<artist_name>]]. Ask on the forum if you need naming help"
rescue Sources::Site::NoStrategyError => e
# unrecognized source; do nothing.
end
def has_copyright_tag