public
Description: Koz's rails git-svn clone
Homepage: http://www.rubyonrails.org
Clone URL: git://github.com/NZKoz/koz-rails.git
2-0-stable: Don't repeatedly add relative_url_root to asset sources.  
References #10767 [tomtoday, Koz]

Merging [8740]


git-svn-id: 
http://svn-commit.rubyonrails.org/rails/branches/2-0-stable@8834 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
nzkoz (author)
Sat Feb 09 17:07:24 -0800 2008
commit  0e657ef96c7abf8aa0ac8e90e61c2cddb5ab06aa
tree    3c904e90c680ed42d4ddcbf5f2a8c58ece22ecc5
parent  1211f2e6b508b2c24cfbc609a4da488b89315c05
...
435
436
437
438
 
 
 
439
440
 
441
442
443
...
484
485
486
487
 
488
489
 
490
491
 
 
 
 
 
492
493
494
...
435
436
437
 
438
439
440
441
 
442
443
444
445
...
486
487
488
 
489
490
 
491
492
 
493
494
495
496
497
498
499
500
0
@@ -435,9 +435,11 @@ module ActionView
0
               else
0
                 source = "/#{dir}/#{source}" unless source[0] == ?/
0
                 if has_request
0
- source = "#{@controller.request.relative_url_root}#{source}"
0
+ unless source =~ %r{^#{@controller.request.relative_url_root}/}
0
+ source = "#{@controller.request.relative_url_root}#{source}"
0
+ end
0
                 end
0
- rewrite_asset_path!(source)
0
+ source = rewrite_asset_path(source)
0
 
0
                 if include_host
0
                   host = compute_asset_host(source)
0
@@ -484,11 +486,15 @@ module ActionView
0
           end
0
         end
0
 
0
- # Break out the asset path rewrite so you wish to put the asset id
0
+ # Break out the asset path rewrite in case plugins wish to put the asset id
0
         # someplace other than the query string.
0
- def rewrite_asset_path!(source)
0
+ def rewrite_asset_path(source)
0
           asset_id = rails_asset_id(source)
0
- source << "?#{asset_id}" if !asset_id.blank?
0
+ if asset_id.blank?
0
+ source
0
+ else
0
+ source + "?#{asset_id}"
0
+ end
0
         end
0
 
0
         def javascript_src_tag(source, options)
...
392
393
394
 
 
395
396
397
...
404
405
406
 
 
407
408
409
...
392
393
394
395
396
397
398
399
...
406
407
408
409
410
411
412
413
0
@@ -392,6 +392,8 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase
0
     assert_dom_equal(%(/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr"))
0
     assert_dom_equal(%(/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style"))
0
     assert_dom_equal(%(/collaboration/hieraki/images/xml.png), image_path("xml.png"))
0
+ assert_dom_equal(%(<img alt="Mouse" onmouseover="this.src='/collaboration/hieraki/images/mouse_over.png'" onmouseout="this.src='/collaboration/hieraki/images/mouse.png'" src="/collaboration/hieraki/images/mouse.png" />), image_tag("mouse.png", :mouseover => "/images/mouse_over.png"))
0
+ assert_dom_equal(%(<img alt="Mouse2" onmouseover="this.src='/collaboration/hieraki/images/mouse_over2.png'" onmouseout="this.src='/collaboration/hieraki/images/mouse2.png'" src="/collaboration/hieraki/images/mouse2.png" />), image_tag("mouse2.png", :mouseover => image_path("mouse_over2.png")))
0
   end
0
   
0
   def test_should_ignore_relative_root_path_on_complete_url
0
@@ -404,6 +406,8 @@ class AssetTagHelperNonVhostTest < Test::Unit::TestCase
0
     assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/javascripts/xmlhr.js), javascript_path("xmlhr"))
0
     assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/stylesheets/style.css), stylesheet_path("style"))
0
     assert_dom_equal(%(http://assets.example.com/collaboration/hieraki/images/xml.png), image_path("xml.png"))
0
+ assert_dom_equal(%(<img alt="Mouse" onmouseover="this.src='http://assets.example.com/collaboration/hieraki/images/mouse_over.png'" onmouseout="this.src='http://assets.example.com/collaboration/hieraki/images/mouse.png'" src="http://assets.example.com/collaboration/hieraki/images/mouse.png" />), image_tag("mouse.png", :mouseover => "/images/mouse_over.png"))
0
+ assert_dom_equal(%(<img alt="Mouse2" onmouseover="this.src='http://assets.example.com/collaboration/hieraki/images/mouse_over2.png'" onmouseout="this.src='http://assets.example.com/collaboration/hieraki/images/mouse2.png'" src="http://assets.example.com/collaboration/hieraki/images/mouse2.png" />), image_tag("mouse2.png", :mouseover => image_path("mouse_over2.png")))
0
   ensure
0
     ActionController::Base.asset_host = ""
0
   end

Comments

    No one has commented yet.