diff --git a/.rubocop.yml b/.rubocop.yml
index c92b709f..dbd74993 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -67,5 +67,3 @@ Style/MultilineBlockChain:
Enabled: false
Style/SpecialGlobalVars:
Enabled: false
-Style/FrozenStringLiteralComment:
- Enabled: false
diff --git a/.travis.yml b/.travis.yml
index ac5a7f06..e6bc197b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,6 +7,8 @@ rvm:
- ruby-head
- 2.3.1
- 2.2.4
+ - 2.1
+ - 2.0
os:
- linux
# - osx
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 148aa2e2..7e4e2f4b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,41 +1,14 @@
master
===
-# 4.1.13
+# 4.2.0
-* Change how config options are passed to Thor. Removes new Thor warnings from #2017
-
-# 4.1.12
-
-* Fix broken `ignore { |p| true }` form.
-
-# 4.1.11
-
-* Upgrade to Rack 2.
-
-# 4.1.10
-
-* Fix unicode issues in URL deeplinks.
-* Add prefix option to asset_hash (#1949)
-
-# 4.1.9
-
-* Fix `--watcher-*` CLI flags.
-* Allow spaces in paths to work with `link_to`. Fixes #1914
-* Add support for dotenv
-* Fix asset_url with asset_hash (#1919)
-* Allow partial lookups without a current_resource (#1912)
+* Remove Rack support in favor of `resource.filters << proc { |oldbody| newbody }`
+* Expose `development?` and `production?` helpers to template context.
# 4.1.8
-* Expose `development?` and `production?` helpers to template context.
-* require the `try` core extension (#1911)
-* Fix contract for Sitemap::Store.register_resource_list_manipulator (#1907)
-* Loosen contract on Resource#source_file to Maybe[String] (#1906)
* Let collection loops access ConfigContext for helpers. #1879
-* Use https:// to clone templates (#1901)
-* Allow numbers to be unique page_ids (#1886)
-* Prevent infinite loop when encountering files where base filename is a possible templating engine
# 4.1.7
diff --git a/Gemfile b/Gemfile
index db4043a0..f14eb3b1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -9,12 +9,6 @@ gem 'byebug'
gem 'aruba', '~> 0.7.4', require: false
gem 'rspec', '~> 3.0', require: false
gem 'cucumber', '~> 2.0', require: false
-gem 'addressable', '~> 2.4.0', require: false
-
-# Pry tools
-gem 'pry'
-gem 'pry-stack_explorer'
-gem 'pry-rescue'
# Optional middleman dependencies, included for tests
gem 'haml', '>= 4.0.5', require: false
@@ -24,7 +18,7 @@ gem 'kramdown', '~> 1.2', require: false
gem 'slim', '>= 2.0', require: false
gem 'liquid', '>= 2.6', require: false
gem 'stylus', '>= 1.0', require: false
-gem 'sinatra', '>= 2.0.0.beta2', require: false
+gem 'sinatra', '>= 1.4', require: false
gem 'redcarpet', '>= 3.1', require: false
# Dns server to test preview server
@@ -32,7 +26,7 @@ gem 'rubydns', '~> 1.0.1', require: false
# To test javascript
gem 'poltergeist', '~> 1.8', require: false
-gem 'phantomjs', '~> 2.1.1.0', require: false
+gem 'phantomjs', '~> 1.9.8.0', require: false
# For less, note there is no compatible JS runtime for windows
gem 'therubyrhino', '>= 2.0', platforms: :jruby
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
deleted file mode 100644
index 6d2dc0e0..00000000
--- a/ISSUE_TEMPLATE.md
+++ /dev/null
@@ -1,9 +0,0 @@
-## Expected behavior and actual behavior
-
-## Steps to reproduce the problem (from a clean middleman installation)
-
-## Additional information
-
-- Ruby version:
-- Middleman version:
-- OS version:
diff --git a/middleman-cli/bin/middleman b/middleman-cli/bin/middleman
index 8b381a08..b5d1921d 100755
--- a/middleman-cli/bin/middleman
+++ b/middleman-cli/bin/middleman
@@ -9,9 +9,6 @@ end
require "middleman-core/load_paths"
Middleman.setup_load_paths
-require 'dotenv'
-::Dotenv.load
-
require 'middleman-core'
require 'middleman-core/logger'
@@ -25,10 +22,12 @@ module Middleman::Cli
if setting.default.is_a?(String) || setting.default.is_a?(NilClass)
base.class_option setting.key,
type: :string,
+ default: :undefined,
desc: setting.description
elsif setting.default.is_a?(TrueClass) || setting.default.is_a?(FalseClass)
base.class_option setting.key,
type: :boolean,
+ default: :undefined,
desc: setting.description
end
end
@@ -47,8 +46,6 @@ end
::Middleman::Logger.singleton(3)
::Middleman::Cli.config = ::Middleman::Application.new do
- #
- config[:environment] = (ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development').to_sym
config[:mode] = :config
config[:exit_before_ready] = true
config[:watcher_disable] = true
diff --git a/middleman-cli/lib/middleman-cli/build.rb b/middleman-cli/lib/middleman-cli/build.rb
index 9e521dde..7d5dd3af 100644
--- a/middleman-cli/lib/middleman-cli/build.rb
+++ b/middleman-cli/lib/middleman-cli/build.rb
@@ -10,7 +10,7 @@ module Middleman::Cli
class_option :environment,
aliases: '-e',
- default: ENV['MM_ENV'] || ENV['RACK_ENV'] || :production
+ default: :production
class_option :clean,
type: :boolean,
default: true,
@@ -29,7 +29,7 @@ module Middleman::Cli
default: false,
desc: 'Print debug messages'
class_option :instrument,
- type: :boolean,
+ type: :string,
default: false,
desc: 'Print instrument messages'
class_option :profile,
@@ -64,7 +64,7 @@ module Middleman::Cli
config[:mode] = :build
config[:show_exceptions] = false
config[:cli_options] = cli_options.each_with_object({}) do |(k, v), sum|
- sum[k] = v
+ sum[k] = v unless v == :undefined
end
end
diff --git a/middleman-cli/lib/middleman-cli/init.rb b/middleman-cli/lib/middleman-cli/init.rb
index e8e5770c..f1c1927e 100644
--- a/middleman-cli/lib/middleman-cli/init.rb
+++ b/middleman-cli/lib/middleman-cli/init.rb
@@ -113,7 +113,7 @@ module Middleman::Cli
end
def repository_path(repo)
- repo.include?('://') || repo.include?('git@') ? repo : "https://github.com/#{repo}.git"
+ repo.include?('://') || repo.include?('git@') ? repo : "git://github.com/#{repo}.git"
end
# Add to CLI
diff --git a/middleman-cli/lib/middleman-cli/server.rb b/middleman-cli/lib/middleman-cli/server.rb
index 85e75a9f..479f53bd 100644
--- a/middleman-cli/lib/middleman-cli/server.rb
+++ b/middleman-cli/lib/middleman-cli/server.rb
@@ -17,7 +17,7 @@ module Middleman::Cli
default: false,
desc: 'Print debug messages'
class_option :instrument,
- type: :boolean,
+ type: :string,
default: false,
desc: 'Print instrument messages'
class_option :profile,
diff --git a/middleman-cli/middleman-cli.gemspec b/middleman-cli/middleman-cli.gemspec
index e9447a9c..f2719efc 100644
--- a/middleman-cli/middleman-cli.gemspec
+++ b/middleman-cli/middleman-cli.gemspec
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0")
s.executable = 'middleman'
s.require_path = 'lib'
- s.required_ruby_version = '>= 2.2.0'
+ s.required_ruby_version = '>= 2.0.0'
# CLI
s.add_dependency('thor', ['>= 0.17.0', '< 2.0'])
diff --git a/middleman-core/features/asset_hash.feature b/middleman-core/features/asset_hash.feature
index 7c173800..6b92777c 100644
--- a/middleman-core/features/asset_hash.feature
+++ b/middleman-core/features/asset_hash.feature
@@ -188,23 +188,6 @@ Feature: Assets get file hashes appended to them and references to them are upda
When I go to "/partials/"
Then I should see 'href="../stylesheets/uses_partials-ec347271.css'
- Scenario: The asset hash should change when a Rack-based filter changes
- Given a fixture app "asset-hash-app"
- And a file named "config.rb" with:
- """
- activate :asset_hash
- activate :relative_assets
- activate :directory_indexes
- require 'lib/middleware.rb'
- use ::Middleware
- """
- Given the Server is running at "asset-hash-app"
- When I go to "/"
- Then I should see 'href="stylesheets/site-5ad7def0.css'
- When I go to "stylesheets/site-5ad7def0.css"
- Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg")'
- Then I should see 'Added by Rack filter'
-
Scenario: Hashed-asset files are not produced for ignored paths
Given a fixture app "asset-hash-app"
And a file named "config.rb" with:
@@ -308,17 +291,3 @@ Feature: Assets get file hashes appended to them and references to them are upda
| javascripts/application.js.map |
And the file "javascripts/application-4553338c.js" should contain "//# sourceMappingURL=application.js-22cc2b5f.map"
-
- Scenario: Hashes can contain a prefix
- Given a successfully built app at "asset-hash-prefix"
- When I cd to "build"
- Then the following files should exist:
- | index.html |
- | javascripts/application-myprefix-4553338c.js |
- | javascripts/application.js-myprefix-22cc2b5f.map |
- | index.html |
- And the following files should not exist:
- | javascripts/application.js |
- | javascripts/application.js.map |
-
- And the file "javascripts/application-myprefix-4553338c.js" should contain "//# sourceMappingURL=application.js-myprefix-22cc2b5f.map"
diff --git a/middleman-core/features/asset_host.feature b/middleman-core/features/asset_host.feature
index 0433b61b..646f1154 100644
--- a/middleman-core/features/asset_host.feature
+++ b/middleman-core/features/asset_host.feature
@@ -25,8 +25,7 @@ Feature: Alternate between multiple asset hosts
And a file named "config.rb" with:
"""
activate :asset_host, host: Proc.new { |asset|
- hash = Digest::MD5.digest(asset).bytes.map!(&:ord).reduce(&:+)
- "http://assets%d.example.com" % (hash % 4)
+ "http://assets%d.example.com" % (asset.hash % 4)
}
"""
And the Server is running
diff --git a/middleman-core/features/endpoints.feature b/middleman-core/features/endpoints.feature
new file mode 100644
index 00000000..1ff6aaf6
--- /dev/null
+++ b/middleman-core/features/endpoints.feature
@@ -0,0 +1,17 @@
+Feature: Generic block based pages
+
+ Scenario: Static Ruby Endpoints
+ Given an empty app
+ And a file named "config.rb" with:
+ """
+ endpoint "hello.html" do
+ "world"
+ end
+ """
+ And a file named "source/index.html.erb" with:
+ """
+ Hi
+ """
+ And the Server is running at "empty_app"
+ When I go to "/hello.html"
+ Then I should see "world"
diff --git a/middleman-core/features/extension_api_deprecations.feature b/middleman-core/features/extension_api_deprecations.feature
index 8c9dd216..15f447ac 100644
--- a/middleman-core/features/extension_api_deprecations.feature
+++ b/middleman-core/features/extension_api_deprecations.feature
@@ -3,8 +3,9 @@ Feature: Extension author could use some hooks
Scenario: When build
Given a fixture app "extension-api-deprecations-app"
When I run `middleman build`
- Then the exit status should be 0
+ And the exit status should be 0
And the output should contain "`set :layout` is deprecated"
+ And the output should contain "Project built successfully"
And the file "build/index.html" should contain "In Index"
And the file "build/index.html" should not contain "In Layout"
diff --git a/middleman-core/features/extension_hooks.feature b/middleman-core/features/extension_hooks.feature
index 1dedd9a9..11a05557 100644
--- a/middleman-core/features/extension_hooks.feature
+++ b/middleman-core/features/extension_hooks.feature
@@ -7,7 +7,6 @@ Feature: Extension author could use some hooks
And the output should contain "/// after_configuration ///"
And the output should contain "/// ready ///"
And the output should contain "/// before_build ///"
- And the output should contain "/// before ///"
And the output should contain "/// before_render ///"
And the output should contain "/// after_render ///"
And the output should contain "/// after_build ///"
diff --git a/middleman-core/features/helpers_link_to.feature b/middleman-core/features/helpers_link_to.feature
index fe8e8530..90b6f08a 100644
--- a/middleman-core/features/helpers_link_to.feature
+++ b/middleman-core/features/helpers_link_to.feature
@@ -40,29 +40,19 @@ Feature: link_to helper
"""
absolute: <%= link_to "Needs Index", "/needs_index.html", relative: true %>
relative: <%= link_to "Relative", "needs_index.html", relative: true %>
-
- absolute spaces: <%= link_to "Spaces Index", "/evil spaces.html", relative: true %>
- relative spaces: <%= link_to "Spaces Relative", "evil spaces.html", relative: true %>
"""
And a file named "source/link_to/sub.html.erb" with:
"""
absolute: <%= link_to "Needs Index", "/needs_index.html", relative: true %>
relative: <%= link_to "Relative", "../needs_index.html", relative: true %>
-
- absolute spaces: <%= link_to "Spaces Index", "/evil spaces.html", relative: true %>
- relative spaces: <%= link_to "Spaces Relative", "../evil spaces.html", relative: true %>
"""
And the Server is running at "indexable-app"
When I go to "/link_to.html"
Then I should see 'absolute: Needs Index'
Then I should see 'relative: Relative'
- Then I should see 'absolute spaces: Spaces Index'
- Then I should see 'relative spaces: Spaces Relative'
When I go to "/link_to/sub.html"
Then I should see 'absolute: Needs Index'
Then I should see 'relative: Relative'
- Then I should see 'absolute spaces: Spaces Index'
- Then I should see 'relative spaces: Spaces Relative'
Scenario: link_to relative works with strip_index_file
Given a fixture app "indexable-app"
@@ -123,7 +113,7 @@ Feature: link_to helper
When I go to "/link_to/sub.html"
Then I should see 'absolute: Needs Index'
Then I should see 'relative: Relative'
-
+
Scenario: link_to knows about directory indexes
Given a fixture app "indexable-app"
And a file named "source/link_to.html.erb" with:
diff --git a/middleman-core/features/i18n_link_to.feature b/middleman-core/features/i18n_link_to.feature
index 9d3f0682..a10787c4 100644
--- a/middleman-core/features/i18n_link_to.feature
+++ b/middleman-core/features/i18n_link_to.feature
@@ -4,7 +4,7 @@ Feature: i18n Paths
Given a fixture app "empty-app"
And a file named "data/pages.yml" with:
"""
- - hello.html
+ - hello.html
"""
And a file named "locales/en.yml" with:
"""
@@ -50,24 +50,24 @@ Feature: i18n Paths
Given the Server is running at "empty-app"
When I go to "/hello.html"
Then I should see "Page: Hello"
- Then I should see 'Current Home'
- Then I should see 'Other Home'
- Then I should see 'Home: Current Block'
- Then I should see 'Home: Other Block'
- Then I should see 'Current hello.html'
- Then I should see 'Other hello.html'
- Then I should see 'Current Block'
- Then I should see 'Other Block'
+ Then I should see 'Current Home'
+ Then I should see 'Other Home'
+ Then I should see 'Home: Current Block'
+ Then I should see 'Home: Other Block'
+ Then I should see 'Current hello.html'
+ Then I should see 'Other hello.html'
+ Then I should see 'Current Block'
+ Then I should see 'Other Block'
When I go to "/es/hola.html"
Then I should see "Page: Hola"
- Then I should see 'Current Home'
- Then I should see 'Other Home'
- Then I should see 'Home: Current Block'
- Then I should see 'Home: Other Block'
- Then I should see 'Current hello.html'
- Then I should see 'Other hello.html'
- Then I should see 'Current Block'
- Then I should see 'Other Block'
+ Then I should see 'Current Home'
+ Then I should see 'Other Home'
+ Then I should see 'Home: Current Block'
+ Then I should see 'Home: Other Block'
+ Then I should see 'Current hello.html'
+ Then I should see 'Other hello.html'
+ Then I should see 'Current Block'
+ Then I should see 'Other Block'
Scenario: link_to is i18n aware and supports relative_links
Given a fixture app "empty-app"
@@ -124,30 +124,30 @@ Feature: i18n Paths
Then I should see "assets/css/main.css"
When I go to "/hello.html"
Then I should see "Page: Hello"
- Then I should see 'Current Home'
- Then I should see 'Other Home'
- Then I should see 'Home: Current Block'
- Then I should see 'Home: Other Block'
- Then I should see 'Current hello.html'
- Then I should see 'Other hello.html'
- Then I should see 'Current Block'
- Then I should see 'Other Block'
+ Then I should see 'Current Home'
+ Then I should see 'Other Home'
+ Then I should see 'Home: Current Block'
+ Then I should see 'Home: Other Block'
+ Then I should see 'Current hello.html'
+ Then I should see 'Other hello.html'
+ Then I should see 'Current Block'
+ Then I should see 'Other Block'
When I go to "/es/hola.html"
Then I should see "Page: Hola"
- Then I should see 'Current Home'
- Then I should see 'Other Home'
- Then I should see 'Home: Current Block'
- Then I should see 'Home: Other Block'
- Then I should see 'Current hello.html'
- Then I should see 'Other hello.html'
- Then I should see 'Current Block'
- Then I should see 'Other Block'
+ Then I should see 'Current Home'
+ Then I should see 'Other Home'
+ Then I should see 'Home: Current Block'
+ Then I should see 'Home: Other Block'
+ Then I should see 'Current hello.html'
+ Then I should see 'Other hello.html'
+ Then I should see 'Current Block'
+ Then I should see 'Other Block'
Scenario: url_for is i18n aware
Given a fixture app "empty-app"
And a file named "data/pages.yml" with:
"""
- - hello.html
+ - hello.html
- article.html
"""
And a file named "locales/en.yml" with:
diff --git a/middleman-core/features/markdown_redcarpet_in_slim.feature b/middleman-core/features/markdown_redcarpet_in_slim.feature
deleted file mode 100644
index 250c6857..00000000
--- a/middleman-core/features/markdown_redcarpet_in_slim.feature
+++ /dev/null
@@ -1,41 +0,0 @@
-Feature: Markdown support in Slim
- In order to test support of the Slim markdown filter
-
- Scenario: Markdown filter in Slim works
- Given a fixture app "markdown-in-slim-app"
- And a file named "config.rb" with:
- """
- set :markdown_engine, :redcarpet
- activate :directory_indexes
- """
- And a file named "source/markdown_filter.html.slim" with:
- """
- markdown:
- # H1
-
- paragraph
- """
- Given the Server is running at "markdown-in-slim-app"
- When I go to "/markdown_filter/"
- Then I should see ">H1"
- Then I should see "
paragraph
"
-
-
- Scenario: Markdown filter in Slim uses our link_to and image_tag helpers
- Given a fixture app "markdown-in-slim-app"
- And a file named "config.rb" with:
- """
- set :markdown_engine, :redcarpet
- activate :directory_indexes
- """
- And a file named "source/link_and_image.html.slim" with:
- """
- markdown:
- [A link](/link_target.html)
-
- 
- """
- Given the Server is running at "markdown-in-slim-app"
- When I go to "/link_and_image/"
- Then I should see "/link_target/"
- Then I should see 'src="/images/blank.gif"'
diff --git a/middleman-core/features/mount_rack.feature b/middleman-core/features/mount_rack.feature
deleted file mode 100644
index dcb83146..00000000
--- a/middleman-core/features/mount_rack.feature
+++ /dev/null
@@ -1,65 +0,0 @@
-Feature: Support Rack apps mounted using map
-
- Scenario: Mounted Rack App at /sinatra
- Given the Server is running at "sinatra-app"
- When I go to "/"
- Then I should see "Hello World (Middleman)"
- When I go to "/sinatra/"
- Then I should see "Hello World (Sinatra)"
-
- Scenario: Built Mounted Rack App at /sinatra
- Given a successfully built app at "sinatra-app"
- When I cd to "build"
- Then the following files should exist:
- | index.html |
- Then the following files should not exist:
- | sinatra/index.html |
- | sinatra/index2.html |
-
- Scenario: Static Ruby Endpoints
- Given a fixture app "sinatra-app"
- And a file named "config.rb" with:
- """
- endpoint "hello.html" do
- "world"
- end
- """
- And the Server is running at "sinatra-app"
- When I go to "/hello.html"
- Then I should see "world"
-
- Scenario: Built Mounted Rack App at /sinatra (including rack endpoints)
- Given a fixture app "sinatra-app"
- And a file named "config.rb" with:
- """
- require "sinatra"
-
- class MySinatra < Sinatra::Base
- get "/" do
- "Hello World (Sinatra)"
- end
- get "/derp.html" do
- "De doo"
- end
- end
-
- map "/sinatra" do
- run MySinatra
- end
-
- endpoint "sinatra/index2.html", path: "/sinatra/"
-
- endpoint "dedoo.html", path: "/sinatra/derp.html"
-
- endpoint "hello.html" do
- "world"
- end
- """
- And a successfully built app at "sinatra-app"
- When I cd to "build"
- Then the following files should exist:
- | index.html |
- | sinatra/index2.html |
- | dedoo.html |
- And the file "sinatra/index2.html" should contain 'Hello World (Sinatra)'
- And the file "dedoo.html" should contain 'De doo'
\ No newline at end of file
diff --git a/middleman-core/features/page-id.feature b/middleman-core/features/page-id.feature
index 74d08cb5..63dd6fad 100644
--- a/middleman-core/features/page-id.feature
+++ b/middleman-core/features/page-id.feature
@@ -3,60 +3,14 @@ Feature: Page IDs
Scenario: link_to works with blocks (erb)
Given the Server is running at "page-id-app"
When I go to "/index.html"
- Then I should see "I am: index"
+ Then I should see "I am: index.html"
And I should see "URL1: /fm.html"
And I should see "URL2: /2.html"
And I should see 'URL3: Hi'
And I should see 'URL4: Sym'
- And I should see 'URL5: Imp'
- And I should see 'URL6: Foldern'
- And I should see 'URL7: Feed'
When I go to "/fm.html"
Then I should see "I am: frontmatter"
- When I go to "/implicit.html"
- Then I should see "I am: implicit"
- When I go to "/feed.xml"
- Then I should see "I am: feed.xml"
- When I go to "/folder/foldern.html"
- Then I should see "I am: folder/foldern"
-
- When I go to "/1.html"
- Then I should see "I am: page1"
- When I go to "/2.html"
- Then I should see "I am: page2"
- When I go to "/3.html"
- Then I should see "I am: page3"
-
- When I go to "/overwrites/from-default.html"
- Then I should see "I am: something-else"
-
- When I go to "/overwrites/from-frontmatter.html"
- Then I should see "I am: from_frontmatter"
-
- Scenario: Override page ID derivation with a proc
- Given a fixture app "page-id-app"
- And app "page-id-app" is using config "proc"
- And the Server is running at "page-id-app"
-
- When I go to "/index.html"
- Then I should see "I am: index.html-foo"
- And I should see "URL1: /fm.html"
- And I should see "URL2: /2.html"
- And I should see 'URL3: Hi'
- And I should see 'URL4: Sym'
- And I should see 'URL8: Imp'
- And I should see 'URL9: Foldern'
- And I should see 'URL10: Feed'
-
- When I go to "/fm.html"
- Then I should see "I am: frontmatter"
- When I go to "/implicit.html"
- Then I should see "I am: implicit.html-foo"
- When I go to "/feed.xml"
- Then I should see "I am: feed.xml-foo"
- When I go to "/folder/foldern.html"
- Then I should see "I am: folder/foldern.html-foo"
When I go to "/1.html"
Then I should see "I am: page1"
diff --git a/middleman-core/features/relative_assets.feature b/middleman-core/features/relative_assets.feature
index ba131396..ea6cbff0 100644
--- a/middleman-core/features/relative_assets.feature
+++ b/middleman-core/features/relative_assets.feature
@@ -120,7 +120,7 @@ Feature: Relative Assets
"""
And the Server is running at "relative-assets-app"
When I go to "/sub/image_tag.html"
- Then I should see '
'
Scenario: Relative assets should not break data URIs in image_tag
Given a fixture app "relative-assets-app"
diff --git a/middleman-core/features/relative_assets_helpers_only.feature b/middleman-core/features/relative_assets_helpers_only.feature
index 194c8b37..9d508977 100644
--- a/middleman-core/features/relative_assets_helpers_only.feature
+++ b/middleman-core/features/relative_assets_helpers_only.feature
@@ -72,7 +72,7 @@ Feature: Relative Assets (Helpers Only)
"""
And the Server is running at "relative-assets-app"
When I go to "/sub/image_tag.html"
- Then I should see '
'
Scenario: Relative assets should not break data URIs in image_tag
Given a fixture app "relative-assets-app"
diff --git a/middleman-core/features/sass_in_slim.feature b/middleman-core/features/sass_in_slim.feature
deleted file mode 100644
index d04055e4..00000000
--- a/middleman-core/features/sass_in_slim.feature
+++ /dev/null
@@ -1,40 +0,0 @@
-Feature: Sass/SCSS support in Slim
- In order to test support of the Slim sass and scss filters
-
- Scenario: Sass filter in Slim works
- Given a fixture app "sass-in-slim-app"
- And a file named "config.rb" with:
- """
- activate :directory_indexes
- """
- And a file named "source/sass_filter.html.slim" with:
- """
- sass:
- .sass
- margin: 0
- """
- Given the Server is running at "sass-in-slim-app"
- When I go to "/sass_filter/"
- Then I should see "text/css"
- Then I should see ".sass"
- Then I should see "margin:0"
-
-
- Scenario: SCSS filter in Slim works
- Given a fixture app "sass-in-slim-app"
- And a file named "config.rb" with:
- """
- activate :directory_indexes
- """
- And a file named "source/scss_filter.html.slim" with:
- """
- scss:
- .scss {
- margin: 0;
- }
- """
- Given the Server is running at "sass-in-slim-app"
- When I go to "/scss_filter/"
- Then I should see "text/css"
- Then I should see ".scss"
- Then I should see "margin:0"
diff --git a/middleman-core/fixtures/asset-hash-prefix/config.rb b/middleman-core/fixtures/asset-hash-prefix/config.rb
deleted file mode 100644
index 449a2e98..00000000
--- a/middleman-core/fixtures/asset-hash-prefix/config.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-
-activate :asset_hash,
- prefix: "myprefix-"
-
-activate :relative_assets
-
-activate :directory_indexes
diff --git a/middleman-core/fixtures/asset-hash-prefix/lib/middleware.rb b/middleman-core/fixtures/asset-hash-prefix/lib/middleware.rb
deleted file mode 100644
index 8ee825fd..00000000
--- a/middleman-core/fixtures/asset-hash-prefix/lib/middleware.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-class Middleware
- def initialize(app)
- @app = app
- end
-
- def call(env)
- status, headers, response = @app.call(env)
- body = ''
- response.each {|part| body += part }
- if (env["PATH_INFO"] =~ /css$/)
- body += "\n/* Added by Rack filter */"
- status, headers, response = Rack::Response.new(body, status, headers).finish
- end
- [status, headers, response]
- end
-end
diff --git a/middleman-core/fixtures/asset-hash-prefix/source/index.html.erb b/middleman-core/fixtures/asset-hash-prefix/source/index.html.erb
deleted file mode 100644
index a88cc13f..00000000
--- a/middleman-core/fixtures/asset-hash-prefix/source/index.html.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-<% content_for :head do %>
- The Middleman!
-<% end %>
-
-Testing the sitemap hashing
-
diff --git a/middleman-core/fixtures/asset-hash-prefix/source/javascripts/application.js b/middleman-core/fixtures/asset-hash-prefix/source/javascripts/application.js
deleted file mode 100644
index c72f8572..00000000
--- a/middleman-core/fixtures/asset-hash-prefix/source/javascripts/application.js
+++ /dev/null
@@ -1,2 +0,0 @@
-function foo(){var message="HEY THERE FRIEND!";var para=document.createElement("p");para.innerHTML=message;var body=document.getElementsByTagName("body")[0];body.insertBefore(para,body.firstChild)}window.onload=foo;
-//# sourceMappingURL=application.js.map
diff --git a/middleman-core/fixtures/asset-hash-prefix/source/javascripts/application.js.map b/middleman-core/fixtures/asset-hash-prefix/source/javascripts/application.js.map
deleted file mode 100644
index 6a5acd5c..00000000
--- a/middleman-core/fixtures/asset-hash-prefix/source/javascripts/application.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["source/javascripts/application.js"],"names":["foo","message","para","document","createElement","innerHTML","body","getElementsByTagName","insertBefore","firstChild","window","onload"],"mappings":"AAAA,QAASA,OACP,GAAIC,SAAU,mBACd,IAAIC,MAAOC,SAASC,cAAc,IAClCF,MAAKG,UAAYJ,OACb,IAAIK,MAAOH,SAASI,qBAAqB,QAAQ,EAC/CD,MAAKE,aAAaN,KAAMI,KAAKG,YAGpCC,OAAOC,OAASX"}
\ No newline at end of file
diff --git a/middleman-core/fixtures/asset-hash-prefix/source/layout.erb b/middleman-core/fixtures/asset-hash-prefix/source/layout.erb
deleted file mode 100644
index c8aacecf..00000000
--- a/middleman-core/fixtures/asset-hash-prefix/source/layout.erb
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
- <%= javascript_include_tag "application" %>
- <%= yield_content :head %>
-
-
-
-
-
- <%= yield %>
-
-
-
-
diff --git a/middleman-core/fixtures/sass-in-slim-app/config.rb b/middleman-core/fixtures/asset-host-app/source/images/blank11.gif
similarity index 100%
rename from middleman-core/fixtures/sass-in-slim-app/config.rb
rename to middleman-core/fixtures/asset-host-app/source/images/blank11.gif
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank12.gif b/middleman-core/fixtures/asset-host-app/source/images/blank12.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank41.gif b/middleman-core/fixtures/asset-host-app/source/images/blank41.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank42.gif b/middleman-core/fixtures/asset-host-app/source/images/blank42.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank5.gif b/middleman-core/fixtures/asset-host-app/source/images/blank5.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank51.gif b/middleman-core/fixtures/asset-host-app/source/images/blank51.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank52.gif b/middleman-core/fixtures/asset-host-app/source/images/blank52.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank6.gif b/middleman-core/fixtures/asset-host-app/source/images/blank6.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank61.gif b/middleman-core/fixtures/asset-host-app/source/images/blank61.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank62.gif b/middleman-core/fixtures/asset-host-app/source/images/blank62.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank7.gif b/middleman-core/fixtures/asset-host-app/source/images/blank7.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank71.gif b/middleman-core/fixtures/asset-host-app/source/images/blank71.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank72.gif b/middleman-core/fixtures/asset-host-app/source/images/blank72.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank8.gif b/middleman-core/fixtures/asset-host-app/source/images/blank8.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank81.gif b/middleman-core/fixtures/asset-host-app/source/images/blank81.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/asset-host-app/source/images/blank82.gif b/middleman-core/fixtures/asset-host-app/source/images/blank82.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/page-id-app/config-proc.rb b/middleman-core/fixtures/page-id-app/config-proc.rb
deleted file mode 100644
index 03070f0e..00000000
--- a/middleman-core/fixtures/page-id-app/config-proc.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-%w(1 2 3).each do |n|
- proxy "/#{n}.html", "/index.html", id: "page#{n}"
-end
-
-page "/overwrites/*", id: :"something-else"
-
-config[:page_id_generator] = ->(path){ path + "-foo" }
diff --git a/middleman-core/fixtures/page-id-app/source/feed.xml.erb b/middleman-core/fixtures/page-id-app/source/feed.xml.erb
deleted file mode 100644
index a27800bd..00000000
--- a/middleman-core/fixtures/page-id-app/source/feed.xml.erb
+++ /dev/null
@@ -1 +0,0 @@
-I am: <%= current_resource.page_id %>
diff --git a/middleman-core/fixtures/page-id-app/source/folder/foldern.html.erb b/middleman-core/fixtures/page-id-app/source/folder/foldern.html.erb
deleted file mode 100644
index a27800bd..00000000
--- a/middleman-core/fixtures/page-id-app/source/folder/foldern.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-I am: <%= current_resource.page_id %>
diff --git a/middleman-core/fixtures/page-id-app/source/implicit.html.erb b/middleman-core/fixtures/page-id-app/source/implicit.html.erb
deleted file mode 100644
index a27800bd..00000000
--- a/middleman-core/fixtures/page-id-app/source/implicit.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-I am: <%= current_resource.page_id %>
diff --git a/middleman-core/fixtures/page-id-app/source/index.html.erb b/middleman-core/fixtures/page-id-app/source/index.html.erb
index 6060bc3f..8f2997b6 100644
--- a/middleman-core/fixtures/page-id-app/source/index.html.erb
+++ b/middleman-core/fixtures/page-id-app/source/index.html.erb
@@ -4,11 +4,3 @@ URL1: <%= url_for "frontmatter" %>
URL2: <%= url_for "page2" %>
URL3: <%= link_to "Hi", "page3" %>
URL4: <%= link_to "Sym", :"something-else" %>
-URL5: <%= link_to "Imp", :implicit %>
-URL6: <%= link_to "Foldern", "folder/foldern" %>
-URL7: <%= link_to "Feed", "feed.xml" %>
-
-<%# If custom proc %>
-URL8: <%= link_to "Imp", "implicit.html-foo" %>
-URL9: <%= link_to "Foldern", "folder/foldern.html-foo" %>
-URL10: <%= link_to "Feed", "feed.xml-foo" %>
diff --git a/middleman-core/fixtures/sinatra-app/config.rb b/middleman-core/fixtures/sinatra-app/config.rb
deleted file mode 100644
index 0251a715..00000000
--- a/middleman-core/fixtures/sinatra-app/config.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require "sinatra"
-
-class MySinatra < Sinatra::Base
- get "/" do
- "Hello World (Sinatra)"
- end
- get "/derp.html" do
- "De doo"
- end
-end
-
-map "/sinatra" do
- run MySinatra
-end
diff --git a/middleman-core/fixtures/sinatra-app/source/index.html.erb b/middleman-core/fixtures/sinatra-app/source/index.html.erb
deleted file mode 100644
index 8b59c41c..00000000
--- a/middleman-core/fixtures/sinatra-app/source/index.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
----
-layout: false
----
-
-Hello World (Middleman)
\ No newline at end of file
diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb
index 52b31c92..4ecd40f8 100644
--- a/middleman-core/lib/middleman-core/application.rb
+++ b/middleman-core/lib/middleman-core/application.rb
@@ -157,12 +157,12 @@ module Middleman
define_setting :layout, :_auto_layout, 'Default layout name'
# Which file extensions have a layout by default.
- # @return [Array.]
- define_setting :extensions_with_layout, %w(.htm .html .xhtml .php), 'Which file extensions have a layout by default.'
+ # @return [Set.]
+ define_setting :extensions_with_layout, %w(.htm .html .xhtml .php), 'Which file extensions have a layout by default.', set: true
# Which file extensions are "assets."
# @return [Array.]
- define_setting :asset_extensions, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif .ttf .otf .woff .woff2 .eot .ico .map), 'Which file extensions are treated as assets.'
+ define_setting :asset_extensions, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif .ttf .otf .woff .woff2 .eot .ico .map), 'Which file extensions are treated as assets.', set: true
# Default string encoding for templates and output.
# @return [String]
@@ -203,7 +203,6 @@ module Middleman
define_setting :watcher_disable, false, 'If the Listen watcher should not run'
define_setting :watcher_force_polling, false, 'If the Listen watcher should run in polling mode'
define_setting :watcher_latency, nil, 'The Listen watcher latency'
- define_setting :watcher_wait_for_delay, 0.5, 'The Listen watcher delay between calls when changes exist'
# Delegate convenience methods off to their implementations
def_delegator :"::Middleman::Logger", :singleton, :logger
@@ -267,8 +266,6 @@ module Middleman
# Evaluate a passed block if given
config_context.instance_exec(&block) if block_given?
- apply_cli_options
-
execute_callbacks(:before_sitemap)
# Initialize the Sitemap
@@ -279,6 +276,8 @@ module Middleman
# Before config is parsed, before extensions get to it.
execute_callbacks(:initialized)
+ apply_cli_options
+
# Before config is parsed. Mostly used for extensions.
execute_callbacks(:before_configuration)
@@ -345,11 +344,11 @@ module Middleman
# Clean up missing Tilt exts
def prune_tilt_templates!
- ::Tilt.default_mapping.lazy_map.each_key do |key|
+ ::Tilt.mappings.each_key do |key|
begin
::Tilt[".#{key}"]
rescue LoadError, NameError
- ::Tilt.default_mapping.lazy_map.delete(key)
+ ::Tilt.mappings.delete(key)
end
end
end
diff --git a/middleman-core/lib/middleman-core/builder.rb b/middleman-core/lib/middleman-core/builder.rb
index 1796d4d7..c84bfa39 100644
--- a/middleman-core/lib/middleman-core/builder.rb
+++ b/middleman-core/lib/middleman-core/builder.rb
@@ -2,7 +2,6 @@ require 'pathname'
require 'fileutils'
require 'tempfile'
require 'parallel'
-require 'middleman-core/rack'
require 'middleman-core/callback_manager'
require 'middleman-core/contracts'
@@ -39,9 +38,6 @@ module Middleman
@cleaning = opts.fetch(:clean)
@parallel = opts.fetch(:parallel, true)
- rack_app = ::Middleman::Rack.new(@app).to_app
- @rack = ::Rack::MockRequest.new(rack_app)
-
@callbacks = ::Middleman::CallbackManager.new
@callbacks.install_methods!(self, [:on_build_event])
end
@@ -227,15 +223,7 @@ module Middleman
if resource.binary?
export_file!(output_file, resource.file_descriptor[:full_path])
else
- response = @rack.get(::URI.escape(resource.request_path))
-
- # If we get a response, save it to a tempfile.
- if response.status == 200
- export_file!(output_file, binary_encode(response.body))
- else
- trigger(:error, output_file, response.body)
- return false
- end
+ export_file!(output_file, binary_encode(resource.render))
end
rescue => e
trigger(:error, output_file, "#{e}\n#{e.backtrace.join("\n")}")
diff --git a/middleman-core/lib/middleman-core/configuration.rb b/middleman-core/lib/middleman-core/configuration.rb
index c916fc90..0d6d9be7 100644
--- a/middleman-core/lib/middleman-core/configuration.rb
+++ b/middleman-core/lib/middleman-core/configuration.rb
@@ -1,3 +1,5 @@
+require 'set'
+
module Middleman
module Configuration
# A class that manages a collection of documented settings.
@@ -129,23 +131,37 @@ module Middleman
def initialize(key, default, description, options={})
@value_set = false
+ @array_wrapped_value = nil
+ @array_wrapped_default = nil
self.key = key
self.default = default
self.description = description
self.options = options
+
+ @array_wrapped_default = if self.default && options[:set] && self.default.is_a?(Array)
+ Set.new(self.default)
+ end
end
# The user-supplied value for this setting, overriding the default
def value=(value)
@value = value
@value_set = true
+
+ @array_wrapped_value = if @value && options[:set] && @value.is_a?(Array)
+ Set.new(@value)
+ end
end
# The effective value of the setting, which may be the default
# if the user has not set a value themselves. Note that even if the
# user sets the value to nil it will override the default.
def value
- value_set? ? @value : default
+ if value_set?
+ @array_wrapped_value ? @array_wrapped_value : @value
+ else
+ @array_wrapped_default ? @array_wrapped_default : default
+ end
end
# Whether or not there has been a value set beyond the default
diff --git a/middleman-core/lib/middleman-core/core_extensions.rb b/middleman-core/lib/middleman-core/core_extensions.rb
index e38be937..ea31f89a 100644
--- a/middleman-core/lib/middleman-core/core_extensions.rb
+++ b/middleman-core/lib/middleman-core/core_extensions.rb
@@ -19,12 +19,6 @@ Middleman::Extensions.register :data, auto_activate: :before_sitemap do
Middleman::CoreExtensions::Data
end
-# Rewrite embedded URLs via Rack
-Middleman::Extensions.register :inline_url_rewriter, auto_activate: :before_sitemap do
- require 'middleman-core/core_extensions/inline_url_rewriter'
- Middleman::CoreExtensions::InlineURLRewriter
-end
-
# Catch and show exceptions at the Rack level
Middleman::Extensions.register :show_exceptions, auto_activate: :before_configuration, modes: [:server] do
require 'middleman-core/core_extensions/show_exceptions'
diff --git a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb
index 6fd16ae9..82df8f73 100644
--- a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb
+++ b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb
@@ -28,7 +28,10 @@ module Middleman
super
# Setup source collection.
- @sources = ::Middleman::Sources.new(app)
+ @sources = ::Middleman::Sources.new(app,
+ disable_watcher: app.config[:watcher_disable],
+ force_polling: app.config[:watcher_force_polling],
+ latency: app.config[:watcher_latency])
# Add default ignores.
IGNORES.each do |key, value|
@@ -52,13 +55,6 @@ module Middleman
# @return [void]
Contract Any
def after_configuration
- @watcher.update_config(
- disable_watcher: app.config[:watcher_disable],
- force_polling: app.config[:watcher_force_polling],
- latency: app.config[:watcher_latency],
- wait_for_delay: app.config[:watcher_wait_for_delay]
- )
-
if @original_source_dir != app.config[:source]
@watcher.update_path(app.config[:source])
end
diff --git a/middleman-core/lib/middleman-core/core_extensions/inline_url_rewriter.rb b/middleman-core/lib/middleman-core/core_extensions/inline_url_rewriter.rb
deleted file mode 100644
index 43354e97..00000000
--- a/middleman-core/lib/middleman-core/core_extensions/inline_url_rewriter.rb
+++ /dev/null
@@ -1,135 +0,0 @@
-require 'rack'
-require 'rack/response'
-require 'memoist'
-require 'middleman-core/util'
-require 'middleman-core/contracts'
-
-module Middleman
- module CoreExtensions
- class InlineURLRewriter < ::Middleman::Extension
- include Contracts
-
- expose_to_application rewrite_inline_urls: :add
-
- REWRITER_DESCRIPTOR = {
- id: Symbol,
- proc: Or[Proc, Method],
- url_extensions: ArrayOf[String],
- source_extensions: ArrayOf[String],
- ignore: ArrayOf[::Middleman::Util::IGNORE_DESCRIPTOR],
- after: Maybe[Symbol]
- }.freeze
-
- def initialize(app, options_hash={}, &block)
- super
-
- @rewriters = {}
- end
-
- Contract REWRITER_DESCRIPTOR => Any
- def add(options)
- @rewriters[options] = options
- end
-
- def after_configuration
- return if @rewriters.empty?
-
- rewriters = @rewriters.values.sort do |a, b|
- if b[:after] && b[:after] == a[:id]
- 1
- else
- 0
- end
- end
-
- app.use Rack, rewriters: rewriters, middleman_app: @app
- end
-
- class Rack
- extend Memoist
- include Contracts
-
- Contract RespondTo[:call], {
- middleman_app: IsA['Middleman::Application'],
- rewriters: ArrayOf[REWRITER_DESCRIPTOR]
- } => Any
- def initialize(app, options={})
- @rack_app = app
- @middleman_app = options.fetch(:middleman_app)
- @rewriters = options.fetch(:rewriters)
-
- all_source_exts = @rewriters
- .reduce([]) { |sum, rewriter| sum + rewriter[:source_extensions] }
- .flatten
- .uniq
- @source_exts_regex_text = Regexp.union(all_source_exts).to_s
-
- @all_asset_exts = @rewriters
- .reduce([]) { |sum, rewriter| sum + rewriter[:url_extensions] }
- .flatten
- .uniq
- end
-
- def call(env)
- status, headers, response = @rack_app.call(env)
-
- # Allow configuration or upstream request to skip all rewriting
- return [status, headers, response] if env['bypass_inline_url_rewriter'] == 'true'
-
- path = ::Middleman::Util.full_path(env['PATH_INFO'], @middleman_app)
-
- return [status, headers, response] unless path =~ /(^\/$)|(#{@source_exts_regex_text}$)/
- return [status, headers, response] unless body = ::Middleman::Util.extract_response_text(response)
-
- dirpath = ::Pathname.new(File.dirname(path))
-
- rewritten = ::Middleman::Util.instrument 'inline_url_rewriter', path: path do
- ::Middleman::Util.rewrite_paths(body, path, @all_asset_exts, @middleman_app) do |asset_path|
- uri = ::Middleman::Util.parse_uri(asset_path)
-
- relative_path = uri.host.nil?
-
- full_asset_path = if relative_path
- dirpath.join(asset_path).to_s
- else
- asset_path
- end
-
- @rewriters.each do |rewriter|
- uid = rewriter.fetch(:id)
-
- # Allow upstream request to skip this specific rewriting
- next if env["bypass_inline_url_rewriter_#{uid}"] == 'true'
-
- exts = rewriter.fetch(:url_extensions)
- next unless exts.include?(::File.extname(asset_path))
-
- source_exts = rewriter.fetch(:source_extensions)
- next unless source_exts.include?(::File.extname(path))
-
- ignore = rewriter.fetch(:ignore)
- next if ignore.any? { |r| ::Middleman::Util.should_ignore?(r, full_asset_path) }
-
- rewrite_ignore = Array(rewriter[:rewrite_ignore] || [])
- next if rewrite_ignore.any? { |i| ::Middleman::Util.path_match(i, path) }
-
- proc = rewriter.fetch(:proc)
-
- result = proc.call(asset_path, dirpath, path)
- asset_path = result if result
- end
-
- asset_path
- end
- end
-
- ::Rack::Response.new(
- rewritten,
- status,
- headers
- ).finish
- end
- end
- end
- end
-end
diff --git a/middleman-core/lib/middleman-core/extension.rb b/middleman-core/lib/middleman-core/extension.rb
index 9805455a..0d1f212d 100644
--- a/middleman-core/lib/middleman-core/extension.rb
+++ b/middleman-core/lib/middleman-core/extension.rb
@@ -60,7 +60,7 @@ module Middleman
# There are also some less common hooks that can be listened to from within an extension's `initialize` method:
#
# * `app.before_render {|body, path, locs, template_class| ... }` - Manipulate template sources before they are rendered.
- # * `app.after_render {|content, path, locs, template_class| ... }` - Manipulate output text after a template has been rendered. It is also common to install a Rack middleware to do this instead.
+ # * `app.after_render {|content, path, locs, template_class| ... }` - Manipulate output text after a template has been rendered.
# * `app.ready { ... }` - Run code once Middleman is ready to serve or build files (after `after_configuration`).
#
diff --git a/middleman-core/lib/middleman-core/extensions/asset_hash.rb b/middleman-core/lib/middleman-core/extensions/asset_hash.rb
index 3e2a02aa..f78eed5e 100644
--- a/middleman-core/lib/middleman-core/extensions/asset_hash.rb
+++ b/middleman-core/lib/middleman-core/extensions/asset_hash.rb
@@ -1,19 +1,15 @@
require 'middleman-core/util'
-require 'middleman-core/rack'
class Middleman::Extensions::AssetHash < ::Middleman::Extension
- option :sources, %w(.css .htm .html .js .php .xhtml), 'List of extensions that are searched for hashable assets.'
- option :exts, nil, 'List of extensions that get asset hashes appended to them.'
+ option :sources, %w(.css .htm .html .js .php .xhtml), 'List of extensions that are searched for hashable assets.', set: true
+ option :exts, nil, 'List of extensions that get asset hashes appended to them.', set: true
option :ignore, [], 'Regexes of filenames to skip adding asset hashes to'
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for path rewrites'
- option :prefix, '', 'Prefix for hash'
def initialize(app, options_hash={}, &block)
super
- require 'addressable/uri'
require 'digest/sha1'
- require 'rack/mock'
# Allow specifying regexes to ignore, plus always ignore apple touch icons
@ignore = Array(options.ignore) + [/^apple-touch-icon/]
@@ -21,14 +17,6 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
# Exclude .ico from the default list because browsers expect it
# to be named "favicon.ico"
@exts = options.exts || (app.config[:asset_extensions] - %w(.ico))
-
- app.rewrite_inline_urls id: :asset_hash,
- url_extensions: @exts.sort.reverse,
- source_extensions: options.sources,
- ignore: @ignore,
- rewrite_ignore: options.rewrite_ignore,
- proc: method(:rewrite_url),
- after: :asset_host
end
Contract String, Or[String, Pathname], Any => Maybe[String]
@@ -46,7 +34,6 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
replacement_path = "/#{asset_page.destination_path}"
replacement_path = Pathname.new(replacement_path).relative_path_from(dirpath).to_s if relative_path
-
replacement_path
end
@@ -54,9 +41,18 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
# @return Array
Contract ResourceList => ResourceList
def manipulate_resource_list(resources)
- @rack_client ||= begin
- rack_app = ::Middleman::Rack.new(app).to_app
- ::Rack::MockRequest.new(rack_app)
+ resources.each do |r|
+ next unless r.destination_path.end_with?('/', *options.sources)
+ next if Array(options.rewrite_ignore || []).any? do |i|
+ ::Middleman::Util.path_match(i, "/#{r.destination_path}")
+ end
+
+ r.filters << ::Middleman::InlineURLRewriter.new(:asset_hash,
+ app,
+ r,
+ url_extensions: @exts,
+ ignore: options.ignore,
+ proc: method(:rewrite_url))
end
# Process resources in order: binary images and fonts, then SVG, then JS/CSS.
@@ -82,18 +78,12 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
digest = if resource.binary?
::Digest::SHA1.file(resource.source_file).hexdigest[0..7]
else
- # Render through the Rack interface so middleware and mounted apps get a shot
- response = @rack_client.get(
- ::URI.escape(resource.destination_path),
- 'bypass_inline_url_rewriter_asset_hash' => 'true'
- )
-
- raise "#{resource.path} should be in the sitemap!" unless response.status == 200
-
- ::Digest::SHA1.hexdigest(response.body)[0..7]
+ # Render without asset hash
+ body = resource.render { |f| !f.respond_to?(:filter_name) || f.filter_name != :asset_hash }
+ ::Digest::SHA1.hexdigest(body)[0..7]
end
- resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{options.prefix}#{digest}#{ext}" }
+ resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{digest}#{ext}" }
resource
end
diff --git a/middleman-core/lib/middleman-core/extensions/asset_host.rb b/middleman-core/lib/middleman-core/extensions/asset_host.rb
index 7cb83d07..b076299d 100644
--- a/middleman-core/lib/middleman-core/extensions/asset_host.rb
+++ b/middleman-core/lib/middleman-core/extensions/asset_host.rb
@@ -1,5 +1,3 @@
-require 'addressable/uri'
-
class Middleman::Extensions::AssetHost < ::Middleman::Extension
option :host, nil, 'The asset host to use or a Proc to determine asset host', required: true
option :exts, nil, 'List of extensions that get cache busters strings appended to them.'
@@ -7,15 +5,22 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for host rewrites'
- def initialize(app, options_hash={}, &block)
- super
+ Contract ResourceList => ResourceList
+ def manipulate_resource_list(resources)
+ resources.each do |r|
+ next unless r.destination_path.end_with?('/', *options.sources)
+ next if Array(options.rewrite_ignore || []).any? do |i|
+ ::Middleman::Util.path_match(i, "/#{r.destination_path}")
+ end
- app.rewrite_inline_urls id: :asset_host,
- url_extensions: options.exts || app.config[:asset_extensions],
- source_extensions: options.sources,
- ignore: options.ignore,
- rewrite_ignore: options.rewrite_ignore,
- proc: method(:rewrite_url)
+ r.filters << ::Middleman::InlineURLRewriter.new(:asset_host,
+ app,
+ r,
+ after_filter: :asset_hash,
+ url_extensions: options.exts || app.config[:asset_extensions],
+ ignore: options.ignore,
+ proc: method(:rewrite_url))
+ end
end
Contract String, Or[String, Pathname], Any => String
diff --git a/middleman-core/lib/middleman-core/extensions/cache_buster.rb b/middleman-core/lib/middleman-core/extensions/cache_buster.rb
index 2de11632..ea723a81 100644
--- a/middleman-core/lib/middleman-core/extensions/cache_buster.rb
+++ b/middleman-core/lib/middleman-core/extensions/cache_buster.rb
@@ -1,19 +1,25 @@
# The Cache Buster extension
class Middleman::Extensions::CacheBuster < ::Middleman::Extension
- option :exts, nil, 'List of extensions that get cache busters strings appended to them.'
- option :sources, %w(.css .htm .html .js .php .xhtml), 'List of extensions that are searched for bustable assets.'
+ option :exts, nil, 'List of extensions that get cache busters strings appended to them.', set: true
+ option :sources, %w(.css .htm .html .js .php .xhtml), 'List of extensions that are searched for bustable assets.', set: true
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for path rewrites'
- def initialize(app, options_hash={}, &block)
- super
+ Contract ResourceList => ResourceList
+ def manipulate_resource_list(resources)
+ resources.each do |r|
+ next unless r.destination_path.end_with?('/', *options.sources)
+ next if Array(options.rewrite_ignore || []).any? do |i|
+ ::Middleman::Util.path_match(i, "/#{r.destination_path}")
+ end
- app.rewrite_inline_urls id: :cache_buster,
- url_extensions: options.exts || app.config[:asset_extensions],
- source_extensions: options.sources,
- ignore: options.ignore,
- rewrite_ignore: options.rewrite_ignore,
- proc: method(:rewrite_url)
+ r.filters << ::Middleman::InlineURLRewriter.new(:cache_buster,
+ app,
+ r,
+ url_extensions: options.exts || app.config[:asset_extensions],
+ ignore: options.ignore,
+ proc: method(:rewrite_url))
+ end
end
Contract String, Or[String, Pathname], Any => String
diff --git a/middleman-core/lib/middleman-core/extensions/directory_indexes.rb b/middleman-core/lib/middleman-core/extensions/directory_indexes.rb
index cef88868..3bc340ee 100644
--- a/middleman-core/lib/middleman-core/extensions/directory_indexes.rb
+++ b/middleman-core/lib/middleman-core/extensions/directory_indexes.rb
@@ -1,3 +1,5 @@
+require 'set'
+
# Directory Indexes extension
class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension
# This should run after most other sitemap manipulators so that it
@@ -11,7 +13,7 @@ class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension
index_file = app.config[:index_file]
new_index_path = "/#{index_file}"
- extensions = %w(.htm .html .php .xhtml)
+ extensions = Set.new(%w(.htm .html .php .xhtml))
resources.each do |resource|
# Check if it would be pointless to reroute
diff --git a/middleman-core/lib/middleman-core/extensions/gzip.rb b/middleman-core/lib/middleman-core/extensions/gzip.rb
index 0483fe32..a633f78f 100644
--- a/middleman-core/lib/middleman-core/extensions/gzip.rb
+++ b/middleman-core/lib/middleman-core/extensions/gzip.rb
@@ -10,7 +10,7 @@
# to .css, .htm, .html, .js, and .xhtml
#
class Middleman::Extensions::Gzip < ::Middleman::Extension
- option :exts, %w(.css .htm .html .js .svg .xhtml), 'File extensions to Gzip when building.'
+ option :exts, %w(.css .htm .html .js .svg .xhtml), 'File extensions to Gzip when building.', set: true
option :ignore, [], 'Patterns to avoid gzipping'
option :overwrite, false, 'Overwrite original files instead of adding .gz extension.'
diff --git a/middleman-core/lib/middleman-core/extensions/minify_css.rb b/middleman-core/lib/middleman-core/extensions/minify_css.rb
index aca9c60b..9174322f 100644
--- a/middleman-core/lib/middleman-core/extensions/minify_css.rb
+++ b/middleman-core/lib/middleman-core/extensions/minify_css.rb
@@ -1,6 +1,5 @@
-require 'active_support/core_ext/object/try'
-require 'memoist'
require 'middleman-core/contracts'
+require 'rack/mime'
# Minify CSS Extension
class Middleman::Extensions::MinifyCss < ::Middleman::Extension
@@ -10,17 +9,10 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
require 'sass'
SassCompressor
}, 'Set the CSS compressor to use.'
- option :content_types, %w(text/css), 'Content types of resources that contain CSS'
- option :inline_content_types, %w(text/html text/php), 'Content types of resources that contain inline CSS'
+ option :content_types, %w(text/css), 'Content types of resources that contain CSS', set: true
+ option :inline_content_types, %w(text/html text/php), 'Content types of resources that contain inline CSS', set: true
- def ready
- # Setup Rack middleware to minify CSS
- app.use Rack, compressor: options[:compressor],
- ignore: Array(options[:ignore]) + [/\.min\./],
- inline: options[:inline],
- content_types: options[:content_types],
- inline_content_types: options[:inline_content_types]
- end
+ INLINE_CSS_REGEX = /(