middleman-core 4.0.0.alpha.6 → 4.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/asset_hash.feature +8 -1
- data/features/asset_host.feature +2 -13
- data/features/builder.feature +0 -2
- data/features/cli_init.feature +32 -0
- data/features/collections.feature +50 -0
- data/features/directory_index.feature +4 -5
- data/features/front-matter-neighbor.feature +20 -0
- data/features/helpers_link_to.feature +18 -0
- data/features/image_srcset_paths.feature +7 -0
- data/features/markdown_kramdown_in_haml.feature +2 -1
- data/features/minify_javascript.feature +1 -1
- data/features/multiple-sources.feature +8 -0
- data/fixtures/asset-hash-app/source/slim.html.slim +8 -0
- data/fixtures/asset-hash-app/source/subdir/index.html.erb +10 -1
- data/fixtures/asset-host-app/source/asset_host.html.erb +23 -1
- data/fixtures/collections-app/source/blog2/2011-01-01-new-article.html.markdown +2 -0
- data/fixtures/frontmatter-settings-neighbor-app/config.rb +19 -14
- data/fixtures/image-srcset-paths-app/image-srcset-paths.html.erb +1 -0
- data/fixtures/image-srcset-paths-app/images/blank.gif +0 -0
- data/fixtures/indexable-app/source/evil spaces.html +1 -1
- data/fixtures/large-build-app/config.rb +2 -0
- data/fixtures/large-build-app/source/spaces in file.html.erb +1 -1
- data/fixtures/more-traversal-app/source/layout.erb +1 -1
- data/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb +2 -0
- data/fixtures/multiple-sources-with-duplicate-file-names-app/source/index.html.erb +1 -0
- data/fixtures/multiple-sources-with-duplicate-file-names-app/source2/index.html.erb +1 -0
- data/fixtures/traversal-app/source/.htaccess +0 -0
- data/fixtures/traversal-app/source/layout.erb +1 -1
- data/lib/middleman/rack.rb +1 -0
- data/lib/middleman-core/application.rb +15 -15
- data/lib/middleman-core/builder.rb +11 -7
- data/lib/middleman-core/cli/server.rb +86 -0
- data/lib/middleman-core/config_context.rb +1 -1
- data/lib/middleman-core/contracts.rb +0 -32
- data/lib/middleman-core/core_extensions/collections.rb +19 -17
- data/lib/middleman-core/core_extensions/data.rb +15 -17
- data/lib/middleman-core/core_extensions/default_helpers.rb +22 -1
- data/lib/middleman-core/core_extensions/file_watcher.rb +9 -7
- data/lib/middleman-core/core_extensions/front_matter.rb +2 -2
- data/lib/middleman-core/core_extensions/i18n.rb +11 -9
- data/lib/middleman-core/core_extensions/routing.rb +3 -4
- data/lib/middleman-core/extension.rb +179 -0
- data/lib/middleman-core/extension_manager.rb +8 -7
- data/lib/middleman-core/extensions/asset_hash.rb +14 -9
- data/lib/middleman-core/extensions/asset_host.rb +3 -1
- data/lib/middleman-core/extensions/gzip.rb +3 -2
- data/lib/middleman-core/extensions/lorem.rb +2 -2
- data/lib/middleman-core/extensions/relative_assets.rb +11 -5
- data/lib/middleman-core/file_renderer.rb +2 -2
- data/lib/middleman-core/logger.rb +1 -1
- data/lib/middleman-core/middleware/inline_url_rewriter.rb +9 -4
- data/lib/middleman-core/preview_server.rb +13 -9
- data/lib/middleman-core/rack.rb +2 -1
- data/lib/middleman-core/renderers/haml.rb +6 -0
- data/lib/middleman-core/renderers/kramdown.rb +1 -1
- data/lib/middleman-core/renderers/redcarpet.rb +1 -0
- data/lib/middleman-core/renderers/sass.rb +1 -1
- data/lib/middleman-core/renderers/slim.rb +1 -0
- data/lib/middleman-core/sitemap/extensions/ignores.rb +7 -4
- data/lib/middleman-core/sitemap/extensions/on_disk.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/proxies.rb +13 -10
- data/lib/middleman-core/sitemap/extensions/redirects.rb +8 -7
- data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +7 -6
- data/lib/middleman-core/sitemap/extensions/traversal.rb +3 -1
- data/lib/middleman-core/sitemap/resource.rb +14 -15
- data/lib/middleman-core/sitemap/store.rb +6 -5
- data/lib/middleman-core/sources/source_watcher.rb +29 -16
- data/lib/middleman-core/sources.rb +19 -21
- data/lib/middleman-core/step_definitions/builder_steps.rb +1 -1
- data/lib/middleman-core/step_definitions/server_steps.rb +3 -3
- data/lib/middleman-core/template_context.rb +8 -7
- data/lib/middleman-core/template_renderer.rb +2 -2
- data/lib/middleman-core/util.rb +57 -21
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman-core.rb +2 -1
- data/middleman-core.gemspec +4 -1
- data/spec/middleman-core/core_extensions/data_spec.rb +41 -0
- data/spec/middleman-core/util_spec.rb +96 -0
- metadata +38 -8
- data/lib/middleman-core/util/hash_with_indifferent_access.rb +0 -103
- data/spec/middleman-core/binary_spec.rb +0 -15
- data/spec/middleman-core/path_match_spec.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02dd866c5282faf778b2e57669ad86197c26cc90
|
4
|
+
data.tar.gz: 2402e62953aa0cb41f7cbe98078e7203b2bd98e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d66bfdb93ea7353d9c0f3750f13f5df0b31712e6f7527a256f53116ba422ed7b93cd14e9544e57ac531345ca09d2fb73c1c1c285d6a7848624cb4297a339cc8
|
7
|
+
data.tar.gz: 0653294a824cc10c51d0ecdb04fb0363d550e524ba04e58995d79dbd4d67fb7d751236e703a92c2f5a6860d970e2c879ce79bba92360c815242dc7e396cfbc55
|
data/features/asset_hash.feature
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Feature: Assets get
|
1
|
+
Feature: Assets get file hashes appended to them and references to them are updated
|
2
2
|
Scenario: Hashed-asset files are produced, and HTML, CSS, JSON and JavaScript gets rewritten to reference the new files
|
3
3
|
Given a successfully built app at "asset-hash-app"
|
4
4
|
When I cd to "build"
|
@@ -79,6 +79,13 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|
79
79
|
And I should see 'images/100px-5fd6fb90.jpg'
|
80
80
|
And I should see 'images/100px-1242c368.png'
|
81
81
|
|
82
|
+
Scenario: Hashed assets work with Slim
|
83
|
+
Given the Server is running at "asset-hash-app"
|
84
|
+
When I go to "/slim.html"
|
85
|
+
And I should see 'src="images/300px-59adce76.jpg"'
|
86
|
+
And I should see 'src="images/100px-5fd6fb90.jpg"'
|
87
|
+
And I should see 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
88
|
+
|
82
89
|
Scenario: Enabling an asset host still produces hashed files and references
|
83
90
|
Given the Server is running at "asset-hash-host-app"
|
84
91
|
When I go to "/"
|
data/features/asset_host.feature
CHANGED
@@ -1,17 +1,4 @@
|
|
1
1
|
Feature: Alternate between multiple asset hosts
|
2
|
-
In order to speed up page loading
|
3
|
-
|
4
|
-
Scenario: Set single host globally
|
5
|
-
Given a fixture app "asset-host-app"
|
6
|
-
And a file named "config.rb" with:
|
7
|
-
"""
|
8
|
-
activate :asset_host, host: "http://assets1.example.com"
|
9
|
-
"""
|
10
|
-
And the Server is running
|
11
|
-
When I go to "/asset_host.html"
|
12
|
-
Then I should see "http://assets1"
|
13
|
-
When I go to "/stylesheets/asset_host.css"
|
14
|
-
Then I should see "http://assets1"
|
15
2
|
|
16
3
|
Scenario: Set single host with inline-option
|
17
4
|
Given a fixture app "asset-host-app"
|
@@ -21,6 +8,7 @@ Feature: Alternate between multiple asset hosts
|
|
21
8
|
"""
|
22
9
|
And the Server is running
|
23
10
|
When I go to "/asset_host.html"
|
11
|
+
Then I should see 'src="https://code.jquery.com/jquery-2.1.3.min.js"'
|
24
12
|
Then I should see content matching %r{http://assets1.example.com/}
|
25
13
|
Then I should not see content matching %r{http://assets1.example.com//}
|
26
14
|
When I go to "/stylesheets/asset_host.css"
|
@@ -37,6 +25,7 @@ Feature: Alternate between multiple asset hosts
|
|
37
25
|
"""
|
38
26
|
And the Server is running
|
39
27
|
When I go to "/asset_host.html"
|
28
|
+
Then I should see 'src="https://code.jquery.com/jquery-2.1.3.min.js"'
|
40
29
|
Then I should see content matching %r{http://assets1.example.com/}
|
41
30
|
Then I should not see content matching %r{http://assets1.example.com//}
|
42
31
|
When I go to "/stylesheets/asset_host.css"
|
data/features/builder.feature
CHANGED
@@ -9,7 +9,6 @@ Feature: Builder
|
|
9
9
|
| static.html |
|
10
10
|
| services/index.html |
|
11
11
|
| stylesheets/static.css |
|
12
|
-
| spaces in file.html |
|
13
12
|
| images/blank.gif |
|
14
13
|
| images/Read me (example).txt |
|
15
14
|
| images/Child folder/regular_file(example).txt |
|
@@ -27,7 +26,6 @@ Feature: Builder
|
|
27
26
|
And the file "static.html" should contain "Static, no code!"
|
28
27
|
And the file "services/index.html" should contain "Services"
|
29
28
|
And the file "stylesheets/static.css" should contain "body"
|
30
|
-
And the file "spaces in file.html" should contain "spaces"
|
31
29
|
|
32
30
|
Scenario: Build glob
|
33
31
|
Given a successfully built app at "glob-app" with flags "--glob '*.css'"
|
data/features/cli_init.feature
CHANGED
@@ -55,3 +55,35 @@ Feature: Middleman CLI
|
|
55
55
|
And I type "y"
|
56
56
|
And I type "y"
|
57
57
|
Then a directory named "MY_PROJECT" should exist
|
58
|
+
|
59
|
+
Scenario: Create a new project using Middleman directory
|
60
|
+
When I run `middleman init MY_PROJECT -T amicus`
|
61
|
+
Then a directory named "MY_PROJECT" should exist
|
62
|
+
When I cd to "MY_PROJECT"
|
63
|
+
And the file "README.md" should contain "Amicus"
|
64
|
+
And the file ".gitignore" should not exist
|
65
|
+
|
66
|
+
Scenario: Create a new project using github(user/repository)
|
67
|
+
When I run `middleman init MY_PROJECT -T middleman/middleman-templates-default` interactively
|
68
|
+
And I type "y"
|
69
|
+
And I type "y"
|
70
|
+
And I type "y"
|
71
|
+
And I type "y"
|
72
|
+
Then a directory named "MY_PROJECT" should exist
|
73
|
+
|
74
|
+
Scenario: Create a new project using github(user/repository#branch)
|
75
|
+
When I run `middleman init MY_PROJECT -T middleman/middleman-templates-default#master` interactively
|
76
|
+
And I type "y"
|
77
|
+
And I type "y"
|
78
|
+
And I type "y"
|
79
|
+
And I type "y"
|
80
|
+
Then a directory named "MY_PROJECT" should exist
|
81
|
+
And the output should contain "-b master"
|
82
|
+
|
83
|
+
Scenario: Create a new project using full path(://)
|
84
|
+
When I run `middleman init MY_PROJECT -T https://github.com/middleman/middleman-templates-default.git` interactively
|
85
|
+
And I type "y"
|
86
|
+
And I type "y"
|
87
|
+
And I type "y"
|
88
|
+
And I type "y"
|
89
|
+
Then a directory named "MY_PROJECT" should exist
|
@@ -143,3 +143,53 @@ Feature: Collections
|
|
143
143
|
When I go to "index.html"
|
144
144
|
And I should see 'Article: Blog3 Another Article'
|
145
145
|
And I should see 'Article: Blog2 Yet Another Article'
|
146
|
+
|
147
|
+
|
148
|
+
Scenario: Collected data update with file changes
|
149
|
+
Given a fixture app "collections-app"
|
150
|
+
And a file named "config.rb" with:
|
151
|
+
"""
|
152
|
+
data.articles.each_with_index do |a, i|
|
153
|
+
proxy "/#{i}.html", a
|
154
|
+
end
|
155
|
+
"""
|
156
|
+
And a file named "data/articles.yaml" with:
|
157
|
+
"""
|
158
|
+
---
|
159
|
+
- "/blog1/2011-01-01-new-article.html"
|
160
|
+
- "/blog2/2011-01-02-another-article.html"
|
161
|
+
"""
|
162
|
+
Given the Server is running at "collections-app"
|
163
|
+
When I go to "0.html"
|
164
|
+
Then I should see 'Newer Article Content'
|
165
|
+
When I go to "1.html"
|
166
|
+
Then I should see 'Another Article Content'
|
167
|
+
When I go to "2.html"
|
168
|
+
Then I should see 'Not Found'
|
169
|
+
|
170
|
+
When the file "data/articles.yaml" has the contents
|
171
|
+
"""
|
172
|
+
---
|
173
|
+
- "/blog1/2011-01-01-new-article.html"
|
174
|
+
"""
|
175
|
+
When I go to "0.html"
|
176
|
+
Then I should see 'Newer Article Content'
|
177
|
+
When I go to "1.html"
|
178
|
+
Then I should see 'Not Found'
|
179
|
+
When I go to "2.html"
|
180
|
+
Then I should see 'Not Found'
|
181
|
+
|
182
|
+
When the file "data/articles.yaml" has the contents
|
183
|
+
"""
|
184
|
+
---
|
185
|
+
- "/blog2/2011-01-02-another-article.html"
|
186
|
+
- "/blog1/2011-01-01-new-article.html"
|
187
|
+
- "/blog2/2011-01-01-new-article.html"
|
188
|
+
"""
|
189
|
+
When I go to "0.html"
|
190
|
+
Then I should see 'Another Article Content'
|
191
|
+
When I go to "1.html"
|
192
|
+
Then I should see 'Newer Article Content'
|
193
|
+
When I go to "2.html"
|
194
|
+
Then I should see 'Again'
|
195
|
+
|
@@ -25,9 +25,8 @@ Feature: Directory Index
|
|
25
25
|
And the file "a_folder/needs_index/index.html" should contain "Indexable"
|
26
26
|
And the file "leave_me_alone.html" should contain "Stay away"
|
27
27
|
And the file "regular/index.html" should contain "Regular"
|
28
|
-
And the file "evil spaces/index.html" should contain "Spaces"
|
29
|
-
|
30
|
-
|
28
|
+
And the file "evil spaces/index.html" should contain "Filled with Evil Spaces"
|
29
|
+
|
31
30
|
Scenario: Preview normal file
|
32
31
|
Given the Server is running at "indexable-app"
|
33
32
|
When I go to "/needs_index/"
|
@@ -35,8 +34,8 @@ Feature: Directory Index
|
|
35
34
|
|
36
35
|
Scenario: Preview normal file with spaces in filename
|
37
36
|
Given the Server is running at "indexable-app"
|
38
|
-
When I go to "/evil
|
39
|
-
Then I should see "Spaces"
|
37
|
+
When I go to "/evil spaces/"
|
38
|
+
Then I should see "Filled with Evil Spaces"
|
40
39
|
|
41
40
|
Scenario: Preview normal file subdirectory
|
42
41
|
Given the Server is running at "indexable-app"
|
@@ -136,3 +136,23 @@ Feature: Neighboring YAML Front Matter
|
|
136
136
|
Then I should see "Layout in use: Override"
|
137
137
|
When I go to "/page_mentioned.html.erb.frontmatter"
|
138
138
|
Then I should see "File Not Found"
|
139
|
+
|
140
|
+
# Scenario: Neighbor frontmatter for destination of proxy resources
|
141
|
+
# Given the Server is running at "frontmatter-settings-neighbor-app"
|
142
|
+
# And the file "source/proxied_with_frontmatter.html.frontmatter" has the contents
|
143
|
+
# """
|
144
|
+
# ---
|
145
|
+
# title: Proxied title
|
146
|
+
# ---
|
147
|
+
# """
|
148
|
+
# And the file "source/ignored.html.erb" has the contents
|
149
|
+
# """
|
150
|
+
# ---
|
151
|
+
# ignored: true
|
152
|
+
# ---
|
153
|
+
|
154
|
+
# <%= current_resource.data.inspect %>
|
155
|
+
# <%= current_resource.data.title %>
|
156
|
+
# """
|
157
|
+
# When I go to "/proxied_with_frontmatter.html"
|
158
|
+
# Then I should see "Proxied title"
|
@@ -5,6 +5,24 @@ Feature: link_to helper
|
|
5
5
|
When I go to "/link_to_erb.html"
|
6
6
|
Then I should see "erb <s>with html tags</s>"
|
7
7
|
|
8
|
+
Scenario: link_to works with absolute URLs (where the relative part matches a local path)
|
9
|
+
Given a fixture app "link-to-app"
|
10
|
+
And a file named "config.rb" with:
|
11
|
+
"""
|
12
|
+
set :relative_links, true
|
13
|
+
"""
|
14
|
+
And a file named "source/test.html.erb" with:
|
15
|
+
"""
|
16
|
+
Hello
|
17
|
+
"""
|
18
|
+
And a file named "source/link_to_absolute.html.erb" with:
|
19
|
+
"""
|
20
|
+
<%= link_to "test", "http://google.com/test.html" %>
|
21
|
+
"""
|
22
|
+
And the Server is running at "link-to-app"
|
23
|
+
When I go to "/link_to_absolute.html"
|
24
|
+
Then I should see '<a href="http://google.com/test.html">test</a>'
|
25
|
+
|
8
26
|
Scenario: link_to works with blocks (slim)
|
9
27
|
Given the Server is running at "link-to-app"
|
10
28
|
When I go to "/link_to_slim.html"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Feature: Support srcset property as params for image_tag helper
|
2
|
+
This lets you specify responsive image sizes
|
3
|
+
|
4
|
+
Scenario: Rendering an image with the feature enabled
|
5
|
+
Given the Server is running at "image-srcset-paths-app"
|
6
|
+
When I go to "/image-srcset-paths.html"
|
7
|
+
Then I should see '//example.com/remote-image.jpg 2x, /images/blank_3x.jpg 3x'
|
@@ -33,9 +33,10 @@ Feature: Markdown support in Haml (Kramdown)
|
|
33
33
|
:markdown
|
34
34
|
[A link](/link_target.html)
|
35
35
|
|
36
|
-
![image](blank.gif)
|
36
|
+
![image](blank.gif){: srcset="image_2x.jpg 2x"}
|
37
37
|
"""
|
38
38
|
Given the Server is running at "markdown-in-haml-app"
|
39
39
|
When I go to "/link_and_image/"
|
40
40
|
Then I should see "/link_target/"
|
41
|
+
Then I should see "/images/image_2x.jpg 2x"
|
41
42
|
Then I should see 'src="/images/blank.gif"'
|
@@ -25,3 +25,11 @@ Feature: Allow multiple sources to be setup.
|
|
25
25
|
Then I should see "Data 2: Data 2"
|
26
26
|
Then I should see "Override in Two: Overridden 2"
|
27
27
|
Then I should see "Override in One: Opposite 2"
|
28
|
+
|
29
|
+
Scenario: Set source with destination_dir
|
30
|
+
Given the Server is running at "multiple-sources-with-duplicate-file-names-app"
|
31
|
+
When I go to "/index.html"
|
32
|
+
Then I should see "Default Source"
|
33
|
+
|
34
|
+
When I go to "/source2/index.html"
|
35
|
+
Then I should see "Second Source"
|
@@ -2,8 +2,17 @@
|
|
2
2
|
<title>The Middleman!</title>
|
3
3
|
<% end %>
|
4
4
|
|
5
|
+
<h2>Abs</h2>
|
6
|
+
<p>http://example.com/test.jpg</p>
|
7
|
+
|
5
8
|
<h2>Image url:</h2>
|
6
|
-
<p
|
9
|
+
<p><img src="<%= image_path('100px.jpg') %>"></p>
|
10
|
+
|
11
|
+
<h2>Image url2:</h2>
|
12
|
+
<p><%= image_tag('200px.jpg') %></p>
|
13
|
+
|
14
|
+
<h2>Image url3:</h2>
|
15
|
+
<p><img src="/images/100px.jpg"></p>
|
7
16
|
|
8
17
|
<h2>Autogenerated tests:</h2>
|
9
18
|
<p>images/100px.jpg</p>
|
@@ -1,3 +1,5 @@
|
|
1
|
+
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
|
2
|
+
|
1
3
|
<%= image_tag "blank0.gif" %>
|
2
4
|
<%= image_tag "blank1.gif" %>
|
3
5
|
<%= image_tag "blank2.gif" %>
|
@@ -17,4 +19,24 @@
|
|
17
19
|
<%= image_tag "blank31.gif" %>
|
18
20
|
<%= image_tag "blank32.gif" %>
|
19
21
|
<%= image_tag "blank33.gif" %>
|
20
|
-
<%= image_tag "blank34.gif" %>
|
22
|
+
<%= image_tag "blank34.gif" %>
|
23
|
+
<%= image_tag "blank100.gif" %>
|
24
|
+
<%= image_tag "blank101.gif" %>
|
25
|
+
<%= image_tag "blank102.gif" %>
|
26
|
+
<%= image_tag "blank103.gif" %>
|
27
|
+
<%= image_tag "blank104.gif" %>
|
28
|
+
<%= image_tag "blank1010.gif" %>
|
29
|
+
<%= image_tag "blank1021.gif" %>
|
30
|
+
<%= image_tag "blank1032.gif" %>
|
31
|
+
<%= image_tag "blank1043.gif" %>
|
32
|
+
<%= image_tag "blank1054.gif" %>
|
33
|
+
<%= image_tag "blank1020.gif" %>
|
34
|
+
<%= image_tag "blank1021.gif" %>
|
35
|
+
<%= image_tag "blank1022.gif" %>
|
36
|
+
<%= image_tag "blank1023.gif" %>
|
37
|
+
<%= image_tag "blank1024.gif" %>
|
38
|
+
<%= image_tag "blank1030.gif" %>
|
39
|
+
<%= image_tag "blank1031.gif" %>
|
40
|
+
<%= image_tag "blank1032.gif" %>
|
41
|
+
<%= image_tag "blank1033.gif" %>
|
42
|
+
<%= image_tag "blank1034.gif" %>
|
@@ -1,33 +1,38 @@
|
|
1
1
|
# Proxy ignored.html, which should ignore itself through a frontmatter
|
2
2
|
proxy 'proxied.html', 'ignored.html'
|
3
|
+
proxy 'proxied_with_frontmatter.html', 'ignored.html'
|
3
4
|
page 'override_layout.html', layout: :alternate
|
4
5
|
page 'page_mentioned.html'
|
5
6
|
|
6
7
|
ignore '*.frontmatter'
|
7
8
|
|
8
9
|
# Reads neighbor for every file on every refresh.
|
9
|
-
# TODO: Optimize
|
10
10
|
class NeighborFrontmatter < ::Middleman::Extension
|
11
11
|
self.resource_list_manipulator_priority = 81
|
12
12
|
|
13
13
|
def manipulate_resource_list(resources)
|
14
14
|
resources.each do |resource|
|
15
15
|
next unless resource.source_file
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
opts[:renderer_options].symbolize_keys! if opts.key?(:renderer_options)
|
26
|
-
ignored = fmdata.delete(:ignored)
|
27
|
-
resource.add_metadata options: opts, page: fmdata
|
28
|
-
resource.ignore! if ignored == true && !resource.is_a?(::Middleman::Sitemap::ProxyResource)
|
16
|
+
next if resource.source_file[:relative_path].extname == '.frontmatter'
|
17
|
+
|
18
|
+
[
|
19
|
+
"#{resource.url.sub(/^\//, '')}.frontmatter",
|
20
|
+
"#{resource.source_file[:relative_path]}.frontmatter"
|
21
|
+
].each do |n|
|
22
|
+
file = app.files.find(:source, n)
|
23
|
+
apply_neighbor_data(resource, file) if file
|
24
|
+
end
|
29
25
|
end
|
30
26
|
end
|
27
|
+
|
28
|
+
def apply_neighbor_data(resource, file)
|
29
|
+
fmdata = app.extensions[:front_matter].frontmatter_and_content(file[:full_path]).first
|
30
|
+
opts = fmdata.extract!(:layout, :layout_engine, :renderer_options, :directory_index, :content_type)
|
31
|
+
opts[:renderer_options].symbolize_keys! if opts.key?(:renderer_options)
|
32
|
+
ignored = fmdata.delete(:ignored)
|
33
|
+
resource.add_metadata options: opts, page: fmdata
|
34
|
+
resource.ignore! if ignored == true && !resource.is_a?(::Middleman::Sitemap::ProxyResource)
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
Middleman::Extensions.register :neighbor_frontmatter, NeighborFrontmatter unless Middleman::Extensions.registered.include? :neighbor_frontmatter
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= image_tag 'blank.jpg', srcset: '//example.com/remote-image.jpg 2x, blank_3x.jpg 3x, http://example.com/remoteimage.jpg 4x' %>
|
Binary file
|
@@ -1 +1 @@
|
|
1
|
-
Spaces
|
1
|
+
Filled with Evil Spaces
|
@@ -1 +1 @@
|
|
1
|
-
<%= "spaces" %>
|
1
|
+
<%= "correctly found spaces in file data" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
Default Source
|
@@ -0,0 +1 @@
|
|
1
|
+
Second Source
|
File without changes
|
data/lib/middleman/rack.rb
CHANGED
@@ -30,6 +30,9 @@ require 'middleman-core/template_renderer'
|
|
30
30
|
|
31
31
|
# Core Middleman Class
|
32
32
|
module Middleman
|
33
|
+
MiddlewareDescriptor = Struct.new(:class, :options, :block)
|
34
|
+
MapDescriptor = Struct.new(:path, :block)
|
35
|
+
|
33
36
|
class Application
|
34
37
|
extend Forwardable
|
35
38
|
include Contracts
|
@@ -78,6 +81,14 @@ module Middleman
|
|
78
81
|
define_hook :before_render
|
79
82
|
define_hook :after_render
|
80
83
|
|
84
|
+
# Which host preview should start on.
|
85
|
+
# @return [Fixnum]
|
86
|
+
config.define_setting :host, '0.0.0.0', 'The preview server host'
|
87
|
+
|
88
|
+
# Which port preview should start on.
|
89
|
+
# @return [Fixnum]
|
90
|
+
config.define_setting :port, 4567, 'The preview server port'
|
91
|
+
|
81
92
|
# Name of the source directory
|
82
93
|
# @return [String]
|
83
94
|
config.define_setting :source, 'source', 'Name of the source directory'
|
@@ -180,10 +191,10 @@ module Middleman
|
|
180
191
|
attr_reader :extensions
|
181
192
|
attr_reader :sources
|
182
193
|
|
183
|
-
Contract
|
194
|
+
Contract SetOf[MiddlewareDescriptor]
|
184
195
|
attr_reader :middleware
|
185
196
|
|
186
|
-
Contract
|
197
|
+
Contract SetOf[MapDescriptor]
|
187
198
|
attr_reader :mappings
|
188
199
|
|
189
200
|
# Reference to Logger singleton
|
@@ -191,6 +202,7 @@ module Middleman
|
|
191
202
|
def_delegator :"::Middleman::Util", :instrument
|
192
203
|
def_delegators :"self.class", :root, :root_path
|
193
204
|
def_delegators :@generic_template_context, :link_to, :image_tag, :asset_path
|
205
|
+
def_delegators :@extensions, :activate
|
194
206
|
|
195
207
|
# Initialize the Middleman project
|
196
208
|
def initialize(&block)
|
@@ -293,14 +305,6 @@ module Middleman
|
|
293
305
|
config_context.execute_configure_callbacks(config[:mode])
|
294
306
|
end
|
295
307
|
|
296
|
-
def add_to_instance(name, &func)
|
297
|
-
define_singleton_method(name, &func)
|
298
|
-
end
|
299
|
-
|
300
|
-
def add_to_config_context(name, &func)
|
301
|
-
@config_context.define_singleton_method(name, &func)
|
302
|
-
end
|
303
|
-
|
304
308
|
# Whether we're in server mode
|
305
309
|
# @return [Boolean] If we're in dev mode
|
306
310
|
def server?
|
@@ -342,19 +346,15 @@ module Middleman
|
|
342
346
|
Pathname(File.join(root, config[:source]))
|
343
347
|
end
|
344
348
|
|
345
|
-
MiddlewareDescriptor = Struct.new(:class, :options, :block)
|
346
|
-
|
347
349
|
# Use Rack middleware
|
348
350
|
#
|
349
351
|
# @param [Class] middleware Middleware module
|
350
352
|
# @return [void]
|
351
|
-
Contract Any, Args[Any], Proc => Any
|
353
|
+
# Contract Any, Args[Any], Maybe[Proc] => Any
|
352
354
|
def use(middleware, *args, &block)
|
353
355
|
@middleware << MiddlewareDescriptor.new(middleware, args, block)
|
354
356
|
end
|
355
357
|
|
356
|
-
MapDescriptor = Struct.new(:path, :block)
|
357
|
-
|
358
358
|
# Add Rack App mapped to specific path
|
359
359
|
#
|
360
360
|
# @param [String] map Path to map
|
@@ -12,11 +12,14 @@ module Middleman
|
|
12
12
|
# Make app & events available to `after_build` callbacks.
|
13
13
|
attr_reader :app, :events
|
14
14
|
|
15
|
+
# Reference to the Thor class.
|
16
|
+
attr_accessor :thor
|
17
|
+
|
15
18
|
# Logger comes from App.
|
16
19
|
def_delegator :@app, :logger
|
17
20
|
|
18
21
|
# Sort order, images, fonts, js/css and finally everything else.
|
19
|
-
SORT_ORDER = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .webp .ico .woff .otf .ttf .eot .js .css)
|
22
|
+
SORT_ORDER = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .webp .ico .woff .woff2 .otf .ttf .eot .js .css)
|
20
23
|
|
21
24
|
# Create a new Builder instance.
|
22
25
|
# @param [Middleman::Application] app The app to build.
|
@@ -41,7 +44,7 @@ module Middleman
|
|
41
44
|
|
42
45
|
# Run the build phase.
|
43
46
|
# @return [Boolean] Whether the build was successful.
|
44
|
-
Contract
|
47
|
+
Contract Bool
|
45
48
|
def run!
|
46
49
|
@has_error = false
|
47
50
|
@events = {}
|
@@ -74,7 +77,7 @@ module Middleman
|
|
74
77
|
|
75
78
|
# Pre-request CSS to give Compass a chance to build sprites
|
76
79
|
# @return [Array<Resource>] List of css resources that were output.
|
77
|
-
Contract
|
80
|
+
Contract ResourceList
|
78
81
|
def prerender_css
|
79
82
|
logger.debug '== Prerendering CSS'
|
80
83
|
|
@@ -93,7 +96,7 @@ module Middleman
|
|
93
96
|
|
94
97
|
# Find all the files we need to output and do so.
|
95
98
|
# @return [Array<Resource>] List of resources that were output.
|
96
|
-
Contract
|
99
|
+
Contract ResourceList
|
97
100
|
def output_files
|
98
101
|
logger.debug '== Building files'
|
99
102
|
|
@@ -130,7 +133,8 @@ module Middleman
|
|
130
133
|
def write_tempfile(output_file, contents)
|
131
134
|
file = Tempfile.new([
|
132
135
|
File.basename(output_file),
|
133
|
-
File.extname(output_file)
|
136
|
+
File.extname(output_file)
|
137
|
+
])
|
134
138
|
file.binmode
|
135
139
|
file.write(contents)
|
136
140
|
file.close
|
@@ -205,7 +209,7 @@ module Middleman
|
|
205
209
|
# Get a list of all the paths in the destination folder and save them
|
206
210
|
# for comparison against the files we build in this cycle
|
207
211
|
# @return [void]
|
208
|
-
Contract
|
212
|
+
Contract Any
|
209
213
|
def queue_current_paths
|
210
214
|
@to_clean = []
|
211
215
|
|
@@ -230,7 +234,7 @@ module Middleman
|
|
230
234
|
end
|
231
235
|
|
232
236
|
# Remove files which were not built in this cycle
|
233
|
-
Contract
|
237
|
+
Contract ArrayOf[Pathname]
|
234
238
|
def clean
|
235
239
|
@to_clean.each do |f|
|
236
240
|
FileUtils.rm(f)
|