merge v3
This commit is contained in:
commit
d8e8b06cb6
|
@ -41,6 +41,8 @@ AssignmentInCondition:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
CyclomaticComplexity:
|
CyclomaticComplexity:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
AbcSize:
|
||||||
|
Enabled: false
|
||||||
HandleExceptions:
|
HandleExceptions:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
EndAlignment:
|
EndAlignment:
|
||||||
|
|
|
@ -5,6 +5,10 @@ before_install: git submodule update --init --recursive
|
||||||
rvm:
|
rvm:
|
||||||
- ruby-head
|
- ruby-head
|
||||||
- jruby-19mode
|
- jruby-19mode
|
||||||
|
- 2.2
|
||||||
|
- 2.1.5
|
||||||
|
- 2.1.4
|
||||||
|
- 2.1.3
|
||||||
- 2.1.2
|
- 2.1.2
|
||||||
- 2.1.1
|
- 2.1.1
|
||||||
- 2.1.0
|
- 2.1.0
|
||||||
|
|
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -29,6 +29,23 @@ master
|
||||||
* Remove old module-style extension support
|
* Remove old module-style extension support
|
||||||
* Placed all `config.rb` evaluation inside the `ConfigContext` class
|
* Placed all `config.rb` evaluation inside the `ConfigContext` class
|
||||||
|
|
||||||
|
3.3.7
|
||||||
|
===
|
||||||
|
* Update new project template Gemfile to use HTTPS by default. #1372
|
||||||
|
|
||||||
|
3.3.6
|
||||||
|
===
|
||||||
|
|
||||||
|
* Use full paths instead of relative for `listen` gem. Fixes #1374
|
||||||
|
* Add force option to "middleman init". #1369
|
||||||
|
* Configuration addition for compass 1 compatibility.
|
||||||
|
* Catch File read exceptions in frontmatter.
|
||||||
|
* Remove duplicate attr_accessor. Closes #1352
|
||||||
|
* Update sass dependency to >= 3.4.0.
|
||||||
|
* Update compass dependency to >= 1.0.0, < 2.0.0
|
||||||
|
* Accept pandoc-style YAML frontmatter. #1350
|
||||||
|
* Add webp to image type lists.
|
||||||
|
|
||||||
3.3.5
|
3.3.5
|
||||||
===
|
===
|
||||||
|
|
||||||
|
|
2
Rakefile
2
Rakefile
|
@ -43,6 +43,8 @@ end
|
||||||
|
|
||||||
desc 'Run tests for all middleman gems'
|
desc 'Run tests for all middleman gems'
|
||||||
task :test do
|
task :test do
|
||||||
|
Rake::Task['rubocop'].invoke
|
||||||
|
|
||||||
GEM_PATHS.each do |g|
|
GEM_PATHS.each do |g|
|
||||||
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake test" }
|
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake test" }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# If you have OpenSSL installed, we recommend updating
|
# If you do not have OpenSSL installed, update
|
||||||
# the following line to use "https"
|
# the following line to use "http://" instead
|
||||||
source 'http://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
# Specify your gem's dependencies in <%= name %>.gemspec
|
# Specify your gem's dependencies in <%= name %>.gemspec
|
||||||
gemspec
|
gemspec
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Feature: Assets get a file hash appended to their and references to them are updated
|
Feature: Assets get a file hash appended to their and references to them are updated
|
||||||
Scenario: Hashed-asset files are produced, and HTML, CSS, and JavaScript gets rewritten to reference the new files
|
Scenario: Hashed-asset files are produced, and HTML, CSS, JSON and JavaScript gets rewritten to reference the new files
|
||||||
Given a successfully built app at "asset-hash-app"
|
Given a successfully built app at "asset-hash-app"
|
||||||
When I cd to "build"
|
When I cd to "build"
|
||||||
Then the following files should exist:
|
Then the following files should exist:
|
||||||
|
@ -8,12 +8,16 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
| favicon.ico |
|
| favicon.ico |
|
||||||
| images/100px-1242c368.png |
|
| images/100px-1242c368.png |
|
||||||
| images/100px-5fd6fb90.jpg |
|
| images/100px-5fd6fb90.jpg |
|
||||||
|
| images/200px-c11eb203.jpg |
|
||||||
|
| images/300px-59adce76.jpg |
|
||||||
| images/100px-5fd6fb90.gif |
|
| images/100px-5fd6fb90.gif |
|
||||||
| javascripts/application-1d8d5276.js |
|
| javascripts/application-1d8d5276.js |
|
||||||
| stylesheets/site-7474cadd.css |
|
| stylesheets/site-7474cadd.css |
|
||||||
| index.html |
|
| index.html |
|
||||||
| subdir/index.html |
|
| subdir/index.html |
|
||||||
| other/index.html |
|
| other/index.html |
|
||||||
|
| api.json |
|
||||||
|
| subdir/api.json |
|
||||||
And the following files should not exist:
|
And the following files should not exist:
|
||||||
| images/100px.png |
|
| images/100px.png |
|
||||||
| images/100px.jpg |
|
| images/100px.jpg |
|
||||||
|
@ -31,11 +35,20 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
And the file "index.html" should contain 'src="javascripts/application-1d8d5276.js"'
|
And the file "index.html" should contain 'src="javascripts/application-1d8d5276.js"'
|
||||||
And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"'
|
And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"'
|
||||||
And the file "subdir/index.html" should contain 'href="../stylesheets/site-7474cadd.css"'
|
And the file "subdir/index.html" should contain 'href="../stylesheets/site-7474cadd.css"'
|
||||||
|
And the file "index.html" should contain 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
||||||
|
And the file "index.html" should contain 'src="images/100px-5fd6fb90.gif"'
|
||||||
|
And the file "index.html" should contain 'src="images/100px-1242c368.png"'
|
||||||
And the file "subdir/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
And the file "subdir/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
||||||
And the file "subdir/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
And the file "subdir/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
||||||
And the file "other/index.html" should contain 'href="../stylesheets/site-7474cadd.css"'
|
And the file "other/index.html" should contain 'href="../stylesheets/site-7474cadd.css"'
|
||||||
And the file "other/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
And the file "other/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
||||||
And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
||||||
|
And the file "api.json" should contain 'images/100px-5fd6fb90.gif'
|
||||||
|
And the file "api.json" should contain 'images/100px-5fd6fb90.jpg'
|
||||||
|
And the file "api.json" should contain 'images/100px-1242c368.png'
|
||||||
|
And the file "subdir/api.json" should contain 'images/100px-5fd6fb90.gif'
|
||||||
|
And the file "subdir/api.json" should contain 'images/100px-5fd6fb90.jpg'
|
||||||
|
And the file "subdir/api.json" should contain 'images/100px-1242c368.png'
|
||||||
|
|
||||||
Scenario: Hashed assets work in preview server
|
Scenario: Hashed assets work in preview server
|
||||||
Given the Server is running at "asset-hash-app"
|
Given the Server is running at "asset-hash-app"
|
||||||
|
@ -44,6 +57,7 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
And I should see 'href="stylesheets/site-7474cadd.css"'
|
And I should see 'href="stylesheets/site-7474cadd.css"'
|
||||||
And I should see 'src="javascripts/application-1d8d5276.js"'
|
And I should see 'src="javascripts/application-1d8d5276.js"'
|
||||||
And I should see 'src="images/100px-5fd6fb90.jpg"'
|
And I should see 'src="images/100px-5fd6fb90.jpg"'
|
||||||
|
And I should see 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
||||||
When I go to "/subdir/"
|
When I go to "/subdir/"
|
||||||
Then I should see 'href="../stylesheets/site-7474cadd.css"'
|
Then I should see 'href="../stylesheets/site-7474cadd.css"'
|
||||||
And I should see 'src="../javascripts/application-1d8d5276.js"'
|
And I should see 'src="../javascripts/application-1d8d5276.js"'
|
||||||
|
@ -55,10 +69,15 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
When I go to "/javascripts/application-1d8d5276.js"
|
When I go to "/javascripts/application-1d8d5276.js"
|
||||||
Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
|
Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
|
||||||
When I go to "/stylesheets/site-7474cadd.css"
|
When I go to "/stylesheets/site-7474cadd.css"
|
||||||
Then I should see:
|
Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg")'
|
||||||
"""
|
When I go to "/api.json"
|
||||||
background-image: url("../images/100px-5fd6fb90.jpg")
|
Then I should see 'images/100px-5fd6fb90.gif'
|
||||||
"""
|
And I should see 'images/100px-5fd6fb90.jpg'
|
||||||
|
And I should see 'images/100px-1242c368.png'
|
||||||
|
When I go to "/subdir/api.json"
|
||||||
|
Then I should see 'images/100px-5fd6fb90.gif'
|
||||||
|
And I should see 'images/100px-5fd6fb90.jpg'
|
||||||
|
And I should see 'images/100px-1242c368.png'
|
||||||
|
|
||||||
Scenario: Enabling an asset host still produces hashed files and references
|
Scenario: Enabling an asset host still produces hashed files and references
|
||||||
Given the Server is running at "asset-hash-host-app"
|
Given the Server is running at "asset-hash-host-app"
|
||||||
|
@ -71,9 +90,6 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
When I go to "/other/"
|
When I go to "/other/"
|
||||||
Then I should see 'href="http://middlemanapp.com/stylesheets/site-1fdf4fb5.css"'
|
Then I should see 'href="http://middlemanapp.com/stylesheets/site-1fdf4fb5.css"'
|
||||||
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
||||||
# Asset helpers don't appear to work from Compass right now
|
|
||||||
# When I go to "/stylesheets/site-e5a31a3e.css"
|
|
||||||
# Then I should see "background-image: url('http://middlemanapp.com/images/100px-5fd6fb90.jpg')"
|
|
||||||
|
|
||||||
Scenario: The asset hash should change when a SASS partial changes
|
Scenario: The asset hash should change when a SASS partial changes
|
||||||
Given the Server is running at "asset-hash-app"
|
Given the Server is running at "asset-hash-app"
|
||||||
|
@ -138,6 +154,8 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
| index.html |
|
| index.html |
|
||||||
| subdir/index.html |
|
| subdir/index.html |
|
||||||
| other/index.html |
|
| other/index.html |
|
||||||
|
| api.json |
|
||||||
|
| subdir/api.json |
|
||||||
And the following files should not exist:
|
And the following files should not exist:
|
||||||
| images/100px-1242c368.png |
|
| images/100px-1242c368.png |
|
||||||
| images/100px-5fd6fb90.jpg |
|
| images/100px-5fd6fb90.jpg |
|
||||||
|
|
|
@ -17,3 +17,90 @@ Feature: Templates should be chainable
|
||||||
And the file "index.html" should contain "Title</h1>"
|
And the file "index.html" should contain "Title</h1>"
|
||||||
And the file "index.html" should contain "Subtitle</h2>"
|
And the file "index.html" should contain "Subtitle</h2>"
|
||||||
And the file "index.html" should contain "Sup</h3>"
|
And the file "index.html" should contain "Sup</h3>"
|
||||||
|
|
||||||
|
Scenario: Partials are parsed by multiple template engines: Outer template has .erb and inner .md.erb
|
||||||
|
Given a fixture app "partial-chained_templates-app"
|
||||||
|
And a template named "my_template.html.erb" with:
|
||||||
|
"""
|
||||||
|
<h1>My Template</h1>
|
||||||
|
|
||||||
|
<%= partial 'my_partial' %>
|
||||||
|
"""
|
||||||
|
And a template named "my_partial.html.md.erb" with:
|
||||||
|
"""
|
||||||
|
## My Partial
|
||||||
|
|
||||||
|
<%= 'hello world' %>
|
||||||
|
"""
|
||||||
|
And the Server is running
|
||||||
|
When I go to "/my_template.html"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
<h1>My Template</h1>
|
||||||
|
"""
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
<h2 id="my-partial">My Partial</h2>
|
||||||
|
"""
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
<p>hello world</p>
|
||||||
|
"""
|
||||||
|
|
||||||
|
Scenario: Partials are parsed by multiple template engines: Outer template has .md.erb and inner .md.erb
|
||||||
|
Given a fixture app "partial-chained_templates-app"
|
||||||
|
And a template named "my_template.html.md.erb" with:
|
||||||
|
"""
|
||||||
|
# My Template
|
||||||
|
|
||||||
|
<%= partial 'my_partial' %>
|
||||||
|
"""
|
||||||
|
And a template named "my_partial.html.md.erb" with:
|
||||||
|
"""
|
||||||
|
## My Partial
|
||||||
|
|
||||||
|
<%= 'hello world' %>
|
||||||
|
"""
|
||||||
|
And the Server is running
|
||||||
|
When I go to "/my_template.html"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
<h1 id="my-template">My Template</h1>
|
||||||
|
"""
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
<h2 id="my-partial">My Partial</h2>
|
||||||
|
"""
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
<p>hello world</p>
|
||||||
|
"""
|
||||||
|
|
||||||
|
Scenario: Partials are parsed by multiple template engines: Outer template has .md.erb, and inner .erb
|
||||||
|
Given a fixture app "partial-chained_templates-app"
|
||||||
|
And a template named "my_template.html.md.erb" with:
|
||||||
|
"""
|
||||||
|
# My Template
|
||||||
|
|
||||||
|
<%= partial 'my_partial' %>
|
||||||
|
"""
|
||||||
|
And a template named "my_partial.html.erb" with:
|
||||||
|
"""
|
||||||
|
<h2>My Partial</h2>
|
||||||
|
|
||||||
|
<%= 'hello world' %>
|
||||||
|
"""
|
||||||
|
And the Server is running
|
||||||
|
When I go to "/my_template.html"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
<h1 id="my-template">My Template</h1>
|
||||||
|
"""
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
<h2>My Partial</h2>
|
||||||
|
"""
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
<p>hello world</p>
|
||||||
|
"""
|
||||||
|
|
|
@ -37,21 +37,3 @@ Feature: Middleman CLI
|
||||||
Scenario: Create a new project (alias n)
|
Scenario: Create a new project (alias n)
|
||||||
When I run `middleman n MY_PROJECT`
|
When I run `middleman n MY_PROJECT`
|
||||||
Then a directory named "MY_PROJECT" should exist
|
Then a directory named "MY_PROJECT" should exist
|
||||||
|
|
||||||
# Scenario: Create a new HTML5 project
|
|
||||||
# When I run `middleman init MY_PROJECT --template=html5`
|
|
||||||
# Then a directory named "MY_PROJECT" should exist
|
|
||||||
# When I cd to "MY_PROJECT"
|
|
||||||
# Then the following files should exist:
|
|
||||||
# | config.rb |
|
|
||||||
# | Gemfile |
|
|
||||||
# Then the following files should not exist:
|
|
||||||
# | config.ru |
|
|
||||||
# And the file "config.rb" should contain "set :js_dir, 'js'"
|
|
||||||
# Then a directory named "source" should exist
|
|
||||||
# When I cd to "source"
|
|
||||||
# Then the following files should exist:
|
|
||||||
# | index.html.erb |
|
|
||||||
# | layouts/layout.erb |
|
|
||||||
# | humans.txt |
|
|
||||||
# | js/main.js |
|
|
||||||
|
|
33
middleman-core/features/working_directory.feature
Normal file
33
middleman-core/features/working_directory.feature
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
Feature: Honour working directory
|
||||||
|
Honour the working directory during testing
|
||||||
|
In order to support helpers which work with the current directories
|
||||||
|
|
||||||
|
Scenario: Set working directory for helpers in tests
|
||||||
|
Given a fixture app "empty-app"
|
||||||
|
And a file named "source/index.html.erb" with:
|
||||||
|
"""
|
||||||
|
<%= Dir.getwd %>
|
||||||
|
"""
|
||||||
|
And the Server is running
|
||||||
|
When I go to "/index.html"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
aruba
|
||||||
|
"""
|
||||||
|
|
||||||
|
Scenario: Set working directory for config.rb in tests
|
||||||
|
Given a fixture app "empty-app"
|
||||||
|
And a file named "config.rb" with:
|
||||||
|
"""
|
||||||
|
set :my_working_directory, Dir.getwd
|
||||||
|
"""
|
||||||
|
And a file named "source/index.html.erb" with:
|
||||||
|
"""
|
||||||
|
<%= config[:my_working_directory] %>
|
||||||
|
"""
|
||||||
|
And the Server is running
|
||||||
|
When I go to "/index.html"
|
||||||
|
Then I should see:
|
||||||
|
"""
|
||||||
|
aruba
|
||||||
|
"""
|
|
@ -0,0 +1 @@
|
||||||
|
<%= {gif: image_path('100px.gif'), jpg: image_path('100px.jpg'), png: image_path('100px.png')}.to_json %>
|
BIN
middleman-core/fixtures/asset-hash-app/source/images/200px.jpg
Normal file
BIN
middleman-core/fixtures/asset-hash-app/source/images/200px.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
middleman-core/fixtures/asset-hash-app/source/images/300px.jpg
Normal file
BIN
middleman-core/fixtures/asset-hash-app/source/images/300px.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
|
@ -3,7 +3,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<h2>Image url:</h2>
|
<h2>Image url:</h2>
|
||||||
<img src="<%= image_path('100px.jpg') %>">
|
<img src="<%= image_path('100px.jpg') %>" srcset="<%= image_path('100px.jpg') %> 1x, <%= image_path('200px.jpg') %> 2x, <%= image_path('300px.jpg') %> 3x">
|
||||||
|
|
||||||
<h2>Ignored path:</h2>
|
<h2>Ignored path:</h2>
|
||||||
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<%= {gif: image_path('100px.gif'), jpg: image_path('100px.jpg'), png: image_path('100px.png')}.to_json %>
|
|
@ -1,10 +1,5 @@
|
||||||
Default: <%= data.data.title %>
|
Default: <%= data.data.title %>
|
||||||
Data 1: <%= data.data1.title %>
|
Data 1: <%= data.data1.title %>
|
||||||
Data 2: <%= data.data2.title %>
|
Data 2: <%= data.data2.title %>
|
||||||
<<<<<<< HEAD
|
|
||||||
Override in Two: <%= data.two.title %>
|
Override in Two: <%= data.two.title %>
|
||||||
Override in One: <%= data.one.title %>
|
Override in One: <%= data.one.title %>
|
||||||
=======
|
|
||||||
Override in One: <%= data.one.title %>
|
|
||||||
Override in Two: <%= data.two.title %>
|
|
||||||
>>>>>>> Add external command support
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ module Middleman
|
||||||
|
|
||||||
layout: proc { |file, _sitemap_app|
|
layout: proc { |file, _sitemap_app|
|
||||||
file[:relative_path].to_s.start_with?('layout.') ||
|
file[:relative_path].to_s.start_with?('layout.') ||
|
||||||
file[:relative_path].to_s.start_with?('layouts/')
|
file[:relative_path].to_s.start_with?('layouts/')
|
||||||
}
|
}
|
||||||
}, 'Callbacks that can exclude paths from the sitemap'
|
}, 'Callbacks that can exclude paths from the sitemap'
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Padrino::Helpers::OutputHelpers::ErbHandler
|
||||||
raw = block.call(*args)
|
raw = block.call(*args)
|
||||||
captured = template.instance_variable_get(:@_out_buf)
|
captured = template.instance_variable_get(:@_out_buf)
|
||||||
self.output_buffer = buf_was
|
self.output_buffer = buf_was
|
||||||
engine_matches?(block) ? captured : raw
|
engine_matches?(block) && !captured.empty? ? captured : raw
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,14 @@ module Middleman::CoreExtensions
|
||||||
|
|
||||||
return [data, nil] if ::Middleman::Util.binary?(full_path)
|
return [data, nil] if ::Middleman::Util.binary?(full_path)
|
||||||
|
|
||||||
content = File.read(full_path)
|
# Avoid weird race condition when a file is renamed.
|
||||||
|
content = begin
|
||||||
|
File.read(full_path)
|
||||||
|
rescue ::EOFError
|
||||||
|
rescue ::IOError
|
||||||
|
rescue ::Errno::ENOENT
|
||||||
|
''
|
||||||
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if content =~ /\A.*coding:/
|
if content =~ /\A.*coding:/
|
||||||
|
|
|
@ -59,12 +59,12 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
||||||
|
|
||||||
if lang_suffix
|
if lang_suffix
|
||||||
super(suffixed_partial_name) ||
|
super(suffixed_partial_name) ||
|
||||||
super(File.join(locals_dir, suffixed_partial_name)) ||
|
super(File.join(locals_dir, suffixed_partial_name)) ||
|
||||||
super(partials_path) ||
|
super(partials_path) ||
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
super(partials_path) ||
|
super(partials_path) ||
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,8 +64,8 @@ module Middleman
|
||||||
block
|
block
|
||||||
elsif extension_class && extension_class.ancestors.include?(::Middleman::Extension)
|
elsif extension_class && extension_class.ancestors.include?(::Middleman::Extension)
|
||||||
extension_class
|
extension_class
|
||||||
else
|
else
|
||||||
raise 'You must provide a Middleman::Extension or a block that returns a Middleman::Extension'
|
raise 'You must provide a Middleman::Extension or a block that returns a Middleman::Extension'
|
||||||
end
|
end
|
||||||
|
|
||||||
return unless options[:auto_activate]
|
return unless options[:auto_activate]
|
||||||
|
|
|
@ -39,7 +39,7 @@ module Middleman
|
||||||
build_path = 'Not built' if ignored?
|
build_path = 'Not built' if ignored?
|
||||||
props['Build Path'] = build_path if @resource.path != build_path
|
props['Build Path'] = build_path if @resource.path != build_path
|
||||||
props['URL'] = content_tag(:a, @resource.url, href: @resource.url) unless ignored?
|
props['URL'] = content_tag(:a, @resource.url, href: @resource.url) unless ignored?
|
||||||
props['Source File'] = @resource.source_file ? @resource.source_file[:full_path].to_s : 'Dynamic'
|
props['Source File'] = @resource.source_file ? @resource.source_file[:full_path].to_s.sub(/^#{Regexp.escape(ENV['MM_ROOT'] + '/')}/, '') : 'Dynamic'
|
||||||
|
|
||||||
data = @resource.data
|
data = @resource.data
|
||||||
props['Data'] = data.inspect unless data.empty?
|
props['Data'] = data.inspect unless data.empty?
|
||||||
|
|
|
@ -84,7 +84,7 @@ module Middleman
|
||||||
def globally_ignored?(file)
|
def globally_ignored?(file)
|
||||||
@ignores.values.any? do |descriptor|
|
@ignores.values.any? do |descriptor|
|
||||||
((descriptor[:type] == :all) || file[:types].include?(descriptor[:type])) &&
|
((descriptor[:type] == :all) || file[:types].include?(descriptor[:type])) &&
|
||||||
matches?(descriptor[:validator], file)
|
matches?(descriptor[:validator], file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -169,11 +169,11 @@ module Middleman
|
||||||
Contract Symbol, String, Maybe[Bool] => Maybe[SourceFile]
|
Contract Symbol, String, Maybe[Bool] => Maybe[SourceFile]
|
||||||
def find(type, path, glob=false)
|
def find(type, path, glob=false)
|
||||||
watchers
|
watchers
|
||||||
.lazy
|
.lazy
|
||||||
.select { |d| d.type == type }
|
.select { |d| d.type == type }
|
||||||
.map { |d| d.find(path, glob) }
|
.map { |d| d.find(path, glob) }
|
||||||
.reject(&:nil?)
|
.reject(&:nil?)
|
||||||
.first
|
.first
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if a file for a given type exists.
|
# Check if a file for a given type exists.
|
||||||
|
@ -184,9 +184,9 @@ module Middleman
|
||||||
Contract Symbol, String => Bool
|
Contract Symbol, String => Bool
|
||||||
def exists?(type, path)
|
def exists?(type, path)
|
||||||
watchers
|
watchers
|
||||||
.lazy
|
.lazy
|
||||||
.select { |d| d.type == type }
|
.select { |d| d.type == type }
|
||||||
.any? { |d| d.exists?(path) }
|
.any? { |d| d.exists?(path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if a file for a given type exists.
|
# Check if a file for a given type exists.
|
||||||
|
@ -197,8 +197,8 @@ module Middleman
|
||||||
Contract SetOf[Symbol], String => Maybe[HANDLER]
|
Contract SetOf[Symbol], String => Maybe[HANDLER]
|
||||||
def watcher_for_path(types, path)
|
def watcher_for_path(types, path)
|
||||||
watchers
|
watchers
|
||||||
.select { |d| types.include?(d.type) }
|
.select { |d| types.include?(d.type) }
|
||||||
.find { |d| d.exists?(path) }
|
.find { |d| d.exists?(path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Manually poll all watchers for new content.
|
# Manually poll all watchers for new content.
|
||||||
|
|
|
@ -104,7 +104,6 @@ module Middleman
|
||||||
return nil if p.absolute? && !p.to_s.start_with?(@directory.to_s)
|
return nil if p.absolute? && !p.to_s.start_with?(@directory.to_s)
|
||||||
|
|
||||||
p = @directory + p if p.relative?
|
p = @directory + p if p.relative?
|
||||||
|
|
||||||
if glob
|
if glob
|
||||||
@extensionless_files[p]
|
@extensionless_files[p]
|
||||||
else
|
else
|
||||||
|
@ -211,25 +210,25 @@ module Middleman
|
||||||
Contract ArrayOf[Pathname], ArrayOf[Pathname] => Any
|
Contract ArrayOf[Pathname], ArrayOf[Pathname] => Any
|
||||||
def update(updated_paths, removed_paths)
|
def update(updated_paths, removed_paths)
|
||||||
valid_updates = updated_paths
|
valid_updates = updated_paths
|
||||||
.lazy
|
.lazy
|
||||||
.map(&method(:path_to_source_file))
|
.map(&method(:path_to_source_file))
|
||||||
.select(&method(:valid?))
|
.select(&method(:valid?))
|
||||||
.to_a
|
.to_a
|
||||||
.each do |f|
|
.each do |f|
|
||||||
add_file_to_cache(f)
|
add_file_to_cache(f)
|
||||||
logger.debug "== Change (#{f[:types].inspect}): #{f[:relative_path]}"
|
logger.debug "== Change (#{f[:types].inspect}): #{f[:relative_path]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
valid_removes = removed_paths
|
valid_removes = removed_paths
|
||||||
.lazy
|
.lazy
|
||||||
.select(&@files.method(:key?))
|
.select(&@files.method(:key?))
|
||||||
.map(&@files.method(:[]))
|
.map(&@files.method(:[]))
|
||||||
.select(&method(:valid?))
|
.select(&method(:valid?))
|
||||||
.to_a
|
.to_a
|
||||||
.each do |f|
|
.each do |f|
|
||||||
remove_file_from_cache(f)
|
remove_file_from_cache(f)
|
||||||
logger.debug "== Deletion (#{f[:types].inspect}): #{f[:relative_path]}"
|
logger.debug "== Deletion (#{f[:types].inspect}): #{f[:relative_path]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
run_callbacks(
|
run_callbacks(
|
||||||
@on_change_callbacks,
|
@on_change_callbacks,
|
||||||
|
@ -240,12 +239,19 @@ module Middleman
|
||||||
|
|
||||||
def add_file_to_cache(f)
|
def add_file_to_cache(f)
|
||||||
@files[f[:full_path]] = f
|
@files[f[:full_path]] = f
|
||||||
@extensionless_files[f[:full_path].sub_ext('.*')] = f
|
@extensionless_files[strip_extensions(f[:full_path])] = f
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_file_from_cache(f)
|
def remove_file_from_cache(f)
|
||||||
@files.delete(f[:full_path])
|
@files.delete(f[:full_path])
|
||||||
@extensionless_files.delete(f[:full_path].sub_ext('.*'))
|
@extensionless_files.delete(strip_extensions(f[:full_path]))
|
||||||
|
end
|
||||||
|
|
||||||
|
def strip_extensions(p)
|
||||||
|
while ::Tilt[p.to_s] || p.extname === '.html'
|
||||||
|
p = p.sub_ext('')
|
||||||
|
end
|
||||||
|
Pathname(p.to_s + '.*')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if this watcher should care about a file.
|
# Check if this watcher should care about a file.
|
||||||
|
@ -255,8 +261,8 @@ module Middleman
|
||||||
Contract IsA['Middleman::SourceFile'] => Bool
|
Contract IsA['Middleman::SourceFile'] => Bool
|
||||||
def valid?(file)
|
def valid?(file)
|
||||||
@validator.call(file) &&
|
@validator.call(file) &&
|
||||||
!globally_ignored?(file) &&
|
!globally_ignored?(file) &&
|
||||||
!@ignored.call(file)
|
!@ignored.call(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Convert a path to a file resprentation.
|
# Convert a path to a file resprentation.
|
||||||
|
|
|
@ -33,6 +33,7 @@ end
|
||||||
Given /^the Server is running$/ do
|
Given /^the Server is running$/ do
|
||||||
root_dir = File.expand_path(current_dir)
|
root_dir = File.expand_path(current_dir)
|
||||||
|
|
||||||
|
|
||||||
if File.exists?(File.join(root_dir, 'source'))
|
if File.exists?(File.join(root_dir, 'source'))
|
||||||
ENV['MM_SOURCE'] = 'source'
|
ENV['MM_SOURCE'] = 'source'
|
||||||
else
|
else
|
||||||
|
@ -43,12 +44,14 @@ Given /^the Server is running$/ do
|
||||||
|
|
||||||
initialize_commands = @initialize_commands || []
|
initialize_commands = @initialize_commands || []
|
||||||
|
|
||||||
@server_inst = ::Middleman::Application.new do
|
in_current_dir do
|
||||||
config[:watcher_disable] = true
|
@server_inst = ::Middleman::Application.new do
|
||||||
config[:show_exceptions] = false
|
config[:watcher_disable] = true
|
||||||
|
config[:show_exceptions] = false
|
||||||
|
|
||||||
initialize_commands.each do |p|
|
initialize_commands.each do |p|
|
||||||
instance_exec(&p)
|
instance_exec(&p)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,54 +64,82 @@ Given /^the Server is running at "([^\"]*)"$/ do |app_path|
|
||||||
step %Q{the Server is running}
|
step %Q{the Server is running}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Given /^a template named "([^\"]*)" with:$/ do |name, string|
|
||||||
|
step %Q{a file named "source/#{name}" with:}, string
|
||||||
|
end
|
||||||
|
|
||||||
When /^I go to "([^\"]*)"$/ do |url|
|
When /^I go to "([^\"]*)"$/ do |url|
|
||||||
@last_response = @browser.get(URI.escape(url))
|
in_current_dir do
|
||||||
|
@last_response = @browser.get(URI.escape(url))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
|
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
|
||||||
last_response = nil
|
in_current_dir do
|
||||||
expect {
|
last_response = nil
|
||||||
last_response = @browser.get(URI.escape(url))
|
expect {
|
||||||
}.to_not raise_error
|
last_response = @browser.get(URI.escape(url))
|
||||||
@last_response = last_response
|
}.to_not raise_error
|
||||||
|
@last_response = last_response
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the content type should be "([^\"]*)"$/ do |expected|
|
Then /^the content type should be "([^\"]*)"$/ do |expected|
|
||||||
expect(@last_response.content_type).to start_with(expected)
|
in_current_dir do
|
||||||
|
expect(@last_response.content_type).to start_with(expected)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "([^\"]*)"$/ do |expected|
|
Then /^I should see "([^\"]*)"$/ do |expected|
|
||||||
expect(@last_response.body).to include(expected)
|
in_current_dir do
|
||||||
|
expect(@last_response.body).to include(expected)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see '([^\']*)'$/ do |expected|
|
Then /^I should see '([^\']*)'$/ do |expected|
|
||||||
expect(@last_response.body).to include(expected)
|
in_current_dir do
|
||||||
|
expect(@last_response.body).to include(expected)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see:$/ do |expected|
|
Then /^I should see:$/ do |expected|
|
||||||
expect(@last_response.body).to include(expected)
|
in_current_dir do
|
||||||
|
expect(@last_response.body).to include(expected)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see "([^\"]*)"$/ do |expected|
|
Then /^I should not see "([^\"]*)"$/ do |expected|
|
||||||
expect(@last_response.body).to_not include(expected)
|
in_current_dir do
|
||||||
|
expect(@last_response.body).to_not include(expected)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see content matching %r{(.*)}$/ do |expected|
|
Then /^I should see content matching %r{(.*)}$/ do |expected|
|
||||||
expect(@last_response.body).to match(expected)
|
in_current_dir do
|
||||||
|
expect(@last_response.body).to match(expected)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see content matching %r{(.*)}$/ do |expected|
|
Then /^I should not see content matching %r{(.*)}$/ do |expected|
|
||||||
expect(@last_response.body).to_not match(expected)
|
in_current_dir do
|
||||||
|
expect(@last_response.body).to_not match(expected)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see:$/ do |expected|
|
Then /^I should not see:$/ do |expected|
|
||||||
expect(@browser.last_response.body).to_not include(expected.chomp)
|
in_current_dir do
|
||||||
|
expect(@browser.last_response.body).to_not include(expected.chomp)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the status code should be "([^\"]*)"$/ do |expected|
|
Then /^the status code should be "([^\"]*)"$/ do |expected|
|
||||||
expect(@browser.last_response.status).to eq expected.to_i
|
in_current_dir do
|
||||||
|
expect(@browser.last_response.status).to eq expected.to_i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
||||||
expect(@last_response.body.chomp.split($/).length).to eq(lines.to_i)
|
in_current_dir do
|
||||||
|
expect(@last_response.body.chomp.split($/).length).to eq(lines.to_i)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,7 +30,7 @@ module Middleman
|
||||||
# @param [Middleman::Application] app
|
# @param [Middleman::Application] app
|
||||||
# @param [Hash] locs
|
# @param [Hash] locs
|
||||||
# @param [Hash] opts
|
# @param [Hash] opts
|
||||||
def initialize(app, locs={}.freeze, opts={}.freeze)
|
def initialize(app, locs={}, opts={})
|
||||||
@app = app
|
@app = app
|
||||||
@locs = locs
|
@locs = locs
|
||||||
@opts = opts
|
@opts = opts
|
||||||
|
@ -114,7 +114,7 @@ module Middleman
|
||||||
opts = options.dup
|
opts = options.dup
|
||||||
locs = opts.delete(:locals)
|
locs = opts.delete(:locals)
|
||||||
|
|
||||||
render_file(partial_file, locs.freeze, opts.freeze, &block)
|
render_file(partial_file, locs, opts, &block)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -163,8 +163,28 @@ module Middleman
|
||||||
# @return [String] The resulting content string.
|
# @return [String] The resulting content string.
|
||||||
Contract IsA['Middleman::SourceFile'], Hash, Hash, Proc => String
|
Contract IsA['Middleman::SourceFile'], Hash, Hash, Proc => String
|
||||||
def render_file(file, locs, opts, &block)
|
def render_file(file, locs, opts, &block)
|
||||||
file_renderer = ::Middleman::FileRenderer.new(@app, file[:relative_path].to_s)
|
_render_with_all_renderers(file[:relative_path].to_s, locs, self, opts, &block)
|
||||||
file_renderer.render(locs, opts, self, &block)
|
end
|
||||||
|
|
||||||
|
def _render_with_all_renderers(path, locs, context, opts, &block)
|
||||||
|
# Keep rendering template until we've used up all extensions. This
|
||||||
|
# handles cases like `style.css.sass.erb`
|
||||||
|
content = nil
|
||||||
|
|
||||||
|
while ::Tilt[path]
|
||||||
|
begin
|
||||||
|
opts[:template_body] = content if content
|
||||||
|
|
||||||
|
content_renderer = ::Middleman::FileRenderer.new(@app, path)
|
||||||
|
content = content_renderer.render(locs, opts, context, &block)
|
||||||
|
|
||||||
|
path = File.basename(path, File.extname(path))
|
||||||
|
rescue LocalJumpError
|
||||||
|
raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{@app.config[:source]}/#{@app.config[:layouts_dir]}."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
content
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_path
|
def current_path
|
||||||
|
|
|
@ -42,7 +42,7 @@ module Middleman
|
||||||
# @param [Hash] opts
|
# @param [Hash] opts
|
||||||
# @return [String]
|
# @return [String]
|
||||||
Contract Hash, Hash => String
|
Contract Hash, Hash => String
|
||||||
def render(locs={}, opts={})
|
def render(locs={}, opts={}, &block)
|
||||||
path = @path.dup
|
path = @path.dup
|
||||||
locals = locs.dup.freeze
|
locals = locs.dup.freeze
|
||||||
options = opts.dup
|
options = opts.dup
|
||||||
|
@ -61,21 +61,7 @@ module Middleman
|
||||||
# TODO: Only for HAML files
|
# TODO: Only for HAML files
|
||||||
context.init_haml_helpers if context.respond_to?(:init_haml_helpers)
|
context.init_haml_helpers if context.respond_to?(:init_haml_helpers)
|
||||||
|
|
||||||
# Keep rendering template until we've used up all extensions. This
|
content = _render_with_all_renderers(path, locs, context, opts, &block)
|
||||||
# handles cases like `style.css.sass.erb`
|
|
||||||
content = nil
|
|
||||||
while ::Tilt[path]
|
|
||||||
begin
|
|
||||||
options[:template_body] = content if content
|
|
||||||
|
|
||||||
content_renderer = ::Middleman::FileRenderer.new(@app, path)
|
|
||||||
content = content_renderer.render(locals, options, context)
|
|
||||||
|
|
||||||
path = File.basename(path, File.extname(path))
|
|
||||||
rescue LocalJumpError
|
|
||||||
raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/#{@app.config[:layouts_dir]}."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# If we need a layout and have a layout, use it
|
# If we need a layout and have a layout, use it
|
||||||
if layout_file = fetch_layout(engine, options)
|
if layout_file = fetch_layout(engine, options)
|
||||||
|
@ -93,6 +79,27 @@ module Middleman
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def _render_with_all_renderers(path, locs, context, opts, &block)
|
||||||
|
# Keep rendering template until we've used up all extensions. This
|
||||||
|
# handles cases like `style.css.sass.erb`
|
||||||
|
content = nil
|
||||||
|
|
||||||
|
while ::Tilt[path]
|
||||||
|
begin
|
||||||
|
opts[:template_body] = content if content
|
||||||
|
|
||||||
|
content_renderer = ::Middleman::FileRenderer.new(@app, path)
|
||||||
|
content = content_renderer.render(locs, opts, context, &block)
|
||||||
|
|
||||||
|
path = File.basename(path, File.extname(path))
|
||||||
|
rescue LocalJumpError
|
||||||
|
raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{@app.config[:source]}/#{@app.config[:layouts_dir]}."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
content
|
||||||
|
end
|
||||||
|
|
||||||
# Find a layout for a given engine
|
# Find a layout for a given engine
|
||||||
#
|
#
|
||||||
# @param [Symbol] engine
|
# @param [Symbol] engine
|
||||||
|
|
|
@ -317,7 +317,7 @@ module Middleman
|
||||||
|
|
||||||
Contract String, String, ArrayOf[String], Proc => String
|
Contract String, String, ArrayOf[String], Proc => String
|
||||||
def rewrite_paths(body, _path, exts, &_block)
|
def rewrite_paths(body, _path, exts, &_block)
|
||||||
body.dup.gsub(/([=\'\"\(]\s*)([^\s\'\"\)]+(#{Regexp.union(exts)}))/) do |match|
|
body.dup.gsub(/([=\'\"\(,]\s*)([^\s\'\"\)]+(#{Regexp.union(exts)}))/) do |match|
|
||||||
opening_character = $1
|
opening_character = $1
|
||||||
asset_path = $2
|
asset_path = $2
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue