diff --git a/.rubocop.yml b/.rubocop.yml
index dbd74993..c92b709f 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -67,3 +67,5 @@ Style/MultilineBlockChain:
Enabled: false
Style/SpecialGlobalVars:
Enabled: false
+Style/FrozenStringLiteralComment:
+ Enabled: false
diff --git a/.travis.yml b/.travis.yml
index 42c2903d..ac5a7f06 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,17 +5,14 @@ before_script:
- bundle update
rvm:
- ruby-head
- - 2.3.0
+ - 2.3.1
- 2.2.4
- - 2.1
- - 2.0
os:
- linux
# - osx
matrix:
fast_finish: true
allow_failures:
- - rvm: 2.3.0
- rvm: ruby-head
env:
global:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f81321ad..148aa2e2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,42 @@
master
===
+# 4.1.13
+
+* 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)
+
+# 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
* Upgrade fastimage to 2.0
diff --git a/Gemfile b/Gemfile
index f14eb3b1..db4043a0 100644
--- a/Gemfile
+++ b/Gemfile
@@ -9,6 +9,12 @@ 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
@@ -18,7 +24,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', '>= 1.4', require: false
+gem 'sinatra', '>= 2.0.0.beta2', require: false
gem 'redcarpet', '>= 3.1', require: false
# Dns server to test preview server
@@ -26,7 +32,7 @@ gem 'rubydns', '~> 1.0.1', require: false
# To test javascript
gem 'poltergeist', '~> 1.8', require: false
-gem 'phantomjs', '~> 1.9.8.0', require: false
+gem 'phantomjs', '~> 2.1.1.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
new file mode 100644
index 00000000..6d2dc0e0
--- /dev/null
+++ b/ISSUE_TEMPLATE.md
@@ -0,0 +1,9 @@
+## 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/README.md b/README.md
index 55b81cc1..df4497f7 100644
--- a/README.md
+++ b/README.md
@@ -121,6 +121,6 @@ Copyright (c) 2010-2015 Thomas Reynolds. MIT Licensed, see [LICENSE] for details
[codeclimate]: https://codeclimate.com/github/middleman/middleman
[gittip]: https://www.gittip.com/middleman/
[rubyinstaller]: http://rubyinstaller.org/
-[RubyInstaller-Devkit]: http:rubyinstaller.org/add-ons/devkit/
+[RubyInstaller-Devkit]: http://rubyinstaller.org/add-ons/devkit/
[rubydoc]: http://rubydoc.info/github/middleman/middleman
[LICENSE]: https://github.com/middleman/middleman/blob/master/LICENSE.md
diff --git a/middleman-cli/bin/middleman b/middleman-cli/bin/middleman
index b5d1921d..8b381a08 100755
--- a/middleman-cli/bin/middleman
+++ b/middleman-cli/bin/middleman
@@ -9,6 +9,9 @@ end
require "middleman-core/load_paths"
Middleman.setup_load_paths
+require 'dotenv'
+::Dotenv.load
+
require 'middleman-core'
require 'middleman-core/logger'
@@ -22,12 +25,10 @@ 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
@@ -46,6 +47,8 @@ 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 7d5dd3af..9e521dde 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: :production
+ default: ENV['MM_ENV'] || ENV['RACK_ENV'] || :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: :string,
+ type: :boolean,
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 unless v == :undefined
+ sum[k] = v
end
end
diff --git a/middleman-cli/lib/middleman-cli/init.rb b/middleman-cli/lib/middleman-cli/init.rb
index f1c1927e..e8e5770c 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 : "git://github.com/#{repo}.git"
+ repo.include?('://') || repo.include?('git@') ? repo : "https://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 479f53bd..85e75a9f 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: :string,
+ type: :boolean,
default: false,
desc: 'Print instrument messages'
class_option :profile,
diff --git a/middleman-cli/middleman-cli.gemspec b/middleman-cli/middleman-cli.gemspec
index f2719efc..e9447a9c 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.0.0'
+ s.required_ruby_version = '>= 2.2.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 19517e3b..7c173800 100644
--- a/middleman-core/features/asset_hash.feature
+++ b/middleman-core/features/asset_hash.feature
@@ -308,3 +308,17 @@ 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 646f1154..0433b61b 100644
--- a/middleman-core/features/asset_host.feature
+++ b/middleman-core/features/asset_host.feature
@@ -25,7 +25,8 @@ Feature: Alternate between multiple asset hosts
And a file named "config.rb" with:
"""
activate :asset_host, host: Proc.new { |asset|
- "http://assets%d.example.com" % (asset.hash % 4)
+ hash = Digest::MD5.digest(asset).bytes.map!(&:ord).reduce(&:+)
+ "http://assets%d.example.com" % (hash % 4)
}
"""
And the Server is running
diff --git a/middleman-core/features/collections.feature b/middleman-core/features/collections.feature
index e12ca0a5..2d313a3c 100644
--- a/middleman-core/features/collections.feature
+++ b/middleman-core/features/collections.feature
@@ -144,6 +144,33 @@ Feature: Collections
And I should see 'Article: Blog3 Another Article'
And I should see 'Article: Blog2 Yet Another Article'
+ Scenario: Work with local helpers
+ Given a fixture app "collections-app"
+ And a file named "config.rb" with:
+ """
+ module TestHelper
+ def help_me
+ "ok"
+ end
+ end
+
+ include TestHelper
+
+ data.articles.each_with_index do |a, i|
+ proxy "/#{i}-#{help_me}.html", a
+ end
+ """
+ And a file named "data/articles.yaml" with:
+ """
+ ---
+ - "/blog1/2011-01-01-new-article.html"
+ - "/blog2/2011-01-02-another-article.html"
+ """
+ Given the Server is running at "collections-app"
+ When I go to "0-ok.html"
+ Then I should see 'Newer Article Content'
+ When I go to "1-ok.html"
+ Then I should see 'Another Article Content'
Scenario: Collected data update with file changes
Given a fixture app "collections-app"
diff --git a/middleman-core/features/helpers_link_to.feature b/middleman-core/features/helpers_link_to.feature
index 90b6f08a..fe8e8530 100644
--- a/middleman-core/features/helpers_link_to.feature
+++ b/middleman-core/features/helpers_link_to.feature
@@ -40,19 +40,29 @@ 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"
@@ -113,7 +123,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 a10787c4..9d3f0682 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
new file mode 100644
index 00000000..250c6857
--- /dev/null
+++ b/middleman-core/features/markdown_redcarpet_in_slim.feature
@@ -0,0 +1,41 @@
+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/page-id.feature b/middleman-core/features/page-id.feature
index 63dd6fad..74d08cb5 100644
--- a/middleman-core/features/page-id.feature
+++ b/middleman-core/features/page-id.feature
@@ -3,14 +3,60 @@ 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.html"
+ Then I should see "I am: index"
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 ea6cbff0..ba131396 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 '
'
+ Then I should see '
")
+ h2
+ background: url("<%= asset_url('/images/blank2.gif') %>")
+ """
+ And a file named "source/javascripts/application.js.erb" with:
+ """
+ function foo() {
+ var img = document.createElement('img');
+ img.src = '<%= asset_url("images/100px.jpg") %>';
+ var body = document.getElementsByTagName('body')[0];
+ body.insertBefore(img, body.firstChild);
+ }
+
+ window.onload = foo;
+ """
+ And a file named "source/stylesheets/fonts3.css.erb" with:
+ """
+ @font-face {
+ font-family: 'Roboto2';
+ src: url(<%= asset_url("/fonts/roboto/roboto-regular-webfont.eot") %>);
+ src: url(<%= asset_url("/fonts/roboto/roboto-regular-webfont.eot?#iefix") %>) format('embedded-opentype'),
+ url(<%= asset_url("/fonts/roboto/roboto-regular-webfont.woff") %>) format('woff'),
+ url(<%= asset_url("/fonts/roboto/roboto-regular-webfont.ttf") %>) format('truetype'),
+ url(<%= asset_url("/fonts/roboto/roboto-regular-webfont.svg#robotoregular") %>) format('svg');
+ font-weight: normal;
+ font-style: normal;
+ }
+ """
+ And the Server is running at "relative-assets-app"
+ When I go to "/stylesheets/relative_assets.css"
+ Then I should see 'url("../images/blank.gif'
+ And I should see 'url("../images/blank2.gif'
+ When I go to "/javascripts/application.js"
+ Then I should not see "../"
+ When I go to "/stylesheets/fonts3.css"
+ Then I should see 'url(../fonts/roboto/roboto-regular-webfont.eot'
+ And I should see 'url(../fonts/roboto/roboto-regular-webfont.woff'
+ And I should see 'url(../fonts/roboto/roboto-regular-webfont.ttf'
+ And I should see 'url(../fonts/roboto/roboto-regular-webfont.svg'
+
+ Scenario: Relative css reference with directory indexes
+ Given a fixture app "relative-assets-app"
+ And a file named "config.rb" with:
+ """
+ activate :directory_indexes
+ activate :relative_assets, helpers_only: true
+ """
+ And the Server is running at "relative-assets-app"
+ When I go to "/relative_image/index.html"
+ Then I should see "../stylesheets/relative_assets.css"
+
+ Scenario: Relative assets via image_tag
+ Given a fixture app "relative-assets-app"
+ And a file named "config.rb" with:
+ """
+ activate :relative_assets, helpers_only: true
+ """
+ And a file named "source/sub/image_tag.html.erb" with:
+ """
+ <%= image_tag '/img/blank.gif' %>
+ """
+ And the Server is running at "relative-assets-app"
+ When I go to "/sub/image_tag.html"
+ Then I should see '
+ """
+ And the Server is running at "relative-assets-app"
+ When I go to "/sub/image_tag.html"
+ Then I should see '
'
+
+ Scenario: URLs are not rewritten for rewrite ignored paths
+ Given a fixture app "relative-assets-app"
+ And a file named "config.rb" with:
+ """
+ activate :relative_assets, rewrite_ignore: [
+ '/stylesheets/fonts3.css',
+ ], helpers_only: true
+ """
+ And a file named "source/stylesheets/relative_assets.css.sass.erb" with:
+ """
+ h1
+ background: url("<%= asset_url('images/blank.gif') %>")
+ h2
+ background: url("<%= asset_url('/images/blank2.gif') %>")
+ """
+ And a file named "source/stylesheets/fonts3.css.erb" with:
+ """
+ @font-face {
+ font-family: 'Roboto2';
+ src: url(<%= asset_url("/fonts/roboto/roboto-regular-webfont.eot") %>);
+ src: url(<%= asset_url("/fonts/roboto/roboto-regular-webfont.eot?#iefix") %>) format('embedded-opentype'),
+ url(<%= asset_url("/fonts/roboto/roboto-regular-webfont.woff") %>) format('woff'),
+ url(<%= asset_url("/fonts/roboto/roboto-regular-webfont.ttf") %>) format('truetype'),
+ url(<%= asset_url("/fonts/roboto/roboto-regular-webfont.svg#robotoregular") %>) format('svg');
+ font-weight: normal;
+ font-style: normal;
+ }
+ """
+ And the Server is running at "relative-assets-app"
+ When I go to "/stylesheets/relative_assets.css"
+ Then I should see 'url("../images/blank.gif'
+ When I go to "/stylesheets/fonts3.css"
+ Then I should see 'url(/fonts/roboto/roboto-regular-webfont.eot'
diff --git a/middleman-core/features/sass_in_slim.feature b/middleman-core/features/sass_in_slim.feature
new file mode 100644
index 00000000..d04055e4
--- /dev/null
+++ b/middleman-core/features/sass_in_slim.feature
@@ -0,0 +1,40 @@
+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/features/template-key-collision.feature b/middleman-core/features/template-key-collision.feature
new file mode 100644
index 00000000..9e530dc1
--- /dev/null
+++ b/middleman-core/features/template-key-collision.feature
@@ -0,0 +1,26 @@
+Feature: Don't allow template locals to overwrite template helpers
+
+ Scenario: Normal Template
+ Given an empty app
+ And a file named "config.rb" with:
+ """
+ class TestExt < ::Middleman::Extension
+ expose_to_template foo: :foo
+
+ def foo
+ "bar"
+ end
+ end
+
+ ::Middleman::Extensions.register :test, TestExt
+
+ activate :test
+
+ page "/index.html", locals: { foo: false }
+ """
+ And a file named "source/index.html.erb" with:
+ """
+ <%= foo %>
+ """
+ Given a built app at "empty_app"
+ Then the exit status should be 1
diff --git a/middleman-core/fixtures/asset-hash-prefix/config.rb b/middleman-core/fixtures/asset-hash-prefix/config.rb
new file mode 100644
index 00000000..449a2e98
--- /dev/null
+++ b/middleman-core/fixtures/asset-hash-prefix/config.rb
@@ -0,0 +1,7 @@
+
+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
new file mode 100644
index 00000000..8ee825fd
--- /dev/null
+++ b/middleman-core/fixtures/asset-hash-prefix/lib/middleware.rb
@@ -0,0 +1,16 @@
+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
new file mode 100644
index 00000000..a88cc13f
--- /dev/null
+++ b/middleman-core/fixtures/asset-hash-prefix/source/index.html.erb
@@ -0,0 +1,6 @@
+<% 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
new file mode 100644
index 00000000..c72f8572
--- /dev/null
+++ b/middleman-core/fixtures/asset-hash-prefix/source/javascripts/application.js
@@ -0,0 +1,2 @@
+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
new file mode 100644
index 00000000..6a5acd5c
--- /dev/null
+++ b/middleman-core/fixtures/asset-hash-prefix/source/javascripts/application.js.map
@@ -0,0 +1 @@
+{"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
new file mode 100644
index 00000000..c8aacecf
--- /dev/null
+++ b/middleman-core/fixtures/asset-hash-prefix/source/layout.erb
@@ -0,0 +1,17 @@
+
+
+
+
+
+ <%= javascript_include_tag "application" %>
+ <%= yield_content :head %>
+
+
+
+
+
+ <%= yield %>
+
+
+
+
diff --git a/middleman-core/fixtures/page-id-app/config-proc.rb b/middleman-core/fixtures/page-id-app/config-proc.rb
new file mode 100644
index 00000000..03070f0e
--- /dev/null
+++ b/middleman-core/fixtures/page-id-app/config-proc.rb
@@ -0,0 +1,7 @@
+%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
new file mode 100644
index 00000000..a27800bd
--- /dev/null
+++ b/middleman-core/fixtures/page-id-app/source/feed.xml.erb
@@ -0,0 +1 @@
+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
new file mode 100644
index 00000000..a27800bd
--- /dev/null
+++ b/middleman-core/fixtures/page-id-app/source/folder/foldern.html.erb
@@ -0,0 +1 @@
+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
new file mode 100644
index 00000000..a27800bd
--- /dev/null
+++ b/middleman-core/fixtures/page-id-app/source/implicit.html.erb
@@ -0,0 +1 @@
+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 8f2997b6..6060bc3f 100644
--- a/middleman-core/fixtures/page-id-app/source/index.html.erb
+++ b/middleman-core/fixtures/page-id-app/source/index.html.erb
@@ -4,3 +4,11 @@ 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/relative-assets-app/source/images/blank2.gif b/middleman-core/fixtures/relative-assets-app/source/images/blank2.gif
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/fixtures/sass-in-slim-app/config.rb b/middleman-core/fixtures/sass-in-slim-app/config.rb
new file mode 100644
index 00000000..e69de29b
diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb
index 379d1e81..52b31c92 100644
--- a/middleman-core/lib/middleman-core/application.rb
+++ b/middleman-core/lib/middleman-core/application.rb
@@ -203,6 +203,7 @@ 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
@@ -266,6 +267,8 @@ 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
@@ -276,8 +279,6 @@ 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)
@@ -344,11 +345,11 @@ module Middleman
# Clean up missing Tilt exts
def prune_tilt_templates!
- ::Tilt.mappings.each_key do |key|
+ ::Tilt.default_mapping.lazy_map.each_key do |key|
begin
::Tilt[".#{key}"]
rescue LoadError, NameError
- ::Tilt.mappings.delete(key)
+ ::Tilt.default_mapping.lazy_map.delete(key)
end
end
end
diff --git a/middleman-core/lib/middleman-core/config_context.rb b/middleman-core/lib/middleman-core/config_context.rb
index d140e8ea..3ee98632 100644
--- a/middleman-core/lib/middleman-core/config_context.rb
+++ b/middleman-core/lib/middleman-core/config_context.rb
@@ -8,7 +8,7 @@ module Middleman
attr_reader :app
# Whitelist methods that can reach out.
- def_delegators :@app, :config, :logger, :use, :map, :mime_type, :files, :root, :build?, :server?, :environment?
+ def_delegators :@app, :config, :logger, :use, :map, :mime_type, :files, :root, :build?, :server?, :environment?, :extensions
def_delegator :"@app.extensions", :activate
def initialize(app, template_context_class)
@@ -23,7 +23,7 @@ module Middleman
end
def include(mod)
- self.extend(mod)
+ extend(mod)
end
def helpers(*helper_modules, &block)
diff --git a/middleman-core/lib/middleman-core/core_extensions/collections.rb b/middleman-core/lib/middleman-core/core_extensions/collections.rb
index 22e6d281..b915fffd 100644
--- a/middleman-core/lib/middleman-core/core_extensions/collections.rb
+++ b/middleman-core/lib/middleman-core/core_extensions/collections.rb
@@ -90,7 +90,7 @@ module Middleman
pair[:root].realize!(dataset)
end
- ctx = StepContext.new
+ ctx = StepContext.new(app)
StepContext.current = ctx
leaves = @leaves.dup
diff --git a/middleman-core/lib/middleman-core/core_extensions/collections/step_context.rb b/middleman-core/lib/middleman-core/core_extensions/collections/step_context.rb
index 0b17870d..0549b826 100644
--- a/middleman-core/lib/middleman-core/core_extensions/collections/step_context.rb
+++ b/middleman-core/lib/middleman-core/core_extensions/collections/step_context.rb
@@ -12,17 +12,20 @@ module Middleman
attr_reader :descriptors
- def initialize
+ def initialize(app)
+ @app = app
@descriptors = []
end
def method_missing(name, *args, &block)
internal = :"_internal_#{name}"
- return super unless respond_to?(internal)
-
- send(internal, *args, &block).tap do |r|
- @descriptors << r if r.respond_to?(:execute_descriptor)
+ if respond_to?(internal)
+ send(internal, *args, &block).tap do |r|
+ @descriptors << r if r.respond_to?(:execute_descriptor)
+ end
+ else
+ @app.config_context.send(name, *args, &block)
end
end
end
diff --git a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb
index 33b411e1..774522db 100644
--- a/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb
+++ b/middleman-core/lib/middleman-core/core_extensions/default_helpers.rb
@@ -1,4 +1,5 @@
require 'padrino-helpers'
+require 'middleman-core/contracts'
# Don't fail on invalid locale, that's not what our current
# users expect.
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 82df8f73..6fd16ae9 100644
--- a/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb
+++ b/middleman-core/lib/middleman-core/core_extensions/file_watcher.rb
@@ -28,10 +28,7 @@ module Middleman
super
# Setup source collection.
- @sources = ::Middleman::Sources.new(app,
- disable_watcher: app.config[:watcher_disable],
- force_polling: app.config[:watcher_force_polling],
- latency: app.config[:watcher_latency])
+ @sources = ::Middleman::Sources.new(app)
# Add default ignores.
IGNORES.each do |key, value|
@@ -55,6 +52,13 @@ 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/front_matter.rb b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb
index 49f4195f..0f69c634 100644
--- a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb
+++ b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb
@@ -73,18 +73,20 @@ module Middleman::CoreExtensions
return [{}, nil] unless file
- return @cache[file[:full_path]] if @cache.key?(file[:full_path])
+ file_path = file[:full_path].to_s
- @cache[file[:full_path]] = ::Middleman::Util::Data.parse(
- file,
- app.config[:frontmatter_delims]
- )
+ @cache[file_path] ||= begin
+ ::Middleman::Util::Data.parse(
+ file,
+ app.config[:frontmatter_delims]
+ )
+ end
end
Contract ArrayOf[IsA['Middleman::SourceFile']], ArrayOf[IsA['Middleman::SourceFile']] => Any
def clear_data(updated_files, removed_files)
(updated_files + removed_files).each do |file|
- @cache.delete(file[:full_path])
+ @cache.delete(file[:full_path].to_s)
end
end
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
index 14cf4715..43354e97 100644
--- a/middleman-core/lib/middleman-core/core_extensions/inline_url_rewriter.rb
+++ b/middleman-core/lib/middleman-core/core_extensions/inline_url_rewriter.rb
@@ -1,6 +1,6 @@
require 'rack'
require 'rack/response'
-require 'addressable/uri'
+require 'memoist'
require 'middleman-core/util'
require 'middleman-core/contracts'
@@ -11,13 +11,12 @@ module Middleman
expose_to_application rewrite_inline_urls: :add
- IGNORE_DESCRIPTOR = Or[Regexp, RespondTo[:call], String]
REWRITER_DESCRIPTOR = {
id: Symbol,
proc: Or[Proc, Method],
url_extensions: ArrayOf[String],
source_extensions: ArrayOf[String],
- ignore: ArrayOf[IGNORE_DESCRIPTOR],
+ ignore: ArrayOf[::Middleman::Util::IGNORE_DESCRIPTOR],
after: Maybe[Symbol]
}.freeze
@@ -33,6 +32,8 @@ module Middleman
end
def after_configuration
+ return if @rewriters.empty?
+
rewriters = @rewriters.values.sort do |a, b|
if b[:after] && b[:after] == a[:id]
1
@@ -45,6 +46,7 @@ module Middleman
end
class Rack
+ extend Memoist
include Contracts
Contract RespondTo[:call], {
@@ -55,6 +57,17 @@ module Middleman
@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)
@@ -63,27 +76,16 @@ module Middleman
# Allow configuration or upstream request to skip all rewriting
return [status, headers, response] if env['bypass_inline_url_rewriter'] == 'true'
- 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
-
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 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 = ::Addressable::URI.parse(asset_path)
+ ::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?
@@ -106,7 +108,7 @@ module Middleman
next unless source_exts.include?(::File.extname(path))
ignore = rewriter.fetch(:ignore)
- next if ignore.any? { |r| should_ignore?(r, full_asset_path) }
+ 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) }
@@ -127,23 +129,6 @@ module Middleman
headers
).finish
end
-
- Contract IGNORE_DESCRIPTOR, String => Bool
- def should_ignore?(validator, value)
- if validator.is_a? Regexp
- # Treat as Regexp
- !!(value =~ validator)
- elsif validator.respond_to? :call
- # Treat as proc
- validator.call(value)
- elsif validator.is_a? String
- # Treat as glob
- File.fnmatch(value, validator)
- else
- # If some unknown thing, don't ignore
- false
- end
- end
end
end
end
diff --git a/middleman-core/lib/middleman-core/extension.rb b/middleman-core/lib/middleman-core/extension.rb
index 8f342e69..9805455a 100644
--- a/middleman-core/lib/middleman-core/extension.rb
+++ b/middleman-core/lib/middleman-core/extension.rb
@@ -1,4 +1,5 @@
require 'forwardable'
+require 'memoist'
require 'active_support/core_ext/class/attribute'
require 'middleman-core/configuration'
require 'middleman-core/contracts'
@@ -66,6 +67,8 @@ module Middleman
# @see http://middlemanapp.com/advanced/custom/ Middleman Custom Extensions Documentation
class Extension
extend Forwardable
+ extend Memoist
+
include Contracts
def_delegator :@app, :logger
@@ -510,7 +513,7 @@ module Middleman
self.class.exposed_to_config.each do |k, v|
::Middleman::CoreExtensions::Collections::StepContext.add_to_context(k) do |*args, &b|
r = context.method(:"__original_#{v}").call(*args, &b)
- self.descriptors << r if r.respond_to?(:execute_descriptor)
+ descriptors << r if r.respond_to?(:execute_descriptor)
end
end
end
diff --git a/middleman-core/lib/middleman-core/extensions/asset_hash.rb b/middleman-core/lib/middleman-core/extensions/asset_hash.rb
index b38bab9f..3e2a02aa 100644
--- a/middleman-core/lib/middleman-core/extensions/asset_hash.rb
+++ b/middleman-core/lib/middleman-core/extensions/asset_hash.rb
@@ -6,6 +6,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
option :exts, nil, 'List of extensions that get asset hashes appended to them.'
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
@@ -32,7 +33,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
Contract String, Or[String, Pathname], Any => Maybe[String]
def rewrite_url(asset_path, dirpath, _request_path)
- uri = ::Addressable::URI.parse(asset_path)
+ uri = ::Middleman::Util.parse_uri(asset_path)
relative_path = !uri.path.start_with?('/')
full_asset_path = if relative_path
@@ -92,7 +93,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
::Digest::SHA1.hexdigest(response.body)[0..7]
end
- resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{digest}#{ext}" }
+ resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{options.prefix}#{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 f7c7e8fc..7cb83d07 100644
--- a/middleman-core/lib/middleman-core/extensions/asset_host.rb
+++ b/middleman-core/lib/middleman-core/extensions/asset_host.rb
@@ -20,7 +20,7 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
Contract String, Or[String, Pathname], Any => String
def rewrite_url(asset_path, dirpath, _request_path)
- uri = ::Addressable::URI.parse(asset_path)
+ uri = ::Middleman::Util.parse_uri(asset_path)
relative_path = uri.path[0..0] != '/'
full_asset_path = if relative_path
@@ -37,4 +37,5 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
File.join(asset_prefix, full_asset_path)
end
+ memoize :rewrite_url
end
diff --git a/middleman-core/lib/middleman-core/extensions/minify_css.rb b/middleman-core/lib/middleman-core/extensions/minify_css.rb
index cc513b6c..aca9c60b 100644
--- a/middleman-core/lib/middleman-core/extensions/minify_css.rb
+++ b/middleman-core/lib/middleman-core/extensions/minify_css.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/object/try'
+require 'memoist'
require 'middleman-core/contracts'
# Minify CSS Extension
@@ -30,6 +32,7 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
# Rack middleware to look for CSS and compress it
class Rack
+ extend Memoist
include Contracts
INLINE_CSS_REGEX = /(