Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ac53859
Showing
11 changed files
with
120 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
2008-09-29 - Sean Huber (shuber@huberry.com) | ||
* Initial import |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2008 Sean Huber (shuber@huberry.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'proxy' | ||
$:.unshift File.join(File.dirname(__FILE__), 'lib') |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module Huberry | ||
module ActionController | ||
module Base | ||
def self.included(base) | ||
base.class_eval do | ||
cattr_accessor :relative_url_root | ||
alias_method_chain :redirect_to, :forwarded_host | ||
around_filter :set_relative_url_root | ||
end | ||
end | ||
|
||
def redirect_to_with_forwarded_host(options = {}, response_status = {}) | ||
unless request.env['HTTP_X_FORWARDED_HOST'].blank? | ||
host = request.env['HTTP_X_FORWARDED_HOST'].split(', ').first | ||
if options.is_a? Hash | ||
options[:host] = host | ||
else | ||
request.instance_variable_set('@host_with_port', host + request.port_string) | ||
end | ||
end | ||
redirect_to_without_forwarded_host(options, response_status) | ||
end | ||
|
||
def set_relative_url_root | ||
if self.class.relative_url_root.blank? | ||
yield | ||
else | ||
@original_relative_url_root = ActionController::AbstractRequest.relative_url_root.to_s | ||
ActionController::AbstractRequest.relative_url_root = self.class.relative_url_root | ||
begin | ||
yield | ||
ensure | ||
ActionController::AbstractRequest.relative_url_root = @original_relative_url_root | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Huberry | ||
module ActionController | ||
module Dispatcher | ||
def self.included(base) | ||
base.send :before_dispatch, :set_session_domain | ||
end | ||
|
||
def set_session_domain | ||
host = @request.env['HTTP_X_FORWARDED_HOST'].blank? ? @request.host : @request.env['HTTP_X_FORWARDED_HOST'].split(', ').first | ||
ApplicationController.session_options.merge!(:session_domain => ".#{$1}") if /([^\.]+\.[^\.]+)$/.match(host) | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'huberry/action_controller/dispatcher' | ||
require 'huberry/action_controller/base' | ||
|
||
::ActionController::Dispatcher.send :include, ::Huberry::ActionController::Dispatcher | ||
::ActionController::Base.send :include, ::Huberry::ActionController::Base |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require File.dirname(__FILE__) + '/init' | ||
|
||
class BaseTest < Test::Unit::TestCase | ||
end |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require File.dirname(__FILE__) + '/init' | ||
|
||
class DispatcherTest < Test::Unit::TestCase | ||
end |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
$:.reject! { |path| path.include? 'TextMate' } | ||
require 'test/unit' | ||
|
||
# Load rubygems | ||
# | ||
require 'rubygems' | ||
|
||
# Load ActionPack | ||
# | ||
gem 'actionpack' | ||
require 'action_pack' | ||
require 'action_controller' | ||
require 'action_controller/dispatcher' | ||
require 'action_controller/routing' | ||
require 'action_controller/assertions' | ||
require 'action_controller/test_process' | ||
|
||
# Routing | ||
# | ||
class ActionController::Routing::RouteSet | ||
def append | ||
yield Mapper.new(self) | ||
install_helpers | ||
end | ||
end | ||
|
||
# Require the main proxy.rb file | ||
# | ||
require File.join(File.dirname(File.dirname(__FILE__)), 'lib', 'proxy') |