Module: UrlUpload

Included in:
ClippingImage, Photo, User
Defined in:
lib/community_engine/url_upload.rb

Instance Method Summary collapse

Instance Method Details

#data_from_url(uri) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/community_engine/url_upload.rb', line 3

def data_from_url(uri)
  io = (open(URI.parse(uri)) rescue return nil)
  (class << io; self; end;).class_eval do
    define_method(:original_filename) { base_uri.path.split('/').last }
  end
  io
end

#validateObject



11
12
13
# File 'lib/community_engine/url_upload.rb', line 11

def validate
  errors.add("filename", "is invalid") if filename? && %w(index.html index.htm).include?(filename.downcase)
end