Commit bdfeebda by Prem Sichanugrist

Some style change

parent 5ffcc855
...@@ -11,29 +11,29 @@ module Paperclip ...@@ -11,29 +11,29 @@ module Paperclip
def self.default_options def self.default_options
@default_options ||= { @default_options ||= {
:url => "/system/:attachment/:id/:style/:filename", :convert_options => {},
:path => ":rails_root/public:url", :default_style => :original,
:styles => {}, :default_url => "/:attachment/:style/missing.png",
:hash_data => ":class/:attachment/:id/:style/:updated_at",
:hash_digest => "SHA1",
:interpolator => Paperclip::Interpolations,
:only_process => [], :only_process => [],
:path => ":rails_root/public:url",
:preserve_files => false,
:processors => [:thumbnail], :processors => [:thumbnail],
:convert_options => {},
:source_file_options => {}, :source_file_options => {},
:default_url => "/:attachment/:style/missing.png",
:default_style => :original,
:storage => :filesystem, :storage => :filesystem,
:styles => {},
:url => "/system/:attachment/:id/:style/:filename",
:url_generator => Paperclip::UrlGenerator
:use_default_time_zone => true,
:use_timestamp => true, :use_timestamp => true,
:whiny => Paperclip.options[:whiny] || Paperclip.options[:whiny_thumbnails], :whiny => Paperclip.options[:whiny] || Paperclip.options[:whiny_thumbnails],
:use_default_time_zone => true,
:hash_digest => "SHA1",
:hash_data => ":class/:attachment/:id/:style/:updated_at",
:preserve_files => false,
:interpolator => Paperclip::Interpolations,
:url_generator => Paperclip::UrlGenerator
} }
end end
attr_reader :name, :instance, :default_style, :convert_options, :queued_for_write, :whiny, :options, :interpolator attr_reader :name, :instance, :default_style, :convert_options, :queued_for_write, :whiny,
attr_reader :source_file_options, :whiny :options, :interpolator, :source_file_options, :whiny
attr_accessor :post_processing attr_accessor :post_processing
# Creates an Attachment object. +name+ is the name of the attachment, # Creates an Attachment object. +name+ is the name of the attachment,
......
...@@ -5,7 +5,6 @@ module Paperclip ...@@ -5,7 +5,6 @@ module Paperclip
# to the +File+ class. Useful for testing. # to the +File+ class. Useful for testing.
# user.avatar = File.new("test/test_avatar.jpg") # user.avatar = File.new("test/test_avatar.jpg")
module Upfile module Upfile
# Infer the MIME-type of the file from the extension. # Infer the MIME-type of the file from the extension.
def content_type def content_type
types = MIME::Types.type_for(self.original_filename) types = MIME::Types.type_for(self.original_filename)
...@@ -23,7 +22,7 @@ module Paperclip ...@@ -23,7 +22,7 @@ module Paperclip
end end
def type_from_file_command def type_from_file_command
# On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist. # On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
type = (self.original_filename.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase type = (self.original_filename.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase
mime_type = (Paperclip.run("file", "-b --mime :file", :file => self.path).split(/[:;]\s+/)[0] rescue "application/x-#{type}") mime_type = (Paperclip.run("file", "-b --mime :file", :file => self.path).split(/[:;]\s+/)[0] rescue "application/x-#{type}")
mime_type = "application/x-#{type}" if mime_type.match(/\(.*?\)/) mime_type = "application/x-#{type}" if mime_type.match(/\(.*?\)/)
...@@ -45,12 +44,15 @@ end ...@@ -45,12 +44,15 @@ end
if defined? StringIO if defined? StringIO
class StringIO class StringIO
attr_accessor :original_filename, :content_type, :fingerprint attr_accessor :original_filename, :content_type, :fingerprint
def original_filename def original_filename
@original_filename ||= "stringio.txt" @original_filename ||= "stringio.txt"
end end
def content_type def content_type
@content_type ||= "text/plain" @content_type ||= "text/plain"
end end
def fingerprint def fingerprint
@fingerprint ||= Digest::MD5.hexdigest(self.string) @fingerprint ||= Digest::MD5.hexdigest(self.string)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment