public
Description: Merb More: The Full Stack. Take what you need; leave what you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-more.git
Allow absolute paths to pass through asset_path() / require_js / 
require_css
fabien (author)
Mon Jun 16 06:00:28 -0700 2008
commit  729832e8eb02180234f671e1a43cd8173373531f
tree    338d352642374872a8a3cd56bc69166f9a05d2c1
parent  17e2c02a2e651902f3a4176e106832646607b728
...
44
45
46
47
 
48
49
50
...
44
45
46
 
47
48
49
50
0
@@ -44,7 +44,7 @@ module Merb
0
         if filename !~ /#{'\\' + ASSET_FILE_EXTENSIONS[asset_type]}\Z/ && filename.index('?').nil?
0
           filename = "#{filename}#{ASSET_FILE_EXTENSIONS[asset_type]}" # don't modify receiver
0
         end
0
- if filename !~ %r{^https?://}
0
+ if filename !~ %r{^(/|https?://)}
0
           filename = "/#{asset_type}s/#{filename}"
0
         end
0
         if local_path
...
82
83
84
85
86
87
 
 
 
88
89
90
91
92
93
94
95
 
 
96
97
98
99
100
101
102
103
104
 
 
 
105
106
107
108
109
110
111
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
114
115
...
82
83
84
 
 
 
85
86
87
88
89
90
91
92
93
 
 
94
95
96
97
98
99
100
101
 
 
 
102
103
104
105
106
107
108
109
110
 
 
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
0
@@ -82,34 +82,50 @@ describe "External JavaScript and Stylesheets" do
0
   it "should require a js file only once" do
0
     require_js 'jquery'
0
     require_js 'jquery', 'effects'
0
-
0
- include_required_js.scan(%r{/javascripts/jquery.js}).should have(1).things
0
- include_required_js.scan(%r{/javascripts/effects.js}).should have(1).things
0
+
0
+ include_required_js.scan(%r{src="/javascripts/jquery.js"}).should have(1).things
0
+ include_required_js.scan(%r{src="/javascripts/effects.js"}).should have(1).things
0
   end
0
 
0
   it "should require a css file only once" do
0
     require_css('style')
0
     require_css('style', 'ie-specific')
0
 
0
- include_required_css.scan(%r{/stylesheets/style.css}).should have(1).things
0
- include_required_css.scan(%r{/stylesheets/ie-specific.css}).should have(1).things
0
+ include_required_css.scan(%r{href="/stylesheets/style.css"}).should have(1).things
0
+ include_required_css.scan(%r{href="/stylesheets/ie-specific.css"}).should have(1).things
0
   end
0
 
0
   it "should require included js" do
0
     require_js 'jquery', 'effects', 'validation'
0
     result = include_required_js
0
     result.scan(/<script/).should have(3).things
0
- result.should match(%r{/javascripts/jquery.js})
0
- result.should match(%r{/javascripts/effects.js})
0
- result.should match(%r{/javascripts/validation.js})
0
+ result.should match(%r{src="/javascripts/jquery.js"})
0
+ result.should match(%r{src="/javascripts/effects.js"})
0
+ result.should match(%r{src="/javascripts/validation.js"})
0
   end
0
 
0
   it "should require included css" do
0
     require_css 'style', 'ie-specific'
0
     result = include_required_css
0
     result.scan(/<link/).should have(2).things
0
- result.should match(%r{/stylesheets/style.css})
0
- result.should match(%r{/stylesheets/ie-specific.css})
0
+ result.should match(%r{href="/stylesheets/style.css"})
0
+ result.should match(%r{href="/stylesheets/ie-specific.css"})
0
+ end
0
+
0
+ it "should require included js from an absolute path" do
0
+ require_js '/other/scripts.js', '/other/utils'
0
+ result = include_required_js
0
+ result.scan(/<script/).should have(2).things
0
+ result.should match(%r{src="/other/scripts.js"})
0
+ result.should match(%r{src="/other/utils.js"})
0
+ end
0
+
0
+ it "should require included css from an absolute path" do
0
+ require_css '/styles/theme.css', '/styles/fonts'
0
+ result = include_required_css
0
+ result.scan(/<link/).should have(2).things
0
+ result.should match(%r{href="/styles/theme.css"})
0
+ result.should match(%r{href="/styles/fonts.css"})
0
   end
0
 
0
   it "should create a js include tag with the extension specified" do

Comments

    No one has commented yet.