Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/misc-chapter1'
- Loading branch information
Showing
37 changed files
with
1,473 additions
and
1,601 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
source :rubygems | ||
|
||
gem 'nanoc', '~> 3.1.7' | ||
gem 'nanoc', '3.1.7' | ||
|
||
gem 'haml', '~> 3.1.1' | ||
gem 'sass', '~> 3.1.1' | ||
gem 'redcarpet', '~> 1.15.2' | ||
gem 'coderay', '~> 0.9.8' | ||
gem 'haml', '3.1.2' | ||
gem 'sass', '3.1.3' | ||
gem 'redcarpet', '1.17.2' | ||
gem 'coderay', '0.9.8' | ||
|
||
gem 'heroku', '~> 2.1.4' | ||
gem 'heroku', '2.3.3' | ||
|
||
gem 'rspec', '~> 2.6.0' | ||
gem 'capybara', '~> 0.4.1.2' | ||
gem 'delorean', '~> 1.0.0' | ||
gem 'rbtrace', '~> 0.3.13' | ||
gem 'ruby-debug19', '~> 0.11.6', :require => 'ruby-debug' | ||
gem 'rspec', '2.6.0' | ||
gem 'capybara', '1.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,42 @@ | ||
require './web/app' | ||
require 'rack' | ||
require 'rack/contrib' | ||
require 'rack-rewrite' | ||
require 'mime/types' | ||
|
||
Encoding.default_internal = 'utf-8' | ||
Encoding.default_external = 'utf-8' | ||
use Rack::ETag | ||
|
||
run Sinatra::Application | ||
module ::Rack | ||
class TryStatic < Static | ||
|
||
def initialize(app, options) | ||
super | ||
@try = ([''] + Array(options.delete(:try)) + ['']) | ||
end | ||
|
||
def call(env) | ||
@next = 0 | ||
while @next < @try.size && 404 == (resp = super(try_next(env)))[0] | ||
@next += 1 | ||
end | ||
404 == resp[0] ? @app.call : resp | ||
end | ||
|
||
private | ||
def try_next(env) | ||
env.merge('PATH_INFO' => env['PATH_INFO'] + @try[@next]) | ||
end | ||
|
||
end | ||
end | ||
|
||
use Rack::TryStatic, | ||
:root => "output", # static files root dir | ||
:urls => %w[/], # match all requests | ||
:try => ['.html', 'index.html', '/index.html'] # try these postfixes sequentially | ||
|
||
errorFile='output/index.html' | ||
run lambda { [404, { | ||
"Last-Modified" => File.mtime(errorFile).httpdate, | ||
"Content-Type" => "text/html", | ||
"Content-Length" => File.size(errorFile).to_s | ||
}, File.read(errorFile)] }┌ |
Oops, something went wrong.