From 0455b8b615471c721cc65af0a4f5944af8192ed8 Mon Sep 17 00:00:00 2001 From: Chris Cherry Date: Fri, 17 Oct 2008 11:22:41 -0700 Subject: [PATCH 1/5] Rails now uses ActionController::Base.relative_url_root to set relative_url_root. --- lib/rack/adapter/rails.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rack/adapter/rails.rb b/lib/rack/adapter/rails.rb index 629bef90..9a2f82df 100644 --- a/lib/rack/adapter/rails.rb +++ b/lib/rack/adapter/rails.rb @@ -31,7 +31,7 @@ def load_application require "#{@root}/config/environment" require 'dispatcher' - ActionController::AbstractRequest.relative_url_root = @prefix if @prefix + ActionController::Base.relative_url_root = @prefix if @prefix end # TODO refactor this in File#can_serve?(path) ?? From b6b0d844c8b82904810ac6cccd1948133d3143f0 Mon Sep 17 00:00:00 2001 From: Chris Cherry Date: Fri, 17 Oct 2008 11:35:42 -0700 Subject: [PATCH 2/5] Support new Rails 2.1.1 method of setting relative_url_root as well as older Rails via a respond_to? check --- lib/rack/adapter/rails.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rack/adapter/rails.rb b/lib/rack/adapter/rails.rb index 9a2f82df..a89e6b04 100644 --- a/lib/rack/adapter/rails.rb +++ b/lib/rack/adapter/rails.rb @@ -31,7 +31,13 @@ def load_application require "#{@root}/config/environment" require 'dispatcher' - ActionController::Base.relative_url_root = @prefix if @prefix + if @prefix + if ActionController::Base.respond_to?('relative_url_root=') + ActionController::Base.relative_url_root = @prefix # Rails 2.1.1 + else + ActionController::AbstractRequest.relative_url_root = @prefix + end + end end # TODO refactor this in File#can_serve?(path) ?? From 3cddf37bdfd515c976bbeca5a47a3251c878570a Mon Sep 17 00:00:00 2001 From: macournoyer Date: Tue, 21 Oct 2008 23:10:50 -0400 Subject: [PATCH 3/5] Add more sites to users page --- site/thin.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/site/thin.rb b/site/thin.rb index 652f0091..10c85ffb 100644 --- a/site/thin.rb +++ b/site/thin.rb @@ -188,8 +188,9 @@ def users_page ul do li { a 'RefactorMyCode.com', :href => 'http://refactormycode.com/' } - li { a "Joao Pedrosa's Blog", :href => 'http://www.deze9.com/jp/blog/post?p=enabling-thin-support-for-this-site-replacing' } + li { a "Standout Jobs", :href => 'http://standoutjobs.com/'} li { a "Kevin Williams Blog", :href => 'http://www.almostserio.us/articles/tag/thin' } + li { a "Gitorious", :href => 'http://gitorious.org/' } li { a "Dinooz", :href => 'http://www.nicomoayudarte.com/' } li { a "Mobile Dyne Systems", :href => 'http://www.mobiledyne.com/' } li { a "feelfree.homelinux.com", :href => 'http://feelfree.homelinux.com' } @@ -197,10 +198,10 @@ def users_page li { a "James on Software", :href => 'http://jamesgolick.com/' } li { a "FlashDen", :href => 'http://flashden.net/' } li { a "Calico Web Development", :href => 'http://www.calicowebdev.com/' } - li { a "Gitorious", :href => 'http://gitorious.org/' } li { a "Cornerstone Web", :href => 'http://www.cornerstoneweb.org/' } li { a "Osmos", :href => 'http://www.getosmos.com/' } li { a "Lipomics", :href => 'http://www.lipomics.com/' } + li { a "Joao Pedrosa's Blog", :href => 'http://www.deze9.com/jp/blog/post?p=enabling-thin-support-for-this-site-replacing' } li { a "RaPlanet", :href => 'http://planet.zhekov.net/' } li { a "Ninja Hideout blog", :href => 'http://blog.ninjahideout.com/' } li { a "Hoodows Blog", :href => 'http://blog.hoodow.de/articles/2008/02/09/thin' } @@ -226,6 +227,13 @@ def users_page li { a "Hacknight", :href => 'http://hacknight.gangplankhq.com/'} li { a "Sizzix", :href => 'http://www.sizzix.com/'} li { a "Ellison Retailers", :href => 'http://www.ellisonretailers.com/'} + li { a "ShareMeme", :href => 'http://sharememe.com/'} + li { a "ylastic", :href => 'http://ylastic.com/'} + li { a "hello2morrow", :href => 'http://www.hello2morrow.com/'} + li { a "TimmyOnTime", :href => 'http://www.timmyontime.com/'} + li { a "Generous", :href => 'http://generous.org.uk/'} + li { a "Catapult Magazine", :href => 'http://www.catapultmagazine.com/'} + li { a "Good-Tutorials", :href => 'http://www.good-tutorials.com/'} end p { "If you'd like to have your site listed here, #{a 'drop me an email', :href => 'mailto:macournoyer@gmail.com'}" } From 4d224bd3fe0824387da3cbb5390a02a8bd775c28 Mon Sep 17 00:00:00 2001 From: macournoyer Date: Tue, 21 Oct 2008 23:20:10 -0400 Subject: [PATCH 4/5] Add CHANGELOG entry for last merge [#85 state:resolved] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index c020c33a..43b0dbb7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ == 1.0.1 ? release + * Fixes a warning RE relative_url_root when using a prefix with Rails 2.1.1 [seriph] [#85 state:resolved] * --only can work as a sequence number (if < 80) or a port number (if >= 80) [jmay] [#81 state:resolved] == 1.0.0 That's What She Said release From 1e90d63f9139f6bc5dc7624ef07076bedcbb0bb3 Mon Sep 17 00:00:00 2001 From: macournoyer Date: Tue, 21 Oct 2008 23:26:44 -0400 Subject: [PATCH 5/5] Set RACK_ENV based on environment option when loading rackup file [Curtis Summers] [#83 state:resolved] --- CHANGELOG | 1 + lib/thin/controllers/controller.rb | 1 + spec/controllers/controller_spec.rb | 14 +++++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 43b0dbb7..f01422e1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ == 1.0.1 ? release + * Set RACK_ENV based on environment option when loading rackup file [Curtis Summers] [#83 state:resolved] * Fixes a warning RE relative_url_root when using a prefix with Rails 2.1.1 [seriph] [#85 state:resolved] * --only can work as a sequence number (if < 80) or a port number (if >= 80) [jmay] [#81 state:resolved] diff --git a/lib/thin/controllers/controller.rb b/lib/thin/controllers/controller.rb index 6b020fce..6cece408 100644 --- a/lib/thin/controllers/controller.rb +++ b/lib/thin/controllers/controller.rb @@ -166,6 +166,7 @@ def load_adapter end def load_rackup_config + ENV['RACK_ENV'] = @options[:environment] case @options[:rackup] when /\.rb$/ Kernel.load(@options[:rackup]) diff --git a/spec/controllers/controller_spec.rb b/spec/controllers/controller_spec.rb index 3d757102..d98a011d 100644 --- a/spec/controllers/controller_spec.rb +++ b/spec/controllers/controller_spec.rb @@ -63,14 +63,14 @@ end it "should load app from Rack config" do - @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru' + @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru' @controller.start @server.app.class.should == Proc end it "should load app from ruby file" do - @controller.options[:rackup] = filename = File.dirname(__FILE__) + '/../../example/myapp.rb' + @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/myapp.rb' @controller.start @server.app.should == Myapp @@ -78,7 +78,7 @@ it "should throwup if rackup is not a .ru or .rb file" do proc do - @controller.options[:rackup] = filename = File.dirname(__FILE__) + '/../../example/myapp.foo' + @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/myapp.foo' @controller.start end.should raise_error(RuntimeError, /please/) end @@ -89,6 +89,14 @@ @server.threaded.should be_true end + + it "should set RACK_ENV" do + @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru' + @controller.options[:environment] = "lolcat" + @controller.start + + ENV['RACK_ENV'].should == "lolcat" + end end