Files
danbooru/app/logical/sources/site.rb
Toks 899fd8f71f Don't instantly make a request to get info when using bookmarklet
Currently this is done twice: once when the page first loads (although
this one isn't used) and then a second time asynchronously with
javascript (which is used). This commit removes the first one, improving
upload page load time.
2014-04-30 14:28:07 -04:00

38 lines
913 B
Ruby

module Sources
class Site
attr_reader :url, :strategy
delegate :get, :referer_url, :site_name, :artist_name, :profile_url, :image_url, :tags, :artist_record, :unique_id, :to => :strategy
def self.strategies
[Strategies::Pixiv, Strategies::NicoSeiga, Strategies::DeviantArt]
end
def initialize(url)
@url = url
Site.strategies.each do |strategy|
if strategy.url_match?(url)
@strategy = strategy.new(url)
break
end
end
end
def to_json
return {
:artist_name => artist_name,
:profile_url => profile_url,
:image_url => image_url,
:tags => tags,
:danbooru_name => artist_record.try(:first).try(:name),
:danbooru_id => artist_record.try(:first).try(:id),
:unique_id => unique_id
}.to_json
end
def available?
strategy.present?
end
end
end