public
Fork of halorgium/mephisto
Description: A refactored Mephisto that has multiple spam detection engines.
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/francois/mephisto.git
mephisto / app / models / resources.rb
100644 30 lines (27 sloc) 0.836 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class Resources < Attachments
  @@non_image_extnames = %w(.js .css)
  cattr_reader :non_image_extnames
  def image?(path)
    !non_image_extnames.include?(path.extname)
  end
  
  def content_type(path)
    case path.extname
      when '.js' then 'text/javascript'
      when '.css' then 'text/css'
      when '.png' then 'image/png'
      when '.jpg', '.jpeg' then 'image/jpeg'
      when '.gif' then 'image/gif'
      when '.swf' then 'application/x-shockwave-flash'
      when '.ico' then 'image/x-icon'
    end
  end
  
  def [](filename)
    path =
      case filename
        when /\.js$/i then 'javascripts'
        when /\.css$/i then 'stylesheets'
        else 'images'
      end
      
    theme.path + "#{path}/#{File.basename(filename.to_s)}"
  end
end