2010-04-20 23:05:11 +00:00
|
|
|
class ExternalPost
|
|
|
|
# These mimic the equivalent attributes in Post directly.
|
2012-05-20 17:43:19 -07:00
|
|
|
attr_accessor :md5, :url, :preview_url, :sample_url, :service, :width, :height, :tags, :rating, :id, :similarity
|
2010-04-20 23:05:11 +00:00
|
|
|
|
|
|
|
class << self
|
|
|
|
def get_service_icon(service)
|
2015-01-06 01:50:14 +09:00
|
|
|
case service
|
|
|
|
when CONFIG["local_image_service"]
|
2012-06-04 18:45:53 +07:00
|
|
|
"/favicon.ico"
|
2015-01-06 01:50:14 +09:00
|
|
|
when "gelbooru.com" # hack
|
|
|
|
"/favicon-#{service}.png"
|
2010-04-20 23:05:11 +00:00
|
|
|
else
|
2015-01-06 01:50:14 +09:00
|
|
|
"/favicon-#{service}.ico"
|
2010-04-20 23:05:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def service_icon
|
|
|
|
ExternalPost.get_service_icon(service)
|
|
|
|
end
|
2014-08-23 20:19:29 +09:00
|
|
|
|
2010-04-20 23:05:11 +00:00
|
|
|
def ext
|
|
|
|
true
|
|
|
|
end
|
2014-08-23 20:19:29 +09:00
|
|
|
|
2010-04-20 23:05:11 +00:00
|
|
|
def cached_tags
|
|
|
|
tags
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_xml(options = {})
|
2014-08-23 16:44:43 +09:00
|
|
|
{ :md5 => md5, :url => url, :preview_url => preview_url, :service => service }.to_xml(options.merge(:root => "external-post"))
|
2010-04-20 23:05:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def preview_dimensions
|
2014-11-20 18:12:44 +09:00
|
|
|
dim = Moebooru::Resizer.reduce_to({ :width => width, :height => height }, :width => 150, :height => 150)
|
2014-08-23 16:56:00 +09:00
|
|
|
[dim[:width], dim[:height]]
|
2010-04-20 23:05:11 +00:00
|
|
|
end
|
2010-04-20 23:29:28 +00:00
|
|
|
|
2014-08-23 20:03:11 +09:00
|
|
|
def use_jpeg?(_user)
|
2010-04-20 23:35:44 +00:00
|
|
|
false
|
|
|
|
end
|
2014-08-23 20:19:29 +09:00
|
|
|
|
2010-04-20 23:35:44 +00:00
|
|
|
def has_jpeg?
|
|
|
|
false
|
|
|
|
end
|
2010-11-16 19:56:23 +00:00
|
|
|
|
|
|
|
def is_flagged?
|
|
|
|
false
|
|
|
|
end
|
2014-08-23 20:19:29 +09:00
|
|
|
|
2010-11-16 19:56:23 +00:00
|
|
|
def has_children?
|
|
|
|
false
|
|
|
|
end
|
2014-08-23 20:19:29 +09:00
|
|
|
|
2010-11-16 19:56:23 +00:00
|
|
|
def is_pending?
|
|
|
|
false
|
|
|
|
end
|
2014-08-23 20:19:29 +09:00
|
|
|
|
2010-11-16 19:56:23 +00:00
|
|
|
def parent_id
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
# For external posts, we only link to the page containing the image, not directly
|
|
|
|
# to the image itself, so url and file_url are the same.
|
|
|
|
def file_url
|
|
|
|
url
|
|
|
|
end
|
2010-04-20 23:05:11 +00:00
|
|
|
end
|