middleman-blog 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +16 -0
- data/.gitignore +5 -1
- data/.travis.yml +33 -19
- data/.yardopts +2 -2
- data/CHANGELOG.md +51 -24
- data/CONTRIBUTING.md +5 -2
- data/Gemfile +23 -16
- data/ISSUE_TEMPLATE.md +14 -0
- data/LICENSE.md +15 -17
- data/README.md +52 -14
- data/Rakefile +10 -7
- data/features/article_dirs.feature +34 -0
- data/features/blog_sources.feature +35 -6
- data/features/filename_date.feature +4 -2
- data/features/language.feature +108 -77
- data/features/layouts.feature +3 -0
- data/features/multiblog.feature +1 -1
- data/features/next_previous.feature +10 -7
- data/features/permalink.feature +17 -0
- data/features/summary.feature +26 -2
- data/features/support/env.rb +7 -4
- data/features/support/time_steps.rb +7 -3
- data/features/tags.feature +68 -34
- data/fixtures/article-dirs-app/config-directory-indexes.rb +6 -0
- data/fixtures/article-dirs-app/config-permalink-with-dot.rb +6 -0
- data/fixtures/blog-sources-app/config.rb +6 -3
- data/fixtures/blog-sources-app/source/blog/2011-01-01-new-article.html.markdown +5 -3
- data/fixtures/blog-sources-app/source/blog/2013-08-08-slug-from-filename.html.markdown +5 -3
- data/fixtures/blog-sources-app/source/index.html.erb +12 -8
- data/fixtures/blog-sources-app/source/layout.erb +21 -10
- data/fixtures/blog-sources-no-date-app/config.rb +6 -0
- data/fixtures/blog-sources-no-date-app/source/blog/new-article.html.markdown +8 -0
- data/fixtures/blog-sources-no-date-app/source/index.html.erb +13 -0
- data/fixtures/blog-sources-no-date-app/source/layout.erb +24 -0
- data/fixtures/blog-sources-no-day-app/config.rb +6 -0
- data/fixtures/blog-sources-no-day-app/source/2012-08-testing.html.markdown +8 -0
- data/fixtures/blog-sources-no-day-app/source/layout.erb +24 -0
- data/fixtures/{no-title-app → blog-sources-no-title-app}/config.rb +3 -0
- data/fixtures/blog-sources-no-title-app/source/2013-08-07.html.markdown +8 -0
- data/fixtures/blog-sources-no-title-app/source/2013-08-08.html.markdown +9 -0
- data/fixtures/{no-date-app → blog-sources-no-title-app}/source/layout.erb +11 -0
- data/fixtures/blog-sources-subdirs-app/config.rb +6 -3
- data/fixtures/blog-sources-subdirs-app/source/blog.html.erb +6 -3
- data/fixtures/blog-sources-subdirs-app/source/blog/another-post.html.markdown +9 -0
- data/fixtures/blog-sources-subdirs-app/source/blog/subdir/yet-another-post.html.markdown +9 -0
- data/fixtures/blog-sources-subdirs-app/source/layout.erb +24 -1
- data/fixtures/calendar-app/config-directory-indexes.rb +6 -4
- data/fixtures/calendar-app/config-only-year.rb +8 -6
- data/fixtures/calendar-app/config.rb +6 -4
- data/fixtures/calendar-app/source/layout.erb +17 -12
- data/fixtures/language-app/locales/en.yml +5 -4
- data/fixtures/language-app/locales/ru.yml +5 -4
- data/fixtures/language-app/source/2013-09-05-previous-english-article.html.erb +9 -0
- data/fixtures/language-app/source/2013-09-06-previous-russian-article.html.erb +9 -0
- data/fixtures/language-app/source/2013-09-07-english-article-with-lang-in-frontmatter.html.erb +5 -2
- data/fixtures/language-app/source/2013-09-07-russian-article-with-lang-in-frontmatter.html.erb +5 -2
- data/fixtures/language-app/source/2013-09-08-next-russian-article.html.erb +9 -0
- data/fixtures/language-app/source/2013-09-09-next-english-article.html.erb +9 -0
- data/fixtures/language-app/source/layouts/layout.erb +12 -1
- data/fixtures/language-app/source/localizable/index.html.erb +3 -1
- data/fixtures/layouts-app/source/2011/01/01/fourth-article.html.markdown +7 -0
- data/fixtures/paginate-app/config-directory-indexes.rb +14 -12
- data/fixtures/paginate-app/config-paginate-off.rb +14 -12
- data/fixtures/paginate-app/config.rb +16 -13
- data/fixtures/permalink-app/config.rb +7 -0
- data/fixtures/permalink-app/source/index.html.erb +13 -0
- data/fixtures/permalink-app/source/layout.erb +26 -0
- data/fixtures/permalink-app/source/news/2011-01-01-new-article.html.markdown +9 -0
- data/fixtures/summary-app/source/2013-05-08-article-with-custom-separator.html.markdown +1 -1
- data/fixtures/summary-app/source/2016-05-21-article-with-comment-separator.html.markdown +7 -0
- data/fixtures/tags-app/config-directory-indexes.rb +2 -1
- data/fixtures/tags-app/config-filters.rb +8 -0
- data/fixtures/tags-app/config-no-tags.rb +5 -3
- data/fixtures/tags-app/config.rb +2 -1
- data/fixtures/tags-app/source/blog/2011-01-03-no-taga.html.markdown +6 -0
- data/lib/middleman-blog.rb +7 -4
- data/lib/middleman-blog/blog_article.rb +157 -34
- data/lib/middleman-blog/blog_data.rb +83 -29
- data/lib/middleman-blog/calendar_pages.rb +1 -1
- data/lib/middleman-blog/commands/article.rb +88 -30
- data/lib/middleman-blog/commands/article.tt +4 -1
- data/lib/middleman-blog/custom_pages.rb +1 -1
- data/lib/middleman-blog/helpers.rb +2 -2
- data/lib/middleman-blog/paginator.rb +5 -4
- data/lib/middleman-blog/tag_pages.rb +61 -24
- data/lib/middleman-blog/truncate_html.rb +4 -9
- data/lib/middleman-blog/uri_templates.rb +44 -30
- data/lib/middleman-blog/version.rb +3 -1
- data/middleman-blog.gemspec +19 -17
- data/spec/spec_helper.rb +1 -1
- data/spec/uri_templates_spec.rb +21 -6
- metadata +68 -52
- data/.gemtest +0 -0
- data/features/no_date.feature +0 -9
- data/features/permalink-data.feature +0 -12
- data/fixtures/blog-sources-app/source/_article_template.erb +0 -1
- data/fixtures/blog-sources-subdirs-app/source/blog/another-post.html.md.erb +0 -8
- data/fixtures/blog-sources-subdirs-app/source/blog/subdir/yet-another-post.html.md.erb +0 -8
- data/fixtures/no-date-app/config.rb +0 -3
- data/fixtures/no-date-app/source/_article_template.erb +0 -1
- data/fixtures/no-date-app/source/blog/new-article.html.markdown +0 -6
- data/fixtures/no-date-app/source/index.html.erb +0 -9
- data/fixtures/no-day-app/config.rb +0 -3
- data/fixtures/no-day-app/source/2012-08-testing.html.markdown +0 -6
- data/fixtures/no-day-app/source/layout.erb +0 -13
- data/fixtures/no-title-app/source/2013-08-07.html.markdown +0 -6
- data/fixtures/no-title-app/source/2013-08-08.html.markdown +0 -7
- data/fixtures/no-title-app/source/layout.erb +0 -13
- data/fixtures/permalink-data-app/config.rb +0 -5
- data/fixtures/permalink-data-app/source/index.html.erb +0 -3
- data/fixtures/permalink-data-app/source/layout.erb +0 -14
- data/fixtures/permalink-data-app/source/news/2011-01-01-new-article.html.markdown +0 -7
data/features/support/env.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'simplecov'
|
2
|
+
|
2
3
|
SimpleCov.start do
|
3
4
|
add_filter "/features/"
|
4
5
|
end
|
@@ -6,10 +7,12 @@ end
|
|
6
7
|
require 'coveralls'
|
7
8
|
Coveralls.wear!
|
8
9
|
|
9
|
-
ENV["TEST"]
|
10
|
-
ENV["AUTOLOAD_SPROCKETS"] = "false"
|
10
|
+
ENV[ "TEST" ] = "true"
|
11
|
+
ENV[ "AUTOLOAD_SPROCKETS" ] = "false"
|
12
|
+
|
13
|
+
PROJECT_ROOT_PATH = File.dirname( File.dirname( File.dirname( __FILE__ ) ) )
|
11
14
|
|
12
|
-
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
13
15
|
require "middleman-core"
|
14
16
|
require "middleman-core/step_definitions"
|
15
|
-
|
17
|
+
|
18
|
+
require File.join( PROJECT_ROOT_PATH, 'lib', 'middleman-blog' )
|
@@ -3,11 +3,11 @@ require 'active_support/core_ext/time/calculations'
|
|
3
3
|
|
4
4
|
Time.zone = "UTC" if Time.zone.nil?
|
5
5
|
|
6
|
-
Given /the timezone is "(.+?)"$/ do |zone|
|
7
|
-
|
6
|
+
Given /the timezone is "(.+?)"$/ do | zone |
|
7
|
+
Time.zone = zone
|
8
8
|
end
|
9
9
|
|
10
|
-
Given /the (date|time|date and time) is (.+?)$/ do |datetime, value|
|
10
|
+
Given /the (date|time|date and time) is (.+?)$/ do | datetime, value |
|
11
11
|
time = case datetime
|
12
12
|
when "date"
|
13
13
|
Date.parse(value)
|
@@ -16,9 +16,13 @@ Given /the (date|time|date and time) is (.+?)$/ do |datetime, value|
|
|
16
16
|
when "date and time"
|
17
17
|
Time.zone.parse(value)
|
18
18
|
end
|
19
|
+
|
19
20
|
Timecop.travel time
|
21
|
+
|
20
22
|
end
|
21
23
|
|
22
24
|
After do
|
25
|
+
|
23
26
|
Timecop.return
|
27
|
+
|
24
28
|
end
|
data/features/tags.feature
CHANGED
@@ -1,34 +1,50 @@
|
|
1
|
+
##
|
2
|
+
# @usage
|
3
|
+
# bundle exec cucumber features/tags.feature
|
4
|
+
##
|
1
5
|
Feature: Tag pages
|
6
|
+
|
2
7
|
Scenario: Tag pages are accessible from preview server
|
8
|
+
|
3
9
|
Given the Server is running at "tags-app"
|
10
|
+
|
4
11
|
When I go to "/tags/foo.html"
|
5
12
|
Then I should see "/2011-01-01-new-article.html"
|
6
13
|
Then I should see "/2011-01-02-another-article.html"
|
7
14
|
Then I should see "Tag: foo"
|
15
|
+
|
8
16
|
When I go to "/tags/bar.html"
|
9
17
|
Then I should see "/2011-01-01-new-article.html"
|
10
18
|
Then I should not see "/2011-01-02-another-article.html"
|
11
19
|
Then I should see "Tag: bar"
|
20
|
+
|
12
21
|
When I go to "/tags/120.html"
|
13
22
|
Then I should see "/2011-01-02-another-article.html"
|
14
23
|
Then I should see "Tag: 120"
|
24
|
+
|
15
25
|
When I go to "/index.html"
|
16
26
|
Then I should see "Tag Path: '/tags/foo.html'"
|
17
27
|
|
18
28
|
Scenario: Tag pages are accessible from preview server with directory_indexes
|
29
|
+
|
19
30
|
Given a fixture app "tags-app"
|
20
|
-
|
21
|
-
|
31
|
+
And app "tags-app" is using config "directory-indexes"
|
32
|
+
And the Server is running
|
33
|
+
|
22
34
|
When I go to "/tags/foo.html"
|
23
35
|
Then I should see "File Not Found"
|
36
|
+
|
24
37
|
When I go to "/tags/foo/"
|
25
38
|
Then I should not see "/2011-01-01-new-article.html"
|
26
39
|
Then I should see "/2011-01-01-new-article/"
|
40
|
+
|
27
41
|
When I go to "/index.html"
|
28
42
|
Then I should see "Tag Path: '/tags/foo/'"
|
29
43
|
|
30
44
|
Scenario: Tag pages also get built
|
45
|
+
|
31
46
|
Given a successfully built app at "tags-app"
|
47
|
+
|
32
48
|
When I cd to "build"
|
33
49
|
Then the following files should exist:
|
34
50
|
| tags/foo.html |
|
@@ -36,57 +52,65 @@ Feature: Tag pages
|
|
36
52
|
Then the following files should not exist:
|
37
53
|
| tags.html |
|
38
54
|
|
39
|
-
|
40
|
-
|
41
|
-
|
55
|
+
And the file "tags/foo.html" should contain "Tag: foo"
|
56
|
+
And the file "tags/foo.html" should contain "/2011-01-01-new-article.html"
|
57
|
+
And the file "tags/foo.html" should contain "/2011-01-02-another-article.html"
|
42
58
|
|
43
|
-
|
44
|
-
|
45
|
-
|
59
|
+
And the file "tags/bar.html" should contain "Tag: bar"
|
60
|
+
And the file "tags/bar.html" should contain "/2011-01-01-new-article.html"
|
61
|
+
And the file "tags/bar.html" should not contain "/2011-01-02-another-article.html"
|
46
62
|
|
47
63
|
Scenario: Adding a tag to a post in preview adds a tag page
|
64
|
+
|
48
65
|
Given the Server is running at "tags-app"
|
66
|
+
|
49
67
|
When I go to "/tags/bar.html"
|
50
68
|
Then I should see "/2011-01-01-new-article.html"
|
69
|
+
|
51
70
|
When I go to "/tags/newtag.html"
|
52
71
|
Then I should see "Not Found"
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
72
|
+
And the file "source/blog/2011-01-01-new-article.html.markdown" has the contents
|
73
|
+
"""
|
74
|
+
---
|
75
|
+
title: "Newest Article"
|
76
|
+
date: 2011-01-01
|
77
|
+
tags: newtag
|
78
|
+
---
|
79
|
+
|
80
|
+
Newer Article Content
|
81
|
+
"""
|
63
82
|
When I go to "/tags/bar.html"
|
64
83
|
Then I should see "Not Found"
|
84
|
+
|
65
85
|
When I go to "/tags/newtag.html"
|
66
86
|
Then I should see "/2011-01-01-new-article.html"
|
67
87
|
|
68
|
-
Scenario: Adding a non-ASCII tag to a post in preview adds a tag page
|
88
|
+
Scenario: Adding a completely non-ASCII tag to a post in preview adds a blank tag page
|
89
|
+
|
69
90
|
Given the Server is running at "tags-app"
|
91
|
+
|
70
92
|
When I go to "/tags/☆☆☆.html"
|
71
93
|
Then I should see "Not Found"
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
94
|
+
And the file "source/blog/2011-01-01-new-article.html.markdown" has the contents
|
95
|
+
"""
|
96
|
+
---
|
97
|
+
title: "Newest Article"
|
98
|
+
date: 2011-01-01
|
99
|
+
tags: ☆☆☆
|
100
|
+
---
|
101
|
+
|
102
|
+
Newer Article Content
|
103
|
+
"""
|
104
|
+
|
105
|
+
When I go to "/tags/.html"
|
83
106
|
Then I should see "/2011-01-01-new-article.html"
|
84
107
|
|
85
108
|
Scenario: Tag pages are not added when disabled in configuration
|
109
|
+
|
86
110
|
Given a fixture app "tags-app"
|
87
|
-
|
88
|
-
|
89
|
-
|
111
|
+
And app "tags-app" is using config "no-tags"
|
112
|
+
And I run `middleman build`
|
113
|
+
And was successfully built
|
90
114
|
|
91
115
|
When I cd to "build"
|
92
116
|
Then the following files should not exist:
|
@@ -94,4 +118,14 @@ Feature: Tag pages
|
|
94
118
|
| tags/foo.html |
|
95
119
|
| tags/bar.html |
|
96
120
|
|
97
|
-
|
121
|
+
And the file "index.html" should contain "Tag Path: ''"
|
122
|
+
|
123
|
+
Scenario: Tags respect filters
|
124
|
+
|
125
|
+
Given a fixture app "tags-app"
|
126
|
+
And app "tags-app" is using config "filters"
|
127
|
+
And the Server is running
|
128
|
+
|
129
|
+
When I go to "/tags/foo.html"
|
130
|
+
Then I should see "/2011-01-01-new-article.html"
|
131
|
+
Then I should not see "/2011-01-02-another-article.html"
|
@@ -1,9 +1,13 @@
|
|
1
|
-
<% blog.articles[0...5].each_with_index do |article, i| %>
|
2
|
-
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
<% blog.articles[ 0...5 ].each_with_index do | article, i | %>
|
2
|
+
|
3
|
+
<article class="<%= ( i == 0 ) ? 'first' : '' %>">
|
4
|
+
|
5
|
+
<h1><a href="<%= article.url %>"><%= article.title %></a> <span><%= article.date.strftime( '%b %e %Y' ) %></span></h1>
|
6
|
+
|
7
|
+
<%= article.summary %>
|
8
|
+
|
9
|
+
<div class="more"><a href="<%= article.url %>">read on »</a></div>
|
10
|
+
|
11
|
+
</article>
|
12
|
+
|
9
13
|
<% end %>
|
@@ -1,13 +1,24 @@
|
|
1
1
|
<!doctype html>
|
2
|
+
|
2
3
|
<html>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<title>Blog sources app</title>
|
7
|
+
</head>
|
8
|
+
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<% if is_blog_article? %>
|
12
|
+
|
13
|
+
<%= yield %>
|
14
|
+
<%= current_article.url %>
|
15
|
+
|
16
|
+
<% else %>
|
17
|
+
|
18
|
+
<%= yield %>
|
19
|
+
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
</body>
|
23
|
+
|
13
24
|
</html>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% blog.articles[ 0...5 ].each_with_index do | article, i | %>
|
2
|
+
|
3
|
+
<article class="<%= ( i == 0 ) ? 'first' : '' %>">
|
4
|
+
|
5
|
+
<h1><a href="<%= article.url %>"><%= article.title %></a> <span><%= article.date.strftime( '%b %e %Y' ) %></span></h1>
|
6
|
+
|
7
|
+
<%= article.summary %>
|
8
|
+
|
9
|
+
<div class="more"><a href="<%= article.url %>">read on »</a></div>
|
10
|
+
|
11
|
+
</article>
|
12
|
+
|
13
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<title>Blog sources no title app</title>
|
7
|
+
</head>
|
8
|
+
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<% if is_blog_article? %>
|
12
|
+
|
13
|
+
<%= yield %>
|
14
|
+
<%= current_article.url %>
|
15
|
+
|
16
|
+
<% else %>
|
17
|
+
|
18
|
+
<%= yield %>
|
19
|
+
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
</body>
|
23
|
+
|
24
|
+
</html>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<title>Blog sources no day app</title>
|
7
|
+
</head>
|
8
|
+
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<% if is_blog_article? %>
|
12
|
+
|
13
|
+
<%= yield %>
|
14
|
+
<%= current_article.url %>
|
15
|
+
|
16
|
+
<% else %>
|
17
|
+
|
18
|
+
<%= yield %>
|
19
|
+
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
</body>
|
23
|
+
|
24
|
+
</html>
|