Sha256: 66389c616cc98de9f676b9c71236d1a777fd12529ac8c00025553eb6f6ccbc7f

Contents?: true

Size: 848 Bytes

Versions: 2

Compression:

Stored size: 848 Bytes

Contents

require 'sprockets'
project_root = File.expand_path(File.dirname(__FILE__))
assets = Sprockets::Environment.new(project_root) do |env|
  env.logger = Logger.new(STDOUT)
end

assets.append_path(File.join(project_root, 'src/javascripts'))
assets.append_path(File.join(project_root, 'src/stylesheets'))

map '/lib/images' do
   run Rack::Directory.new('src/images')
end

map "/lib" do
  run assets
end

map "/" do
  @root = File.expand_path(File.join(File.dirname(__FILE__), "public"))

  run Proc.new { |env|
    # Extract the requested path from the request
    req = Rack::Request.new(env)
    index_file = File.join(@root, req.path_info, "index.html")

    if File.exists?(index_file)
      # Rewrite to index
      req.path_info += "index.html"
    end
    # Pass the request to the directory app
    Rack::Directory.new(@root).call(env)
  }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
backrack-0.0.2 lib/backrack/templates/config.ru
backrack-0.0.1 lib/backrack/templates/config.ru