Sha256: 3ce31de3954dadf5d59d7fb263a8322dc359f167b72510ff986427e5ec5a4600

Contents?: true

Size: 751 Bytes

Versions: 1

Compression:

Stored size: 751 Bytes

Contents

module Middleman
  module Rack
    class Static
      def initialize(app, options={})
        @app = app
        root = Middleman::Base.public
        @file_server = ::Rack::File.new(root)
      end

      def templatize_js?(path)
        path.match(/\.js$/) && Middleman::Base.respond_to?(:minify_javascript?) && Middleman::Base.minify_javascript?
      end

      def call(env)
        path = env["PATH_INFO"]
        file_path = File.join(Middleman::Base.public, path)
        
        if templatize_js?(path)
          @app.call(env)
        elsif path.include?("favicon.ico") || (File.exists?(file_path) && !File.directory?(file_path))
          @file_server.call(env)
        else
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
middleman-0.12.0.pre lib/middleman/rack/static.rb