Guest User

Untitled

a guest
May 25th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. module ContentType
  2.  
  3. CONTENT_TYPE = {:video=>%w{video/3gpp video/avi video/divx video/mp4 video/mpeg
  4. video/quicktime video/x-flv video/x-m4v video/x-mpeg video/x-msvideo
  5. video/x-ms-wmv application/x-flash-video },
  6.  
  7. :audio=>%w{audio/m4a audio/mp3 audio/mpeg audio/mpeg3 audio/mpegurl
  8. audio/mpg audio/wav audio/x-aiff audio/x-m4a audio/x-mp3
  9. audio/x-mpeg audio/x-ms-wma },
  10.  
  11. :image=>%w{image/bmp image/gif image/jpeg image/jpg image/pict
  12. image/pjpeg image/png image/tiff image/x-bmp
  13. image/x-photoshop image/x-png },
  14.  
  15. :text=>%w{text/html text/plain text/xml },
  16.  
  17. :application=>%w{application/download application/force-download
  18. application/msword application/pdf
  19. application/save-as application/vnd.ms-powerpoint
  20. application/vnd.ms-wpl
  21. application/vnd.openxmlformats-officedocument.wordprocessingml.document
  22. application/x-download application/x-ms-wmv
  23. application/x-photoshop application/x-shockwave-flash
  24. application/x-unknown application/x-zip-compressed
  25. application/zip },
  26.  
  27. :unknown=>%w{application/octect-stream application/octet-stream unknown/unknown }
  28. }
  29.  
  30. def self.included(base)
  31. base.class_eval do
  32. alias_method :content_type_selector, :cts
  33. end
  34. end
  35.  
  36. def self.content_type_selector(type=nil)
  37. return CONTENT_TYPE[type] if CONTENT_TYPE.has_key?(type)
  38. return CONTENT_TYPE
  39. end
  40. end
Add Comment
Please, Sign In to add comment