Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module ContentType
- CONTENT_TYPE = {:video=>%w{video/3gpp video/avi video/divx video/mp4 video/mpeg
- video/quicktime video/x-flv video/x-m4v video/x-mpeg video/x-msvideo
- video/x-ms-wmv application/x-flash-video },
- :audio=>%w{audio/m4a audio/mp3 audio/mpeg audio/mpeg3 audio/mpegurl
- audio/mpg audio/wav audio/x-aiff audio/x-m4a audio/x-mp3
- audio/x-mpeg audio/x-ms-wma },
- :image=>%w{image/bmp image/gif image/jpeg image/jpg image/pict
- image/pjpeg image/png image/tiff image/x-bmp
- image/x-photoshop image/x-png },
- :text=>%w{text/html text/plain text/xml },
- :application=>%w{application/download application/force-download
- application/msword application/pdf
- application/save-as application/vnd.ms-powerpoint
- application/vnd.ms-wpl
- application/vnd.openxmlformats-officedocument.wordprocessingml.document
- application/x-download application/x-ms-wmv
- application/x-photoshop application/x-shockwave-flash
- application/x-unknown application/x-zip-compressed
- application/zip },
- :unknown=>%w{application/octect-stream application/octet-stream unknown/unknown }
- }
- def self.included(base)
- base.class_eval do
- alias_method :content_type_selector, :cts
- end
- end
- def self.content_type_selector(type=nil)
- return CONTENT_TYPE[type] if CONTENT_TYPE.has_key?(type)
- return CONTENT_TYPE
- end
- end
Add Comment
Please, Sign In to add comment