From 301f2c9dcd883a80516e4660551a002e31d8a72c Mon Sep 17 00:00:00 2001 From: Hampton Catlin Date: Tue, 15 Oct 2013 08:57:06 -0400 Subject: [PATCH 1/2] Redirect to SassMeister.com. Fixes sass/sass.github.com#25. --- config.ru | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.ru b/config.ru index fba4abcee..db125e03f 100644 --- a/config.ru +++ b/config.ru @@ -13,6 +13,8 @@ else r301 '/documentation', '/documentation/' r301 '/documentation/_index.html', '/documentation/' + moved_permanently '/try.html', 'http://www.sassmeister.com' + rewrite(%r{^(.*)/([^/.]+)$}, lambda do |match, rack_env| path = "#{File.dirname(__FILE__)}/build#{match[0]}" next "#{match[1]}/#{match[2]}/index.html" if Dir.exists?(path) From bd3f172aac9e5e41e41e35a712b0ca79df2f44fa Mon Sep 17 00:00:00 2001 From: Hampton Catlin Date: Tue, 15 Oct 2013 09:03:48 -0400 Subject: [PATCH 2/2] Rework the config.ru so that it will do redirects, even when testing locally. Only difference between heroku and here, should be the run command! we still want the other parts --- config.ru | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/config.ru b/config.ru index db125e03f..aa5c2c85c 100644 --- a/config.ru +++ b/config.ru @@ -1,28 +1,28 @@ require "rubygems" -if ENV["HEROKU"].nil? || ENV["HEROKU"] == 'false' - require "middleman" - run Middleman.server -else - require "rack/rewrite" +require "rack/rewrite" - use Rack::Rewrite do - r301 %r{/docs/yardoc/(.*)}, '/documentation/$1' - r301 '/tutorial.html', '/guide' - r301 '/download.html', '/install' - r301 '/documentation', '/documentation/' - r301 '/documentation/_index.html', '/documentation/' +use Rack::Rewrite do + r301 %r{/docs/yardoc/(.*)}, '/documentation/$1' + r301 '/tutorial.html', '/guide' + r301 '/download.html', '/install' + r301 '/documentation', '/documentation/' + r301 '/documentation/_index.html', '/documentation/' - moved_permanently '/try.html', 'http://www.sassmeister.com' + moved_permanently '/try.html', 'http://www.sassmeister.com' - rewrite(%r{^(.*)/([^/.]+)$}, lambda do |match, rack_env| - path = "#{File.dirname(__FILE__)}/build#{match[0]}" - next "#{match[1]}/#{match[2]}/index.html" if Dir.exists?(path) - next match[0] if File.exists?(path) - "#{match[0]}.html" - end) - end + rewrite(%r{^(.*)/([^/.]+)$}, lambda do |match, rack_env| + path = "#{File.dirname(__FILE__)}/build#{match[0]}" + next "#{match[1]}/#{match[2]}/index.html" if Dir.exists?(path) + next match[0] if File.exists?(path) + "#{match[0]}.html" + end) +end +if ENV["HEROKU"].nil? || ENV["HEROKU"] == 'false' + require "middleman" + run Middleman.server +else use Rack::Static, :urls => [""], :root => 'build', :index => 'index.html' run lambda {}