be aware of spaces in paths. fixed #79
This commit is contained in:
parent
cdebfa4587
commit
7b333140a1
0
.gitmodules
vendored
0
.gitmodules
vendored
|
@ -12,6 +12,9 @@ Feature: Builder
|
||||||
Then "stylesheets/site_scss.css" should exist and include "html, body, div, span"
|
Then "stylesheets/site_scss.css" should exist and include "html, body, div, span"
|
||||||
Then "stylesheets/static.css" should exist and include "body"
|
Then "stylesheets/static.css" should exist and include "body"
|
||||||
Then "_partial.html" should not exist
|
Then "_partial.html" should not exist
|
||||||
|
Then "spaces in file.html" should exist and include "spaces"
|
||||||
|
Then "images/Read me (example).txt" should exist
|
||||||
|
Then "images/Child folder/regular_file(example).txt" should exist
|
||||||
And cleanup built test app
|
And cleanup built test app
|
||||||
|
|
||||||
Scenario: Force relative assets
|
Scenario: Force relative assets
|
||||||
|
|
|
@ -17,6 +17,11 @@ Given /^cleanup built test app$/ do
|
||||||
FileUtils.rm_rf(target)
|
FileUtils.rm_rf(target)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^"([^"]*)" should exist$/ do |target_file,|
|
||||||
|
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file)
|
||||||
|
File.exists?(target).should be_true
|
||||||
|
end
|
||||||
|
|
||||||
Then /^"([^"]*)" should exist and include "([^"]*)"$/ do |target_file, expected|
|
Then /^"([^"]*)" should exist and include "([^"]*)"$/ do |target_file, expected|
|
||||||
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file)
|
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file)
|
||||||
File.exists?(target).should be_true
|
File.exists?(target).should be_true
|
||||||
|
|
|
@ -2,6 +2,7 @@ with_layout false do
|
||||||
page "/inline-css.html"
|
page "/inline-css.html"
|
||||||
page "/inline-js.html"
|
page "/inline-js.html"
|
||||||
page "/inline-coffeescript.html"
|
page "/inline-coffeescript.html"
|
||||||
|
page "/spaces in file.html"
|
||||||
page "/slim.html"
|
page "/slim.html"
|
||||||
page "/data.html"
|
page "/data.html"
|
||||||
page "/page-classes.html"
|
page "/page-classes.html"
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Regular
|
1
fixtures/test-app/source/images/Read me (example).txt
Normal file
1
fixtures/test-app/source/images/Read me (example).txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
README
|
1
fixtures/test-app/source/spaces in file.html.erb
Normal file
1
fixtures/test-app/source/spaces in file.html.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<%= "spaces" %>
|
|
@ -83,21 +83,23 @@ module Middleman::Base
|
||||||
settings.set :views, File.join(settings.root, settings.views)
|
settings.set :views, File.join(settings.root, settings.views)
|
||||||
end
|
end
|
||||||
|
|
||||||
result = resolve_template(request.path_info, :raise_exceptions => false)
|
request_path = request.path_info.gsub("%20", " ")
|
||||||
|
result = resolve_template(request_path, :raise_exceptions => false)
|
||||||
|
|
||||||
if result
|
if result
|
||||||
extensionless_path, template_engine = result
|
extensionless_path, template_engine = result
|
||||||
|
|
||||||
# Return static files
|
# Return static files
|
||||||
if !::Tilt.mappings.has_key?(template_engine.to_s)
|
if !::Tilt.mappings.has_key?(template_engine.to_s)
|
||||||
content_type mime_type(File.extname(request.path_info)), :charset => 'utf-8'
|
content_type mime_type(File.extname(request_path)), :charset => 'utf-8'
|
||||||
status 200
|
status 200
|
||||||
send_file File.join(settings.views, request.path_info)
|
send_file File.join(settings.views, request_path)
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
$stderr.puts "File not found: #{request.path_info}"
|
$stderr.puts "File not found: #{request_path}"
|
||||||
status 404
|
status 404
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -156,11 +158,12 @@ module Middleman::Base
|
||||||
|
|
||||||
render_options = { :layout => layout }
|
render_options = { :layout => layout }
|
||||||
render_options[:layout_engine] = options[:layout_engine] if options.has_key? :layout_engine
|
render_options[:layout_engine] = options[:layout_engine] if options.has_key? :layout_engine
|
||||||
result = render(request.path_info, render_options)
|
request_path = request.path_info.gsub("%20", " ")
|
||||||
|
result = render(request_path, render_options)
|
||||||
settings.set :layout, old_layout
|
settings.set :layout, old_layout
|
||||||
|
|
||||||
if result
|
if result
|
||||||
content_type mime_type(File.extname(request.path_info)), :charset => 'utf-8'
|
content_type mime_type(File.extname(request_path)), :charset => 'utf-8'
|
||||||
status 200
|
status 200
|
||||||
body result
|
body result
|
||||||
else
|
else
|
||||||
|
|
|
@ -18,7 +18,7 @@ module Middleman
|
||||||
create_file destination, nil, config do
|
create_file destination, nil, config do
|
||||||
# The default render just requests the page over Rack and writes the response
|
# The default render just requests the page over Rack and writes the response
|
||||||
request_path = destination.sub(/^#{SHARED_SERVER.build_dir}/, "")
|
request_path = destination.sub(/^#{SHARED_SERVER.build_dir}/, "")
|
||||||
@@rack_test.get(request_path)
|
@@rack_test.get(request_path.gsub(/\s/, "%20"))
|
||||||
@@rack_test.last_response.body
|
@@rack_test.last_response.body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,8 @@ module Middleman::CoreExtensions::FrontMatter
|
||||||
|
|
||||||
app.after_feature_init do
|
app.after_feature_init do
|
||||||
app.before_processing do
|
app.before_processing do
|
||||||
result = resolve_template(request.path_info, :raise_exceptions => false)
|
request_path = request.path_info.gsub("%20", " ")
|
||||||
|
result = resolve_template(request_path, :raise_exceptions => false)
|
||||||
|
|
||||||
if result && Tilt.mappings.has_key?(result[1].to_s)
|
if result && Tilt.mappings.has_key?(result[1].to_s)
|
||||||
extensionless_path, template_engine = result
|
extensionless_path, template_engine = result
|
||||||
|
|
Loading…
Reference in a new issue