Permalink
Browse files

absolutize redirect urls

  • Loading branch information...
1 parent b7aa5fd commit cca68b5ea04419119a68a59babf3dbb61be462d2 @ethn ethn committed Dec 18, 2012
@@ -71,6 +71,7 @@ def read_ok
# ----------( rendering methods ) -------------
def wagn_redirect url
+ url = wagn_url url #make sure we have absolute url
if ajax?
render :text => url, :status => 303
else
@@ -228,7 +228,7 @@ def success default_target='_self'
end
case
- when redirect ; wagn_redirect ( Card===target ? url_for_page(target.cardname, new_params) : target )
+ when redirect ; wagn_redirect ( Card===target ? path_for_page( target.cardname, new_params ) : target )
when String===target ; render :text => target
else
@card = target
@@ -23,8 +23,8 @@ def location_history
def save_location
return if ajax? || !html? || !@card.known?
- discard_locations_for(@card)
- @previous_location = wagn_path(@card)
+ discard_locations_for @card
+ @previous_location = wagn_path @card
location_history.push @previous_location
end
@@ -50,7 +50,7 @@ def url_key_for_location(location)
# FIXME: missing test
- def url_for_page( title, opts={} )
+ def path_for_page( title, opts={} )
format = (opts[:format] ? ".#{opts.delete(:format)}" : "")
vars = ''
if !opts.empty?
@@ -61,13 +61,13 @@ def url_for_page( title, opts={} )
wagn_path "/#{title.to_name.url_key}#{format}#{vars}"
end
- def wagn_path( rel ) #should be in cardname?
+ def wagn_path( rel ) #should be in smartname?
rel_path = Card===rel ? rel.cardname.url_key : rel
Wagn::Conf[:root_path].to_s + ( rel_path =~ /^\// ? '' : '/' ) + rel_path
end
- def wagn_url( rel ) #should be in cardname?
- "#{Wagn::Conf[:base_url]}#{wagn_path(rel)}"
+ def wagn_url rel #should be in smartname?
+ rel =~ /^http\:/ ? rel : "#{Wagn::Conf[:base_url]}#{wagn_path(rel)}"
end
@@ -76,7 +76,7 @@ def wagn_url( rel ) #should be in cardname?
def link_to_page( text, title=nil, options={})
title ||= text
url_options = (options[:type]) ? {:type=>options[:type]} : {}
- url = url_for_page(title, url_options)
+ url = path_for_page(title, url_options)
link_to text, url, options
end
@@ -24,7 +24,7 @@ module Set::Self::HeadAndFoot
if root.card.type_id == Card::SearchTypeID
opts = { :format => :rss }
root.search_params[:vars].each { |key, val| opts["_#{key}"] = val }
- rss_href = url_for_page root.card.name, opts
+ rss_href = path_for_page root.card.name, opts
bits << %{<link rel="alternate" type="application/rss+xml" title="RSS" href=#{rss_href} />}
end
end
@@ -26,7 +26,7 @@ def test_should_redirect_to_account_request_landing_card
:content=>"Let me in!"
}
assert_response 302
- #assert_redirected_to @controller.url_for_page(::Setting.find_by_codename('account_request_landing').card.name)
+ #assert_redirected_to @controller.path_for_page(::Setting.find_by_codename('account_request_landing').card.name)
end
def test_should_create_account_request
@@ -97,11 +97,11 @@ def test_removal_and_return_to_previous_undeleted_card_after_deletion
t2 = Card.create! :name => "Testable1+bandana", :content => "world"
end
- get url_for_page( t1.name )
- get url_for_page( t2.name )
+ get path_for_page( t1.name )
+ get path_for_page( t2.name )
post 'card/delete/~' + t2.id.to_s
- assert_redirected_to url_for_page( t1.name )
+ assert_redirected_to path_for_page( t1.name )
assert_nil Card[ t2.name ]
post 'card/delete/~' + t1.id.to_s

0 comments on commit cca68b5

Please sign in to comment.