Files
danbooru/app/logical/sources/strategies.rb
evazion c8d538f618 moebooru: delegate to substrategy based on post source (#3911).
If the yande.re or konachan.com post has a source from a supported site,
for example Pixiv or Twitter, then delegate the artist and commentary
lookup to that substrategy.

Only do this for sources from recognized sites, not the null strategy.
2018-10-06 14:27:49 -05:00

28 lines
695 B
Ruby

module Sources
module Strategies
def self.all
return [
Strategies::Pixiv,
Strategies::NicoSeiga,
Strategies::Twitter,
Strategies::Stash, # must come before DeviantArt
Strategies::DeviantArt,
Strategies::Tumblr,
Strategies::ArtStation,
Strategies::Nijie,
Strategies::Pawoo,
Strategies::Moebooru,
]
end
def self.find(url, referer=nil, default: Strategies::Null)
strategy = all.detect { |strategy| strategy.match?(url, referer) } || default
strategy&.new(url, referer)
end
def self.canonical(url, referer)
find(url, referer).canonical_url
end
end
end