diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index f8cb7563..0712eed1 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -334,8 +334,9 @@ module Middleman end # Whether we're in a specific environment + # @param [Symbol] key # @return [Boolean] - Contract Bool + Contract Symbol => Bool def environment?(key) config[:environment] == key end diff --git a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb index d685e994..a133d0ef 100644 --- a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb +++ b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb @@ -12,7 +12,7 @@ require 'middleman-core/util/data' module Middleman::CoreExtensions class FrontMatter < ::Middleman::Extension # Try to run after routing but before directory_indexes - self.resource_list_manipulator_priority = 10 + self.resource_list_manipulator_priority = 20 def initialize(app, options_hash={}, &block) super diff --git a/middleman-core/lib/middleman-core/core_extensions/routing.rb b/middleman-core/lib/middleman-core/core_extensions/routing.rb index 0601d2d0..3e66f3dc 100644 --- a/middleman-core/lib/middleman-core/core_extensions/routing.rb +++ b/middleman-core/lib/middleman-core/core_extensions/routing.rb @@ -4,7 +4,7 @@ module Middleman class Routing < Extension # This should always run late, but not as late as :directory_indexes, # so it can add metadata to any pages generated by other extensions - self.resource_list_manipulator_priority = 80 + self.resource_list_manipulator_priority = 10 # Expose the `page` method to config. expose_to_config :page diff --git a/middleman-core/lib/middleman-core/extensions/automatic_image_sizes.rb b/middleman-core/lib/middleman-core/extensions/automatic_image_sizes.rb index aa184df9..b88721de 100644 --- a/middleman-core/lib/middleman-core/extensions/automatic_image_sizes.rb +++ b/middleman-core/lib/middleman-core/extensions/automatic_image_sizes.rb @@ -23,7 +23,8 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension if file && file[:full_path].exist? begin - width, height = ::FastImage.size(file[:full_path].to_s, raise_on_failure: true) + full_path = file[:full_path].to_s + width, height = ::FastImage.size(full_path, raise_on_failure: true) # Check for @2x and @3x image retina = full_path.match(/@(\d)x\.[a-zA-Z]{3,4}$/) if retina diff --git a/middleman-core/lib/middleman-core/extensions/minify_javascript.rb b/middleman-core/lib/middleman-core/extensions/minify_javascript.rb index 4ab0979a..73a75cd0 100644 --- a/middleman-core/lib/middleman-core/extensions/minify_javascript.rb +++ b/middleman-core/lib/middleman-core/extensions/minify_javascript.rb @@ -13,7 +13,7 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension def ready # Setup Rack middleware to minify JS - app.use Rack, compressor: chosen_compressor, + app.use Rack, compressor: options[:compressor], ignore: Array(options[:ignore]) + [/\.min\./], inline: options[:inline], content_types: options[:content_types], diff --git a/middleman-core/lib/middleman-core/rack.rb b/middleman-core/lib/middleman-core/rack.rb index 3e2a6f25..4578005b 100644 --- a/middleman-core/lib/middleman-core/rack.rb +++ b/middleman-core/lib/middleman-core/rack.rb @@ -14,6 +14,12 @@ require 'middleman-core/template_renderer' ::Rack::Mime::MIME_TYPES['.html'] = 'text/html; charset=utf-8' ::Rack::Mime::MIME_TYPES['.htm'] = 'text/html; charset=utf-8' +# Sourcemap format +::Rack::Mime::MIME_TYPES['.map'] = 'application/json; charset=utf-8' + +# Create a MIME type for PHP files (for detection by extensions) +::Rack::Mime::MIME_TYPES['.php'] = 'text/php' + module Middleman class Rack extend Forwardable diff --git a/middleman-core/lib/middleman-core/step_definitions/middleman_steps.rb b/middleman-core/lib/middleman-core/step_definitions/middleman_steps.rb index 395ff3de..ff256a94 100644 --- a/middleman-core/lib/middleman-core/step_definitions/middleman_steps.rb +++ b/middleman-core/lib/middleman-core/step_definitions/middleman_steps.rb @@ -1,15 +1,15 @@ Then /^the file "([^\"]*)" has the contents$/ do |path, contents| write_file(path, contents) - cd(".") do + # cd(".") do @server_inst.files.find_new_files! - end + # end end Then /^the file "([^\"]*)" is removed$/ do |path| step %Q{I remove the file "#{path}"} - cd(".") do + # cd(".") do @server_inst.files.find_new_files! - end + # end end diff --git a/middleman-core/lib/middleman-core/step_definitions/server_steps.rb b/middleman-core/lib/middleman-core/step_definitions/server_steps.rb index 448af3cf..1a80a118 100644 --- a/middleman-core/lib/middleman-core/step_definitions/server_steps.rb +++ b/middleman-core/lib/middleman-core/step_definitions/server_steps.rb @@ -1,3 +1,4 @@ +require 'middleman-core/rack' require 'rspec/expectations' require 'capybara/cucumber' @@ -41,7 +42,7 @@ Given /^the Server is running$/ do initialize_commands = @initialize_commands || [] - cd(".") do + # cd(".") do @server_inst = ::Middleman::Application.new do config[:watcher_disable] = true config[:show_exceptions] = false @@ -51,9 +52,8 @@ Given /^the Server is running$/ do end end - rack = ::Middleman::Rack.new(@server_inst) - Capybara.app = rack.to_app - end + Capybara.app = ::Middleman::Rack.new(@server_inst).to_app + # end end Given /^the Server is running at "([^\"]*)"$/ do |app_path| @@ -66,73 +66,73 @@ Given /^a template named "([^\"]*)" with:$/ do |name, string| end When /^I go to "([^\"]*)"$/ do |url| - cd(".") do + # cd(".") do visit(URI.encode(url).to_s) - end + # end end Then /^going to "([^\"]*)" should not raise an exception$/ do |url| - cd(".") do + # cd(".") do expect{ visit(URI.encode(url).to_s) }.to_not raise_exception - end + # end end Then /^the content type should be "([^\"]*)"$/ do |expected| - cd(".") do + # cd(".") do expect(page.response_headers['Content-Type']).to start_with expected - end + # end end Then /^I should see "([^\"]*)"$/ do |expected| - cd(".") do + # cd(".") do expect(page.body).to include expected - end + # end end Then /^I should see '([^\']*)'$/ do |expected| - cd(".") do + # cd(".") do expect(page.body).to include expected - end + # end end Then /^I should see:$/ do |expected| - cd(".") do + # cd(".") do expect(page.body).to include expected - end + # end end Then /^I should not see "([^\"]*)"$/ do |expected| - cd(".") do + # cd(".") do expect(page.body).not_to include expected - end + # end end Then /^I should see content matching %r{(.*)}$/ do |expected| - cd(".") do + # cd(".") do expect(page.body).to match(expected) - end + # end end Then /^I should not see content matching %r{(.*)}$/ do |expected| - cd(".") do + # cd(".") do expect(page.body).to_not match(expected) - end + # end end Then /^I should not see:$/ do |expected| - cd(".") do + # cd(".") do expect(page.body).not_to include expected - end + # end end Then /^the status code should be "([^\"]*)"$/ do |expected| - cd(".") do + # cd(".") do expect(page.status_code).to eq expected.to_i - end + # end end Then /^I should see "([^\"]*)" lines$/ do |lines| - cd(".") do + # cd(".") do expect(page.body.chomp.split($/).length).to eq lines.to_i - end + # end end