Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 34 lines (29 sloc) 0.806 kb
ef3ff431 » imathis
2011-06-24 1. Added html5 video with flash fallback.
1 require 'rubygems'
2 require 'bundler/setup'
3 require 'rack'
4
5 # The project root directory
6 $root = ::File.dirname(__FILE__)
7
8 # Common Rack Middleware
9 use Rack::ShowStatus # Nice looking 404s and other messages
10 use Rack::ShowExceptions # Nice looking errors
11
12 #
13 # From Rack::DirectoryIndex:
14 # https://github.com/craigmarksmith/rack-directory-index/
15 #
16 module Rack
17 class DirectoryIndex
18 def initialize(app)
19 @app = app
20 end
21 def call(env)
22 index_path = ::File.join($root, 'public', Rack::Request.new(env).path.split('/'), 'index.html')
23 if ::File.exists?(index_path)
24 return [200, {"Content-Type" => "text/html"}, [::File.read(index_path)]]
25 else
26 @app.call(env)
27 end
28 end
29 end
30 end
31
32 use Rack::DirectoryIndex
33
34 run Rack::Directory.new($root + '/public')
35
Something went wrong with that request. Please try again.