Minor fixes

1) WEBrick should respond to TERM signals
(needed by MacOSX and, perhaps, others).
2) HTTP redirects for redirected pages should be 301's.
3) Add a flash message for redirection to "new" page
when the target of "show" action is not found.
master
Jacques Distler 2009-06-14 22:55:41 -05:00
parent d50d6fac17
commit 7448b7981b
2 changed files with 5 additions and 2 deletions

View File

@ -235,7 +235,7 @@ class WikiController < ApplicationController
real_page = WikiReference.page_that_redirects_for(@web, @page_name)
if real_page
flash[:info] = "Redirected from \"#{@page_name}\"."
redirect_to :web => @web_name, :action => 'published', :id => real_page
redirect_to :web => @web_name, :action => 'published', :id => real_page, :status => 301
else
render(:text => "Page '#{@page_name}' not found", :status => 404, :layout => 'error')
end
@ -324,8 +324,10 @@ class WikiController < ApplicationController
real_page = WikiReference.page_that_redirects_for(@web, @page_name)
if real_page
flash[:info] = "Redirected from \"#{@page_name}\"."
redirect_to :web => @web_name, :action => 'show', :id => real_page
redirect_to :web => @web_name, :action => 'show', :id => real_page, :status => 301
else
flash[:info] = "Page \"#{@page_name}\" does not exist.\n" +
"Please create it now, or hit the \"back\" button in your browser."
redirect_to :web => @web_name, :action => 'new', :id => @page_name
end
else

View File

@ -9,6 +9,7 @@ module Rack
server = ::WEBrick::HTTPServer.new(options)
server.mount "/", Rack::Handler::WEBrick, app
trap(:INT) { server.shutdown }
trap(:TERM) { server.shutdown }
yield server if block_given?
server.start
end