Changeset 1090
- Timestamp:
- 12/13/07 16:00:24 (1 year ago)
- Files:
-
- trunk/CHANGELOG (modified) (1 diff)
- trunk/lib/merb/mixins/general_controller.rb (modified) (1 diff)
- trunk/lib/merb/mixins/view_context.rb (modified) (3 diffs)
- trunk/spec/merb/view_context_spec.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/CHANGELOG
r1081 r1090 5 5 * merb_helpers: form field labels are now explicit, huge documentation update, added select, fieldset, more helpers 6 6 * Fixed merb.show_routes within merb -i 7 * Fixed image_tag, css_include_tag, and js_include_tag to work with path_prefix 7 8 8 9 == 0.4.1 "Faster Partials or Partially Faster?" 2007-11-12 trunk/lib/merb/mixins/general_controller.rb
r1079 r1090 86 86 raise "URL not generated: #{route_name.inspect}, #{new_params.inspect}" 87 87 end 88 url = Merb Handler.path_prefix + url if MerbHandler.path_prefix88 url = Merb::Server.config[:path_prefix] + url if Merb::Server.config[:path_prefix] 89 89 url 90 90 end trunk/lib/merb/mixins/view_context.rb
r1063 r1090 49 49 # # => <img src="http://test.com/foo.gif"> 50 50 def image_tag(img, opts={}) 51 opts[:path] ||= (img =~ %r{^https?://}) ? '' : '/images/' 51 opts[:path] ||= 52 if img =~ %r{^https?://} 53 '' 54 else 55 if Merb::Server.config[:path_prefix] 56 Merb::Server.config[:path_prefix] + '/images/' 57 else 58 '/images/' 59 end 60 end 52 61 opts[:src] ||= opts.delete(:path) + img 53 62 %{<img #{ opts.to_xml_attributes } />} … … 259 268 scripts.each do |script| 260 269 script = script.to_s 261 include_tag << %Q|<script src="/javascripts/#{script=~/\.js$/ ? script : script+'.js' }" type="text/javascript">//</script>\n| 270 url = "/javascripts/#{script =~ /\.js$/ ? script : script + '.js'}" 271 url = Merb::Server.config[:path_prefix] + url if Merb::Server.config[:path_prefix] 272 include_tag << %Q|<script src="#{url}" type="text/javascript">//</script>\n| 262 273 end 263 274 include_tag … … 288 299 scripts.each do |script| 289 300 script = script.to_s 290 include_tag << %Q|<link href="/stylesheets/#{script=~/\.css$/ ? script : script+'.css' }" media="all" rel="Stylesheet" type="text/css"/>\n| 301 url = "/stylesheets/#{script =~ /\.css$/ ? script : script + '.css'}" 302 url = Merb::Server.config[:path_prefix] + url if Merb::Server.config[:path_prefix] 303 include_tag << %Q|<link href="#{url}" media="all" rel="Stylesheet" type="text/css"/>\n| 291 304 end 292 305 include_tag trunk/spec/merb/view_context_spec.rb
r1063 r1090 14 14 it "should render local image" do 15 15 image_tag('foo.gif').clean.should == %[<img src="/images/foo.gif"/>].clean 16 end 17 18 it "should render a local image with a path_prefix" do 19 Merb::Server.config[:path_prefix] = '/inky' 20 image_tag('foo.gif').clean.should == %[<img src="/inky/images/foo.gif"/>].clean 21 Merb::Server.config.delete(:path_prefix) 16 22 end 17 23 … … 48 54 css_include_tag('bar') 49 55 end 56 57 it "should render a link tag with a path_prefix" do 58 Merb::Server.config[:path_prefix] = '/inky' 59 css_include_tag('foo.css').clean.should == 60 %[<link href="/inky/stylesheets/foo.css" media="all" rel="Stylesheet" type="text/css"/>].clean 61 Merb::Server.config.delete(:path_prefix) 62 end 63 50 64 it "should not generate a script tag with the include_required_css" do 51 65 include_required_css.clean.should == '' 52 end 66 end 67 53 68 it "should generate script tags with the include_required_css" do 54 69 require_css('foo') … … 72 87 js_include_tag('bar') 73 88 end 89 90 it "should render a script tag with a path_prefix" do 91 Merb::Server.config[:path_prefix] = '/inky' 92 js_include_tag('foo.js').clean.should == 93 %[<script src="/inky/javascripts/foo.js" type="text/javascript">//</script>].clean 94 Merb::Server.config.delete(:path_prefix) 95 end 96 74 97 it "should not generate a script tag with the include_required_js" do 75 98 include_required_js.clean.should == '' 76 end 99 end 100 77 101 it "should generate script tags with the include_required_js" do 78 102 require_js('foo')
