diff --git a/.document b/.document deleted file mode 100755 index 12085606..00000000 --- a/.document +++ /dev/null @@ -1,5 +0,0 @@ -README.rdoc -lib/**/*.rb -bin/* -features/**/*.feature -LICENSE \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29b..00000000 diff --git a/features/builder.feature b/features/builder.feature index d905831b..0d845fd4 100644 --- a/features/builder.feature +++ b/features/builder.feature @@ -12,6 +12,9 @@ Feature: Builder Then "stylesheets/site_scss.css" should exist and include "html, body, div, span" Then "stylesheets/static.css" should exist and include "body" 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 Scenario: Force relative assets diff --git a/features/step_definitions/builder_steps.rb b/features/step_definitions/builder_steps.rb index 013706c8..545cc969 100644 --- a/features/step_definitions/builder_steps.rb +++ b/features/step_definitions/builder_steps.rb @@ -17,6 +17,11 @@ Given /^cleanup built test app$/ do FileUtils.rm_rf(target) 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| target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file) File.exists?(target).should be_true diff --git a/fixtures/test-app/config.rb b/fixtures/test-app/config.rb index f8653e37..816b6892 100644 --- a/fixtures/test-app/config.rb +++ b/fixtures/test-app/config.rb @@ -2,6 +2,7 @@ with_layout false do page "/inline-css.html" page "/inline-js.html" page "/inline-coffeescript.html" + page "/spaces in file.html" page "/slim.html" page "/data.html" page "/page-classes.html" diff --git a/fixtures/test-app/source/images/Child folder/regular_file(example).txt b/fixtures/test-app/source/images/Child folder/regular_file(example).txt new file mode 100644 index 00000000..ea9503c0 --- /dev/null +++ b/fixtures/test-app/source/images/Child folder/regular_file(example).txt @@ -0,0 +1 @@ +Regular \ No newline at end of file diff --git a/fixtures/test-app/source/images/Read me (example).txt b/fixtures/test-app/source/images/Read me (example).txt new file mode 100644 index 00000000..100b9382 --- /dev/null +++ b/fixtures/test-app/source/images/Read me (example).txt @@ -0,0 +1 @@ +README \ No newline at end of file diff --git a/fixtures/test-app/source/spaces in file.html.erb b/fixtures/test-app/source/spaces in file.html.erb new file mode 100644 index 00000000..c67dbe85 --- /dev/null +++ b/fixtures/test-app/source/spaces in file.html.erb @@ -0,0 +1 @@ +<%= "spaces" %> \ No newline at end of file diff --git a/lib/middleman/base.rb b/lib/middleman/base.rb index b06426d2..6abcbe6d 100644 --- a/lib/middleman/base.rb +++ b/lib/middleman/base.rb @@ -83,21 +83,23 @@ module Middleman::Base settings.set :views, File.join(settings.root, settings.views) 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 extensionless_path, template_engine = result # Return static files 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 - send_file File.join(settings.views, request.path_info) + send_file File.join(settings.views, request_path) false else true end else - $stderr.puts "File not found: #{request.path_info}" + $stderr.puts "File not found: #{request_path}" status 404 false end @@ -156,11 +158,12 @@ module Middleman::Base render_options = { :layout => layout } 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 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 body result else diff --git a/lib/middleman/builder.rb b/lib/middleman/builder.rb index 6debbcce..62584b49 100644 --- a/lib/middleman/builder.rb +++ b/lib/middleman/builder.rb @@ -18,7 +18,7 @@ module Middleman create_file destination, nil, config do # The default render just requests the page over Rack and writes the response 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 end end diff --git a/lib/middleman/core_extensions/front_matter.rb b/lib/middleman/core_extensions/front_matter.rb index bb3d9b91..c893f1b3 100644 --- a/lib/middleman/core_extensions/front_matter.rb +++ b/lib/middleman/core_extensions/front_matter.rb @@ -24,7 +24,8 @@ module Middleman::CoreExtensions::FrontMatter app.after_feature_init 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) extensionless_path, template_engine = result