middleman-core 4.0.0.alpha.2 → 4.0.0.alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/features/asset_hash.feature +26 -8
- data/features/chained_templates.feature +88 -1
- data/features/cli_init.feature +0 -18
- data/features/collections.feature +145 -0
- data/features/console.feature +11 -0
- data/features/front-matter.feature +11 -0
- data/features/paginate.feature +204 -0
- data/features/partials.feature +0 -5
- data/features/slim.feature +1 -1
- data/features/working_directory.feature +33 -0
- data/fixtures/asset-hash-app/source/api.json.erb +1 -0
- data/fixtures/asset-hash-app/source/images/200px.jpg +0 -0
- data/fixtures/asset-hash-app/source/images/300px.jpg +0 -0
- data/fixtures/asset-hash-app/source/index.html.erb +1 -1
- data/fixtures/asset-hash-app/source/subdir/api.json.erb +1 -0
- data/fixtures/collections-app/config.rb +16 -0
- data/fixtures/collections-app/source/blog1/2011-01-01-new-article.html.markdown +7 -0
- data/fixtures/collections-app/source/blog1/2011-01-02-another-article.html.markdown +9 -0
- data/fixtures/collections-app/source/blog2/2011-01-01-new-article.html.markdown +7 -0
- data/fixtures/collections-app/source/blog2/2011-01-02-another-article.html.markdown +8 -0
- data/fixtures/collections-app/source/index.html.erb +26 -0
- data/fixtures/frontmatter-app/source/front-matter-pandoc.html.md.erb +13 -0
- data/fixtures/generator-test/config.rb +2 -7
- data/fixtures/multiple-data-sources-app/source/index.html.erb +0 -5
- data/fixtures/{more-instance-vars-app → paginate-app}/config.rb +0 -0
- data/fixtures/paginate-app/source/archive/2011/index.html.erb +20 -0
- data/fixtures/paginate-app/source/blog/2011-01-01-test-article.html.markdown +6 -0
- data/fixtures/paginate-app/source/blog/2011-01-02-test-article.html.markdown +6 -0
- data/fixtures/paginate-app/source/blog/2011-01-03-test-article.html.markdown +6 -0
- data/fixtures/paginate-app/source/blog/2011-01-04-test-article.html.markdown +6 -0
- data/fixtures/paginate-app/source/blog/2011-01-05-test-article.html.markdown +6 -0
- data/fixtures/paginate-app/source/blog/2011-02-01-test-article.html.markdown +6 -0
- data/fixtures/paginate-app/source/blog/2011-02-02-test-article.html.markdown +6 -0
- data/fixtures/paginate-app/source/index.html.erb +15 -0
- data/fixtures/paginate-app/source/tag.html.erb +23 -0
- data/fixtures/partial-chained_templates-app/config.rb +0 -0
- data/lib/middleman-core/application.rb +28 -1
- data/lib/middleman-core/builder.rb +2 -0
- data/lib/middleman-core/contracts.rb +19 -1
- data/lib/middleman-core/core_extensions.rb +5 -0
- data/lib/middleman-core/core_extensions/collections.rb +82 -0
- data/lib/middleman-core/core_extensions/collections/lazy_root.rb +30 -0
- data/lib/middleman-core/core_extensions/collections/lazy_step.rb +48 -0
- data/lib/middleman-core/core_extensions/collections/pagination.rb +59 -0
- data/lib/middleman-core/core_extensions/collections/step_context.rb +26 -0
- data/lib/middleman-core/core_extensions/data.rb +1 -1
- data/lib/middleman-core/core_extensions/default_helpers.rb +1 -2
- data/lib/middleman-core/core_extensions/front_matter.rb +10 -3
- data/lib/middleman-core/core_extensions/i18n.rb +6 -7
- data/lib/middleman-core/core_extensions/show_exceptions.rb +1 -1
- data/lib/middleman-core/extension.rb +1 -1
- data/lib/middleman-core/extensions/automatic_image_sizes.rb +0 -2
- data/lib/middleman-core/file_renderer.rb +3 -1
- data/lib/middleman-core/load_paths.rb +2 -1
- data/lib/middleman-core/logger.rb +1 -1
- data/lib/middleman-core/meta_pages/sitemap_resource.rb +1 -1
- data/lib/middleman-core/preview_server.rb +1 -1
- data/lib/middleman-core/renderers/sass.rb +1 -1
- data/lib/middleman-core/renderers/slim.rb +2 -2
- data/lib/middleman-core/sitemap/extensions/on_disk.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/proxies.rb +36 -50
- data/lib/middleman-core/sitemap/resource.rb +42 -3
- data/lib/middleman-core/sitemap/store.rb +5 -0
- data/lib/middleman-core/sources.rb +64 -24
- data/lib/middleman-core/sources/source_watcher.rb +47 -23
- data/lib/middleman-core/step_definitions/server_steps.rb +52 -21
- data/lib/middleman-core/template_context.rb +26 -5
- data/lib/middleman-core/template_renderer.rb +50 -33
- data/lib/middleman-core/util.rb +94 -1
- data/lib/middleman-core/util/hash_with_indifferent_access.rb +1 -1
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +2 -0
- metadata +90 -15
- data/features/more-instance_vars.feature +0 -18
- data/fixtures/more-instance-vars-app/source/_vartial.erb +0 -5
- data/fixtures/more-instance-vars-app/source/instance-var-set.html.erb +0 -2
- data/fixtures/more-instance-vars-app/source/layout.erb +0 -3
- data/fixtures/more-instance-vars-app/source/no-instance-var.html.erb +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df87c14bd46ecb73f2fbfe74a09b83089bdac09a
|
|
4
|
+
data.tar.gz: 1e56eb3b6eee26c9b679db3eabde8a8f7a1fa6b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c843a53d609564f5395f22c2d4ea4b52902a7e69fa3073c7d6dde9ca198bb2b9f0973eb37925bbc99e208cc04b84f831827787fda641f58ef092a88b88876109
|
|
7
|
+
data.tar.gz: 17ab0af69079b461b116e942f09d6143a556071ebc7189de70d6b57d111fa4c214a27cdeccb77f2774b1c0522ca2992c64c2277dbf50850b48433a4432788c82
|
data/features/asset_hash.feature
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Feature: Assets get a file hash appended to their and references to them are updated
|
|
2
|
-
Scenario: Hashed-asset files are produced, and HTML, CSS, and JavaScript gets rewritten to reference the new files
|
|
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"
|
|
5
5
|
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
|
|
|
8
8
|
| favicon.ico |
|
|
9
9
|
| images/100px-1242c368.png |
|
|
10
10
|
| images/100px-5fd6fb90.jpg |
|
|
11
|
+
| images/200px-c11eb203.jpg |
|
|
12
|
+
| images/300px-59adce76.jpg |
|
|
11
13
|
| images/100px-5fd6fb90.gif |
|
|
12
14
|
| javascripts/application-1d8d5276.js |
|
|
13
15
|
| stylesheets/site-7474cadd.css |
|
|
14
16
|
| index.html |
|
|
15
17
|
| subdir/index.html |
|
|
16
18
|
| other/index.html |
|
|
19
|
+
| api.json |
|
|
20
|
+
| subdir/api.json |
|
|
17
21
|
And the following files should not exist:
|
|
18
22
|
| images/100px.png |
|
|
19
23
|
| images/100px.jpg |
|
|
@@ -31,11 +35,20 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|
|
31
35
|
And the file "index.html" should contain 'src="javascripts/application-1d8d5276.js"'
|
|
32
36
|
And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"'
|
|
33
37
|
And the file "subdir/index.html" should contain 'href="../stylesheets/site-7474cadd.css"'
|
|
38
|
+
And the file "index.html" should contain 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
|
39
|
+
And the file "index.html" should contain 'src="images/100px-5fd6fb90.gif"'
|
|
40
|
+
And the file "index.html" should contain 'src="images/100px-1242c368.png"'
|
|
34
41
|
And the file "subdir/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
|
35
42
|
And the file "subdir/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
|
36
43
|
And the file "other/index.html" should contain 'href="../stylesheets/site-7474cadd.css"'
|
|
37
44
|
And the file "other/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
|
38
45
|
And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
|
46
|
+
And the file "api.json" should contain 'images/100px-5fd6fb90.gif'
|
|
47
|
+
And the file "api.json" should contain 'images/100px-5fd6fb90.jpg'
|
|
48
|
+
And the file "api.json" should contain 'images/100px-1242c368.png'
|
|
49
|
+
And the file "subdir/api.json" should contain 'images/100px-5fd6fb90.gif'
|
|
50
|
+
And the file "subdir/api.json" should contain 'images/100px-5fd6fb90.jpg'
|
|
51
|
+
And the file "subdir/api.json" should contain 'images/100px-1242c368.png'
|
|
39
52
|
|
|
40
53
|
Scenario: Hashed assets work in preview server
|
|
41
54
|
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
|
|
|
44
57
|
And I should see 'href="stylesheets/site-7474cadd.css"'
|
|
45
58
|
And I should see 'src="javascripts/application-1d8d5276.js"'
|
|
46
59
|
And I should see 'src="images/100px-5fd6fb90.jpg"'
|
|
60
|
+
And I should see 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
|
47
61
|
When I go to "/subdir/"
|
|
48
62
|
Then I should see 'href="../stylesheets/site-7474cadd.css"'
|
|
49
63
|
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
|
|
|
55
69
|
When I go to "/javascripts/application-1d8d5276.js"
|
|
56
70
|
Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
|
|
57
71
|
When I go to "/stylesheets/site-7474cadd.css"
|
|
58
|
-
Then I should see:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg")'
|
|
73
|
+
When I go to "/api.json"
|
|
74
|
+
Then I should see 'images/100px-5fd6fb90.gif'
|
|
75
|
+
And I should see 'images/100px-5fd6fb90.jpg'
|
|
76
|
+
And I should see 'images/100px-1242c368.png'
|
|
77
|
+
When I go to "/subdir/api.json"
|
|
78
|
+
Then I should see 'images/100px-5fd6fb90.gif'
|
|
79
|
+
And I should see 'images/100px-5fd6fb90.jpg'
|
|
80
|
+
And I should see 'images/100px-1242c368.png'
|
|
62
81
|
|
|
63
82
|
Scenario: Enabling an asset host still produces hashed files and references
|
|
64
83
|
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
|
|
|
71
90
|
When I go to "/other/"
|
|
72
91
|
Then I should see 'href="http://middlemanapp.com/stylesheets/site-1fdf4fb5.css"'
|
|
73
92
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
|
74
|
-
# Asset helpers don't appear to work from Compass right now
|
|
75
|
-
# When I go to "/stylesheets/site-e5a31a3e.css"
|
|
76
|
-
# Then I should see "background-image: url('http://middlemanapp.com/images/100px-5fd6fb90.jpg')"
|
|
77
93
|
|
|
78
94
|
Scenario: The asset hash should change when a SASS partial changes
|
|
79
95
|
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
|
|
|
138
154
|
| index.html |
|
|
139
155
|
| subdir/index.html |
|
|
140
156
|
| other/index.html |
|
|
157
|
+
| api.json |
|
|
158
|
+
| subdir/api.json |
|
|
141
159
|
And the following files should not exist:
|
|
142
160
|
| images/100px-1242c368.png |
|
|
143
161
|
| images/100px-5fd6fb90.jpg |
|
|
@@ -16,4 +16,91 @@ Feature: Templates should be chainable
|
|
|
16
16
|
|
|
17
17
|
And the file "index.html" should contain "Title</h1>"
|
|
18
18
|
And the file "index.html" should contain "Subtitle</h2>"
|
|
19
|
-
And the file "index.html" should contain "Sup</h3>"
|
|
19
|
+
And the file "index.html" should contain "Sup</h3>"
|
|
20
|
+
|
|
21
|
+
Scenario: Partials are parsed by multiple template engines: Outer template has .erb and inner .md.erb
|
|
22
|
+
Given a fixture app "partial-chained_templates-app"
|
|
23
|
+
And a template named "my_template.html.erb" with:
|
|
24
|
+
"""
|
|
25
|
+
<h1>My Template</h1>
|
|
26
|
+
|
|
27
|
+
<%= partial 'my_partial' %>
|
|
28
|
+
"""
|
|
29
|
+
And a template named "my_partial.html.md.erb" with:
|
|
30
|
+
"""
|
|
31
|
+
## My Partial
|
|
32
|
+
|
|
33
|
+
<%= 'hello world' %>
|
|
34
|
+
"""
|
|
35
|
+
And the Server is running
|
|
36
|
+
When I go to "/my_template.html"
|
|
37
|
+
Then I should see:
|
|
38
|
+
"""
|
|
39
|
+
<h1>My Template</h1>
|
|
40
|
+
"""
|
|
41
|
+
Then I should see:
|
|
42
|
+
"""
|
|
43
|
+
<h2 id="my-partial">My Partial</h2>
|
|
44
|
+
"""
|
|
45
|
+
Then I should see:
|
|
46
|
+
"""
|
|
47
|
+
<p>hello world</p>
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
Scenario: Partials are parsed by multiple template engines: Outer template has .md.erb and inner .md.erb
|
|
51
|
+
Given a fixture app "partial-chained_templates-app"
|
|
52
|
+
And a template named "my_template.html.md.erb" with:
|
|
53
|
+
"""
|
|
54
|
+
# My Template
|
|
55
|
+
|
|
56
|
+
<%= partial 'my_partial' %>
|
|
57
|
+
"""
|
|
58
|
+
And a template named "my_partial.html.md.erb" with:
|
|
59
|
+
"""
|
|
60
|
+
## My Partial
|
|
61
|
+
|
|
62
|
+
<%= 'hello world' %>
|
|
63
|
+
"""
|
|
64
|
+
And the Server is running
|
|
65
|
+
When I go to "/my_template.html"
|
|
66
|
+
Then I should see:
|
|
67
|
+
"""
|
|
68
|
+
<h1 id="my-template">My Template</h1>
|
|
69
|
+
"""
|
|
70
|
+
Then I should see:
|
|
71
|
+
"""
|
|
72
|
+
<h2 id="my-partial">My Partial</h2>
|
|
73
|
+
"""
|
|
74
|
+
Then I should see:
|
|
75
|
+
"""
|
|
76
|
+
<p>hello world</p>
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
Scenario: Partials are parsed by multiple template engines: Outer template has .md.erb, and inner .erb
|
|
80
|
+
Given a fixture app "partial-chained_templates-app"
|
|
81
|
+
And a template named "my_template.html.md.erb" with:
|
|
82
|
+
"""
|
|
83
|
+
# My Template
|
|
84
|
+
|
|
85
|
+
<%= partial 'my_partial' %>
|
|
86
|
+
"""
|
|
87
|
+
And a template named "my_partial.html.erb" with:
|
|
88
|
+
"""
|
|
89
|
+
<h2>My Partial</h2>
|
|
90
|
+
|
|
91
|
+
<%= 'hello world' %>
|
|
92
|
+
"""
|
|
93
|
+
And the Server is running
|
|
94
|
+
When I go to "/my_template.html"
|
|
95
|
+
Then I should see:
|
|
96
|
+
"""
|
|
97
|
+
<h1 id="my-template">My Template</h1>
|
|
98
|
+
"""
|
|
99
|
+
Then I should see:
|
|
100
|
+
"""
|
|
101
|
+
<h2>My Partial</h2>
|
|
102
|
+
"""
|
|
103
|
+
Then I should see:
|
|
104
|
+
"""
|
|
105
|
+
<p>hello world</p>
|
|
106
|
+
"""
|
data/features/cli_init.feature
CHANGED
|
@@ -37,21 +37,3 @@ Feature: Middleman CLI
|
|
|
37
37
|
Scenario: Create a new project (alias n)
|
|
38
38
|
When I run `middleman n MY_PROJECT`
|
|
39
39
|
Then a directory named "MY_PROJECT" should exist
|
|
40
|
-
|
|
41
|
-
# Scenario: Create a new HTML5 project
|
|
42
|
-
# When I run `middleman init MY_PROJECT --template=html5`
|
|
43
|
-
# Then a directory named "MY_PROJECT" should exist
|
|
44
|
-
# When I cd to "MY_PROJECT"
|
|
45
|
-
# Then the following files should exist:
|
|
46
|
-
# | config.rb |
|
|
47
|
-
# | Gemfile |
|
|
48
|
-
# Then the following files should not exist:
|
|
49
|
-
# | config.ru |
|
|
50
|
-
# And the file "config.rb" should contain "set :js_dir, 'js'"
|
|
51
|
-
# Then a directory named "source" should exist
|
|
52
|
-
# When I cd to "source"
|
|
53
|
-
# Then the following files should exist:
|
|
54
|
-
# | index.html.erb |
|
|
55
|
-
# | layouts/layout.erb |
|
|
56
|
-
# | humans.txt |
|
|
57
|
-
# | js/main.js |
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Feature: Collections
|
|
2
|
+
Scenario: Lazy query
|
|
3
|
+
Given a fixture app "collections-app"
|
|
4
|
+
And a file named "config.rb" with:
|
|
5
|
+
"""
|
|
6
|
+
articles1 = collection :articles1, resources.select { |r|
|
|
7
|
+
matcher = ::Middleman::Util::UriTemplates.uri_template('blog1/{year}-{month}-{day}-{title}.html')
|
|
8
|
+
::Middleman::Util::UriTemplates.extract_params(matcher, ::Middleman::Util.normalize_path(r.url))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
everything = resources.select do |r|
|
|
12
|
+
true
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_tags(resource)
|
|
16
|
+
if resource.data.tags.is_a? String
|
|
17
|
+
resource.data.tags.split(',').map(&:strip)
|
|
18
|
+
else
|
|
19
|
+
resource.data.tags
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def group_lookup(resource, sum)
|
|
24
|
+
results = Array(get_tags(resource)).map(&:to_s).map(&:to_sym)
|
|
25
|
+
|
|
26
|
+
results.each do |k|
|
|
27
|
+
sum[k] ||= []
|
|
28
|
+
sum[k] << resource
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
tags = everything
|
|
33
|
+
.select { |resource| resource.data.tags }
|
|
34
|
+
.each_with_object({}, &method(:group_lookup))
|
|
35
|
+
|
|
36
|
+
class Wrapper
|
|
37
|
+
attr_reader :stuff
|
|
38
|
+
|
|
39
|
+
def initialize
|
|
40
|
+
@stuff = Set.new
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def <<((k, v))
|
|
44
|
+
@stuff << k
|
|
45
|
+
self
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
collection :wrapped, tags.reduce(Wrapper.new, :<<)
|
|
50
|
+
|
|
51
|
+
set :tags, tags # Expose to templates
|
|
52
|
+
|
|
53
|
+
collection :first_tag, tags.keys.sort.first
|
|
54
|
+
"""
|
|
55
|
+
And a file named "source/index.html.erb" with:
|
|
56
|
+
"""
|
|
57
|
+
<% collection(:articles1).each do |article| %>
|
|
58
|
+
Article1: <%= article.data.title %>
|
|
59
|
+
<% end %>
|
|
60
|
+
|
|
61
|
+
Tag Count: <%= collection(:wrapped).stuff.length %>
|
|
62
|
+
|
|
63
|
+
<% config[:tags].value.each do |k, items| %>
|
|
64
|
+
Tag: <%= k %> (<%= items.length %>)
|
|
65
|
+
<% items.each do |article| %>
|
|
66
|
+
Article (<%= k %>): <%= article.data.title %>
|
|
67
|
+
<% end %>
|
|
68
|
+
<% end %>
|
|
69
|
+
|
|
70
|
+
First Tag: <%= collection(:first_tag) %>
|
|
71
|
+
"""
|
|
72
|
+
Given the Server is running at "collections-app"
|
|
73
|
+
When I go to "index.html"
|
|
74
|
+
Then I should see 'Article1: Blog1 Newer Article'
|
|
75
|
+
And I should see 'Article1: Blog1 Another Article'
|
|
76
|
+
And I should see 'Tag: foo (4)'
|
|
77
|
+
And I should see 'Article (foo): Blog1 Newer Article'
|
|
78
|
+
And I should see 'Article (foo): Blog1 Another Article'
|
|
79
|
+
And I should see 'Article (foo): Blog2 Newer Article'
|
|
80
|
+
And I should see 'Article (foo): Blog2 Another Article'
|
|
81
|
+
And I should see 'Tag: bar (2)'
|
|
82
|
+
And I should see 'Article (bar): Blog1 Newer Article'
|
|
83
|
+
And I should see 'Article (bar): Blog2 Newer Article'
|
|
84
|
+
And I should see 'Tag: 120 (1)'
|
|
85
|
+
And I should see 'Article (120): Blog1 Another Article'
|
|
86
|
+
And I should see 'First Tag: 120'
|
|
87
|
+
And I should see 'Tag Count: 3'
|
|
88
|
+
|
|
89
|
+
Scenario: Collected resources update with file changes
|
|
90
|
+
Given a fixture app "collections-app"
|
|
91
|
+
And a file named "config.rb" with:
|
|
92
|
+
"""
|
|
93
|
+
collection :articles, resources.select { |r|
|
|
94
|
+
matcher = ::Middleman::Util::UriTemplates.uri_template('blog2/{year}-{month}-{day}-{title}.html')
|
|
95
|
+
::Middleman::Util::UriTemplates.extract_params(matcher, ::Middleman::Util.normalize_path(r.url))
|
|
96
|
+
}
|
|
97
|
+
"""
|
|
98
|
+
And a file named "source/index.html.erb" with:
|
|
99
|
+
"""
|
|
100
|
+
<% collection(:articles).each do |article| %>
|
|
101
|
+
Article: <%= article.data.title || article.source_file[:relative_path] %>
|
|
102
|
+
<% end %>
|
|
103
|
+
"""
|
|
104
|
+
Given the Server is running at "collections-app"
|
|
105
|
+
When I go to "index.html"
|
|
106
|
+
Then I should not see "Article: index.html.erb"
|
|
107
|
+
Then I should see 'Article: Blog2 Newer Article'
|
|
108
|
+
And I should see 'Article: Blog2 Another Article'
|
|
109
|
+
|
|
110
|
+
And the file "source/blog2/2011-01-02-another-article.html.markdown" has the contents
|
|
111
|
+
"""
|
|
112
|
+
---
|
|
113
|
+
title: "Blog3 Another Article"
|
|
114
|
+
date: 2011-01-02
|
|
115
|
+
tags:
|
|
116
|
+
- foo
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
Another Article Content
|
|
120
|
+
|
|
121
|
+
"""
|
|
122
|
+
When I go to "index.html"
|
|
123
|
+
Then I should see "Article: Blog2 Newer Article"
|
|
124
|
+
And I should not see "Article: Blog2 Another Article"
|
|
125
|
+
And I should see 'Article: Blog3 Another Article'
|
|
126
|
+
|
|
127
|
+
And the file "source/blog2/2011-01-01-new-article.html.markdown" is removed
|
|
128
|
+
When I go to "index.html"
|
|
129
|
+
Then I should not see "Article: Blog2 Newer Article"
|
|
130
|
+
And I should see 'Article: Blog3 Another Article'
|
|
131
|
+
|
|
132
|
+
And the file "source/blog2/2014-01-02-yet-another-article.html.markdown" has the contents
|
|
133
|
+
"""
|
|
134
|
+
---
|
|
135
|
+
title: "Blog2 Yet Another Article"
|
|
136
|
+
date: 2011-01-02
|
|
137
|
+
tags:
|
|
138
|
+
- foo
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
Yet Another Article Content
|
|
142
|
+
"""
|
|
143
|
+
When I go to "index.html"
|
|
144
|
+
And I should see 'Article: Blog3 Another Article'
|
|
145
|
+
And I should see 'Article: Blog2 Yet Another Article'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Feature: Console
|
|
2
|
+
|
|
3
|
+
Scenario: Enter and exit the console
|
|
4
|
+
Given a fixture app "large-build-app"
|
|
5
|
+
When I run `middleman console` interactively
|
|
6
|
+
And I type "puts 'Hello from the console.'"
|
|
7
|
+
And I type "exit"
|
|
8
|
+
Then it should pass with:
|
|
9
|
+
"""
|
|
10
|
+
Hello from the console.
|
|
11
|
+
"""
|
|
@@ -18,6 +18,17 @@ Feature: YAML Front Matter
|
|
|
18
18
|
Then I should see "<?php"
|
|
19
19
|
Then I should not see "---"
|
|
20
20
|
|
|
21
|
+
Scenario: Rendering markdown (template-less) (yaml)
|
|
22
|
+
Given the Server is running at "frontmatter-app"
|
|
23
|
+
When I go to "/front-matter-pandoc.html"
|
|
24
|
+
Then I should see ">This is a document</h1>"
|
|
25
|
+
Then I should see "<p>To be or not to be</p>"
|
|
26
|
+
Then I should see "The meaning of life is 42"
|
|
27
|
+
Then I should not see "..."
|
|
28
|
+
Then I should not see "layout: false"
|
|
29
|
+
Then I should not see "title: Pandoc likes trailing dots..."
|
|
30
|
+
|
|
31
|
+
|
|
21
32
|
Scenario: YAML not on first line, no encoding
|
|
22
33
|
Given the Server is running at "frontmatter-app"
|
|
23
34
|
When I go to "/front-matter-line-2.html"
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Feature: Pagination
|
|
2
|
+
Scenario: Basic configuration
|
|
3
|
+
Given a fixture app "paginate-app"
|
|
4
|
+
And a file named "config.rb" with:
|
|
5
|
+
"""
|
|
6
|
+
articles = resources.select { |r|
|
|
7
|
+
matcher = ::Middleman::Util::UriTemplates.uri_template('blog/2011-{remaining}')
|
|
8
|
+
::Middleman::Util::UriTemplates.extract_params(matcher, ::Middleman::Util.normalize_path(r.url))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
articles.sort { |a, b|
|
|
12
|
+
b.data.date <=> a.data.date
|
|
13
|
+
}.per_page(5) do |items, num, meta, is_last|
|
|
14
|
+
page_path = num == 1 ? '/2011/index.html' : "/2011/page/#{num}.html"
|
|
15
|
+
|
|
16
|
+
prev_page = case num
|
|
17
|
+
when 1
|
|
18
|
+
nil
|
|
19
|
+
when 2
|
|
20
|
+
'/2011/index.html'
|
|
21
|
+
when 3
|
|
22
|
+
"/2011/page/#{num-1}.html"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
next_page = is_last ? nil : "/2011/page/#{num+1}.html"
|
|
26
|
+
|
|
27
|
+
proxy page_path, "/archive/2011/index.html", locals: {
|
|
28
|
+
items: items,
|
|
29
|
+
pagination: meta,
|
|
30
|
+
prev_page: prev_page,
|
|
31
|
+
next_page: next_page
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def get_tags(resource)
|
|
36
|
+
if resource.data.tags.is_a? String
|
|
37
|
+
resource.data.tags.split(',').map(&:strip)
|
|
38
|
+
else
|
|
39
|
+
resource.data.tags
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def group_lookup(resource, sum)
|
|
44
|
+
results = Array(get_tags(resource)).map(&:to_s).map(&:to_sym)
|
|
45
|
+
|
|
46
|
+
results.each do |k|
|
|
47
|
+
sum[k] ||= []
|
|
48
|
+
sum[k] << resource
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
tags = articles
|
|
53
|
+
.select { |resource| resource.data.tags }
|
|
54
|
+
.each_with_object({}, &method(:group_lookup))
|
|
55
|
+
|
|
56
|
+
tags.each do |k, articles_in_tag|
|
|
57
|
+
articles_in_tag.sort { |a, b|
|
|
58
|
+
b.data.date <=> a.data.date
|
|
59
|
+
}.per_page(2).each do |items, num, meta, is_last|
|
|
60
|
+
page_path = num == 1 ? "/tags/#{k}.html" : "/tags/#{k}/page/#{num}.html"
|
|
61
|
+
|
|
62
|
+
prev_page = case num
|
|
63
|
+
when 1
|
|
64
|
+
nil
|
|
65
|
+
when 2
|
|
66
|
+
"/tags/#{k}.html"
|
|
67
|
+
when 3
|
|
68
|
+
"/tags/#{k}/page/#{num-1}.html"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
next_page = is_last ? nil : "/tags/#{k}/page/#{num+1}.html"
|
|
72
|
+
|
|
73
|
+
proxy page_path, "/archive/2011/index.html", locals: {
|
|
74
|
+
items: items,
|
|
75
|
+
pagination: meta,
|
|
76
|
+
prev_page: prev_page,
|
|
77
|
+
next_page: next_page
|
|
78
|
+
}
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
"""
|
|
82
|
+
And the Server is running
|
|
83
|
+
When I go to "/2011/index.html"
|
|
84
|
+
Then I should see "Paginate: true"
|
|
85
|
+
Then I should see "Article Count: 5"
|
|
86
|
+
Then I should see "Page Num: 1"
|
|
87
|
+
Then I should see "Num Pages: 2"
|
|
88
|
+
Then I should see "Per Page: 5"
|
|
89
|
+
Then I should see "Page Start: 1"
|
|
90
|
+
Then I should see "Page End: 5"
|
|
91
|
+
Then I should see "Next Page: '/2011/page/2.html'"
|
|
92
|
+
Then I should see "Prev Page: ''"
|
|
93
|
+
Then I should not see "/blog/2011-01-01-test-article.html"
|
|
94
|
+
Then I should not see "/blog/2011-01-02-test-article.html"
|
|
95
|
+
Then I should see "/blog/2011-01-03-test-article.html"
|
|
96
|
+
Then I should see "/blog/2011-01-04-test-article.html"
|
|
97
|
+
Then I should see "/blog/2011-01-05-test-article.html"
|
|
98
|
+
Then I should see "/blog/2011-02-01-test-article.html"
|
|
99
|
+
Then I should see "/blog/2011-02-02-test-article.html"
|
|
100
|
+
|
|
101
|
+
When I go to "/2011/page/2.html"
|
|
102
|
+
Then I should see "Article Count: 2"
|
|
103
|
+
Then I should see "Page Num: 2"
|
|
104
|
+
Then I should see "Page Start: 6"
|
|
105
|
+
Then I should see "Page End: 7"
|
|
106
|
+
Then I should see "Next Page: ''"
|
|
107
|
+
Then I should see "Prev Page: '/2011/'"
|
|
108
|
+
Then I should see "/2011-01-01-test-article.html"
|
|
109
|
+
Then I should see "/2011-01-02-test-article.html"
|
|
110
|
+
Then I should not see "/2011-01-03-test-article.html"
|
|
111
|
+
Then I should not see "/2011-01-04-test-article.html"
|
|
112
|
+
Then I should not see "/2011-01-05-test-article.html"
|
|
113
|
+
Then I should not see "/2011-02-01-test-article.html"
|
|
114
|
+
Then I should not see "/2011-02-02-test-article.html"
|
|
115
|
+
|
|
116
|
+
When I go to "/tags/bar.html"
|
|
117
|
+
Then I should see "Paginate: true"
|
|
118
|
+
Then I should see "Article Count: 2"
|
|
119
|
+
Then I should see "Page Num: 1"
|
|
120
|
+
Then I should see "Num Pages: 3"
|
|
121
|
+
Then I should see "Per Page: 2"
|
|
122
|
+
Then I should see "Page Start: 1"
|
|
123
|
+
Then I should see "Page End: 2"
|
|
124
|
+
Then I should see "Next Page: '/tags/bar/page/2.html'"
|
|
125
|
+
Then I should see "Prev Page: ''"
|
|
126
|
+
Then I should see "/2011-02-02-test-article.html"
|
|
127
|
+
Then I should see "/2011-02-01-test-article.html"
|
|
128
|
+
Then I should not see "/2011-02-05-test-article.html"
|
|
129
|
+
Then I should not see "/2011-01-04-test-article.html"
|
|
130
|
+
Then I should not see "/2011-01-03-test-article.html"
|
|
131
|
+
|
|
132
|
+
Scenario: Custom pager method
|
|
133
|
+
Given a fixture app "paginate-app"
|
|
134
|
+
And a file named "config.rb" with:
|
|
135
|
+
"""
|
|
136
|
+
def items_per_page(all_items)
|
|
137
|
+
[
|
|
138
|
+
all_items.shift(2),
|
|
139
|
+
all_items
|
|
140
|
+
]
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
articles = resources.select { |r|
|
|
144
|
+
matcher = ::Middleman::Util::UriTemplates.uri_template('blog/2011-{remaining}')
|
|
145
|
+
::Middleman::Util::UriTemplates.extract_params(matcher, ::Middleman::Util.normalize_path(r.url))
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
articles.sort { |a, b|
|
|
149
|
+
b.data.date <=> a.data.date
|
|
150
|
+
}.per_page(method(:items_per_page).to_proc).each do |items, num, meta, is_last|
|
|
151
|
+
page_path = num == 1 ? '/2011/index.html' : "/2011/page/#{num}.html"
|
|
152
|
+
|
|
153
|
+
prev_page = case num
|
|
154
|
+
when 1
|
|
155
|
+
nil
|
|
156
|
+
when 2
|
|
157
|
+
'/2011/index.html'
|
|
158
|
+
when 3
|
|
159
|
+
"/2011/page/#{num-1}.html"
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
next_page = is_last ? nil : "/2011/page/#{num+1}.html"
|
|
163
|
+
|
|
164
|
+
proxy page_path, "/archive/2011/index.html", locals: {
|
|
165
|
+
items: items,
|
|
166
|
+
pagination: meta,
|
|
167
|
+
prev_page: prev_page,
|
|
168
|
+
next_page: next_page
|
|
169
|
+
}
|
|
170
|
+
end
|
|
171
|
+
"""
|
|
172
|
+
And the Server is running
|
|
173
|
+
When I go to "/2011/index.html"
|
|
174
|
+
Then I should see "Paginate: true"
|
|
175
|
+
Then I should see "Article Count: 2"
|
|
176
|
+
Then I should see "Page Num: 1"
|
|
177
|
+
Then I should see "Num Pages: 2"
|
|
178
|
+
Then I should see "Per Page: 2"
|
|
179
|
+
Then I should see "Page Start: 1"
|
|
180
|
+
Then I should see "Page End: 2"
|
|
181
|
+
Then I should see "Next Page: '/2011/page/2.html'"
|
|
182
|
+
Then I should see "Prev Page: ''"
|
|
183
|
+
Then I should not see "/blog/2011-01-01-test-article.html"
|
|
184
|
+
Then I should not see "/blog/2011-01-02-test-article.html"
|
|
185
|
+
Then I should not see "/blog/2011-01-03-test-article.html"
|
|
186
|
+
Then I should not see "/blog/2011-01-04-test-article.html"
|
|
187
|
+
Then I should not see "/blog/2011-01-05-test-article.html"
|
|
188
|
+
Then I should see "/blog/2011-02-01-test-article.html"
|
|
189
|
+
Then I should see "/blog/2011-02-02-test-article.html"
|
|
190
|
+
|
|
191
|
+
When I go to "/2011/page/2.html"
|
|
192
|
+
Then I should see "Article Count: 5"
|
|
193
|
+
Then I should see "Page Num: 2"
|
|
194
|
+
Then I should see "Page Start: 3"
|
|
195
|
+
Then I should see "Page End: 7"
|
|
196
|
+
Then I should see "Next Page: ''"
|
|
197
|
+
Then I should see "Prev Page: '/2011/'"
|
|
198
|
+
Then I should see "/2011-01-01-test-article.html"
|
|
199
|
+
Then I should see "/2011-01-02-test-article.html"
|
|
200
|
+
Then I should see "/2011-01-03-test-article.html"
|
|
201
|
+
Then I should see "/2011-01-04-test-article.html"
|
|
202
|
+
Then I should see "/2011-01-05-test-article.html"
|
|
203
|
+
Then I should not see "/2011-02-01-test-article.html"
|
|
204
|
+
Then I should not see "/2011-02-02-test-article.html"
|