middleman-blog 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -6
  3. data/CHANGELOG.md +32 -1
  4. data/Gemfile +5 -9
  5. data/README.md +3 -2
  6. data/features/article_cli.feature +10 -1
  7. data/features/custom_collections.feature +11 -0
  8. data/features/language.feature +82 -0
  9. data/features/multiblog.feature +4 -2
  10. data/features/permalink-data.feature +12 -0
  11. data/features/summary.feature +13 -0
  12. data/features/support/env.rb +3 -0
  13. data/features/tags.feature +18 -1
  14. data/features/time_zone.feature +1 -1
  15. data/fixtures/custom-article-template-app/config.rb +3 -0
  16. data/fixtures/custom-article-template-app/my_custom_article.tt +7 -0
  17. data/fixtures/custom-article-template-app/source/index.html.erb +9 -0
  18. data/fixtures/custom-article-template-app/source/layout.erb +30 -0
  19. data/fixtures/custom-collections-sources-app/config.rb +11 -0
  20. data/fixtures/custom-collections-sources-app/source/articles/2011-01-02-another-article.html.markdown +8 -0
  21. data/fixtures/custom-collections-sources-app/source/category.html.erb +7 -0
  22. data/fixtures/custom-collections-sources-app/source/index.html.erb +5 -0
  23. data/fixtures/custom-collections-sources-app/source/layout.erb +13 -0
  24. data/fixtures/custom-collections-sources-app/source/news/2011-01-01-new-article.html.markdown +7 -0
  25. data/fixtures/language-app/config.rb +2 -0
  26. data/fixtures/language-app/locales/en.yml +4 -0
  27. data/fixtures/language-app/locales/ru.yml +4 -0
  28. data/fixtures/language-app/source/2013-09-07-english-article-with-lang-in-frontmatter.html.erb +6 -0
  29. data/fixtures/language-app/source/2013-09-07-russian-article-with-lang-in-frontmatter.html.erb +6 -0
  30. data/fixtures/language-app/source/en/2013-09-07-english-article-with-lang-in-path.html.erb +5 -0
  31. data/fixtures/language-app/source/layouts/layout.erb +8 -0
  32. data/fixtures/language-app/source/localizable/index.html.erb +5 -0
  33. data/fixtures/language-app/source/ru/2013-09-07-russian-article-with-lang-in-path.html.erb +5 -0
  34. data/fixtures/multiblog-app/source/blog1/index.html.erb +7 -0
  35. data/fixtures/permalink-data-app/config.rb +5 -0
  36. data/fixtures/permalink-data-app/source/index.html.erb +3 -0
  37. data/fixtures/permalink-data-app/source/layout.erb +14 -0
  38. data/fixtures/permalink-data-app/source/news/2011-01-01-new-article.html.markdown +7 -0
  39. data/fixtures/time-zone-app/source/blog/2013-06-24-hello.html.erb +1 -0
  40. data/lib/middleman-blog.rb +3 -8
  41. data/lib/middleman-blog/blog_article.rb +96 -60
  42. data/lib/middleman-blog/blog_data.rb +78 -76
  43. data/lib/middleman-blog/calendar_pages.rb +87 -119
  44. data/lib/middleman-blog/commands/article.rb +20 -14
  45. data/lib/middleman-blog/custom_pages.rb +30 -64
  46. data/lib/middleman-blog/extension.rb +175 -0
  47. data/lib/middleman-blog/helpers.rb +152 -0
  48. data/lib/middleman-blog/paginator.rb +127 -123
  49. data/lib/middleman-blog/tag_pages.rb +27 -45
  50. data/lib/middleman-blog/template.rb +17 -15
  51. data/lib/middleman-blog/template/config.tt +30 -33
  52. data/lib/middleman-blog/template/source/layout.erb +1 -0
  53. data/lib/middleman-blog/uri_templates.rb +58 -0
  54. data/lib/middleman-blog/version.rb +1 -1
  55. data/middleman-blog.gemspec +4 -1
  56. metadata +75 -9
  57. data/Gemfile-3.0 +0 -27
  58. data/lib/middleman-blog/extension_3_0.rb +0 -248
  59. data/lib/middleman-blog/extension_3_1.rb +0 -278
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 557a6f4be03e753999b53fa39a8d3310c13b8e89
4
- data.tar.gz: a341051be4806dfdf9a6096b8efa3299bab8c57e
3
+ metadata.gz: 08ba0a40e858e3199220173897c437db62c6513e
4
+ data.tar.gz: 9d38d7176eb91b89ad0c8f125a2271553d3dbacc
5
5
  SHA512:
6
- metadata.gz: 3423447600f0594c2a50a0553db7441c7ccf2cab3ef1eb5208c8dd2f6058c79e0f49b778fafa007ee58bbe95613908d9791978fcd384712686a6a5edf139acd0
7
- data.tar.gz: 1910cadf0f09c54260ef60d41a9ecf89dc83d0aa65a46bcf5e3da4a67eb2b1e5cf8bab63f43dd28d92a57f536e96d2e583b31a0bf879a16312fb5d3e6a234645
6
+ metadata.gz: 888e2bf9c611950366eeb2c65d2cee9f08914d0e0ceec9acdb65f42a940f581b23aedcf38cacf5108005f19009263f607b39a0ae6308c899d391be8aa6d5da50
7
+ data.tar.gz: 18a3c29946fc65bf638b736a8fde6873ebc67eb9e9c99491e2dbd11598d37e0705795ec0e16a21d2bd50b99ff70d5acf3a273e4fa1807d36ac33a01fe640888d
data/.travis.yml CHANGED
@@ -1,14 +1,8 @@
1
1
  rvm:
2
- - 1.8.7
3
2
  - 1.9.3
4
3
  - 2.0.0
5
- - jruby-18mode
6
4
  - jruby-19mode
7
5
 
8
- gemfile:
9
- - Gemfile
10
- - Gemfile-3.0
11
-
12
6
  script: "bundle exec rake test"
13
7
 
14
8
  env: TEST=true
data/CHANGELOG.md CHANGED
@@ -1,6 +1,35 @@
1
1
  master
2
2
  ===
3
3
 
4
+ * Add support for internationalization and locale-specific articles. #156
5
+ * Drop support for Ruby 1.8 and Middleman 3.0.
6
+ * Removed backwards compatibility patch that set instance variables for tag and calendar pages. Use locals instead.
7
+ * Templated paths like :sources, :taglink, :year_link, :month_link, :day_link, :page_link, and custom_collections links can now be optionally expressed as RFC 6570 URI templates.
8
+ * Arbitrary data from page frontmatter can be used in the :permalink template. Simply add a key to your :permalink template that matches a field from your frontmatter.
9
+ * Data extracted from the :sources URL template can be used in the :permalink template. This information can also be used from templates via current_article.metadata[:page][<key>].
10
+ * UTF-8 strings substituted into URLs are now preserved rather than being omitted. #176
11
+ * "middleman article" command now works even when there are multiple blogs. Specify the blog you want using "--blog".
12
+ * The template used to generate new articles via "middleman article" can be overridden by setting :new_article_template.
13
+ * Removed `:blog_name`, `:blog_author`, `:blog_avatar` options and the `page_title` helper.
14
+
15
+ 3.4.1
16
+ ====
17
+
18
+ * Require Middleman 3.2
19
+
20
+ 3.4.0
21
+ ====
22
+
23
+ * Add `inspect` methods to `BlogData` and `BlogArticle` to avoid hangs on exceptions. #157
24
+ * Generated feed.xml now works on blogs with no posts. #155
25
+ * No longer depend on `middleman-more`.
26
+ * Don't try to replace tokens that don't exist in the source path. #161
27
+ * Support for including arbitrary frontmatter data in blog permalinks. #164
28
+ * When using multiblog, fail immediately if the blog name isn't specified. #168
29
+
30
+ 3.3.0
31
+ ====
32
+
4
33
  * Experimental support for multiple blogs in a single site by activating
5
34
  `:blog` multiple times.
6
35
  * Works as a Middleman 3.1-style extension.
@@ -18,12 +47,14 @@ master
18
47
  * Fix setting time zone with `set :time_zone` in `config.rb`. #140
19
48
  * Articles can omit their :title from the filename and specify it in frontmatter
20
49
  instead. #148
50
+ * Pages can choose which blog to use in multi-blog mode by specifying the correct
51
+ blog in frontmatter. #150
21
52
 
22
53
  3.2.0
23
54
  ====
24
55
 
25
56
  * The `summary` method on articles is now HTML-aware, and can be provided with
26
- a different summary length or ellipsis string: `summary(1000, '&hellip;')`.
57
+ a different summary length or ellipsis string: `summary(1000, '&hellip;')`.
27
58
  Nokogiri is required to use the summary.
28
59
  * The `summary_generator` option now recieves the rendered article (without
29
60
  layout) instead of the template source.
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gem "middleman-core", :github => "middleman/middleman"
5
5
  # Specify your gem's dependencies in middleman-blog.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 10.0.3", :require => false
8
+ gem "rake", "~> 10.1.0", :require => false
9
9
  gem "yard", "~> 0.8.0", :require => false
10
10
 
11
11
  # Test tools
@@ -15,18 +15,14 @@ gem "aruba", "~> 0.5.1"
15
15
  gem "rspec", "~> 2.12"
16
16
  gem "simplecov"
17
17
 
18
- gem "timecop", "~> 0.4.0"
19
- gem "nokogiri", "~> 1.5.0" # 1.6.0 requires Ruby 1.9+ but we still test on 1.8
18
+ gem "timecop", "~> 0.6.3"
19
+ gem "nokogiri"
20
20
  gem "kramdown"
21
21
 
22
22
  # Code Quality
23
23
  gem "cane", :platforms => [:mri_19, :mri_20], :require => false
24
+ gem 'coveralls', :require => false
24
25
 
25
26
  platforms :ruby do
26
- gem "redcarpet", /^1\.8/.match(RUBY_VERSION) ? "~> 2.0" : "~> 3.0"
27
- end
28
-
29
- # Cross-templating language block fix for Ruby 1.8
30
- platforms :mri_18 do
31
- gem "ruby18_source_location"
27
+ gem "redcarpet", "~> 3.0"
32
28
  end
data/README.md CHANGED
@@ -31,7 +31,7 @@ Additionally, up-to-date generated code documentation is available on [RubyDoc].
31
31
  [![Build Status](https://travis-ci.org/middleman/middleman-blog.png)][travis]
32
32
  [![Dependency Status](https://gemnasium.com/middleman/middleman-blog.png?travis)][gemnasium]
33
33
  [![Code Quality](https://codeclimate.com/github/middleman/middleman-blog.png)][codeclimate]
34
-
34
+ [![Code Coverage](https://coveralls.io/repos/middleman/middleman-blog/badge.png?branch=master)][coveralls]
35
35
  ## Community
36
36
 
37
37
  The official community forum is available at: http://forum.middlemanapp.com
@@ -62,5 +62,6 @@ Copyright (c) 2010-2013 Thomas Reynolds. MIT Licensed, see [LICENSE] for details
62
62
  [travis]: http://travis-ci.org/middleman/middleman-blog
63
63
  [gemnasium]: https://gemnasium.com/middleman/middleman-blog
64
64
  [codeclimate]: https://codeclimate.com/github/middleman/middleman-blog
65
+ [coveralls]: https://coveralls.io/r/middleman/middleman-blog
65
66
  [rubydoc]: http://rubydoc.info/github/middleman/middleman-blog
66
- [LICENSE]: https://github.com/middleman/middleman-blog/blob/master/LICENSE.md
67
+ [LICENSE]: https://github.com/middleman/middleman-blog/blob/master/LICENSE.md
@@ -4,4 +4,13 @@ Feature: New article CLI command
4
4
  And I run `middleman article "My New Article" --date 2012-03-17`
5
5
  Then the exit status should be 0
6
6
  Then the following files should exist:
7
- | source/blog/2012-03-17-my-new-article.html.markdown |
7
+ | source/blog/2012-03-17-my-new-article.html.markdown |
8
+ And the file "source/blog/2012-03-17-my-new-article.html.markdown" should contain "tags"
9
+
10
+ Scenario: Create a new blog article with the CLI using a custom template
11
+ Given a fixture app "custom-article-template-app"
12
+ And I run `middleman article "My New Article" --date 2012-03-17`
13
+ Then the exit status should be 0
14
+ Then the following files should exist:
15
+ | source/2012-03-17-my-new-article.html.markdown |
16
+ And the file "source/2012-03-17-my-new-article.html.markdown" should contain "From a template!"
@@ -68,3 +68,14 @@ Feature: Custom collection pages
68
68
  When I go to "/blog/categories/ruby-on-rails.html"
69
69
  Then I should see "/2011-01-01-new-article.html"
70
70
  Then I should not see "/2011-01-02-another-article.html"
71
+
72
+ Scenario: Collection property can use source path data
73
+ Given the Server is running at "custom-collections-sources-app"
74
+ When I go to "/categories/news.html"
75
+ Then I should see "/2011-01-01-new-article.html"
76
+ Then I should not see "/2011-01-02-another-article.html"
77
+ When I go to "/categories/articles.html"
78
+ Then I should not see "/2011-01-01-new-article.html"
79
+ Then I should see "/2011-01-02-another-article.html"
80
+ When I go to "/index.html"
81
+ Then I should see "Category Path: '/categories/articles.html'"
@@ -0,0 +1,82 @@
1
+ Feature: Internationalized articles
2
+ Scenario: Article has lang in frontmatter
3
+ Given the Server is running at "language-app"
4
+ When I go to "/index.html"
5
+ Then I should see "Some text in English. All is OK."
6
+ Then I should not see "Некоторый текст на русском языке. Всё отлично."
7
+ When I go to "/ru/index.html"
8
+ Then I should see "Некоторый текст на русском языке. Всё отлично."
9
+ Then I should not see "Some text in English. All is OK."
10
+
11
+ Scenario: Article has lang in path
12
+ Given a fixture app "language-app"
13
+ And a file named "config.rb" with:
14
+ """
15
+ activate :i18n
16
+ activate :blog, prefix: ":lang"
17
+ """
18
+ Given the Server is running at "language-app"
19
+ When I go to "/index.html"
20
+ Then I should see "Some text in English. All is OK."
21
+ Then I should not see "Некоторый текст на русском языке. Всё отлично."
22
+ When I go to "/ru/index.html"
23
+ Then I should see "Некоторый текст на русском языке. Всё отлично."
24
+ Then I should not see "Some text in English. All is OK."
25
+
26
+ Scenario: Custom locales in articles
27
+ Given a fixture app "language-app"
28
+ And a file named "config.rb" with:
29
+ """
30
+ activate :i18n
31
+ activate :blog, preserve_locale: true
32
+ """
33
+ Given the Server is running at "language-app"
34
+ When I go to "/index.html"
35
+ Then I should see "Some text in English. All is OK."
36
+ When I go to "/ru/index.html"
37
+ Then I should see "Некоторый текст на русском языке. Всё OK."
38
+
39
+ Scenario: Layout's locale match article's locale on article page
40
+ Given a fixture app "language-app"
41
+ Given the Server is running at "language-app"
42
+ When I go to "/2013/09/07/english-article-with-lang-in-frontmatter.html"
43
+ Then I should see "Language: en"
44
+ Then I should see "Hello, world!"
45
+ Then I should not see "Язык: ru"
46
+ Then I should not see "Привет, мир!"
47
+ When I go to "/2013/09/07/russian-article-with-lang-in-frontmatter.html"
48
+ Then I should see "Язык: ru"
49
+ Then I should see "Привет, мир!"
50
+ Then I should not see "Language: en"
51
+ Then I should not see "Hello, world!"
52
+
53
+ Scenario: Custom locales on article pages
54
+ Given a fixture app "language-app"
55
+ And a file named "config.rb" with:
56
+ """
57
+ activate :i18n
58
+ activate :blog, preserve_locale: true
59
+ """
60
+ Given the Server is running at "language-app"
61
+ When I go to "/2013/09/07/english-article-with-lang-in-frontmatter.html"
62
+ Then I should see "Language: en"
63
+ Then I should see "Hello, world!"
64
+ Then I should not see "Язык: ru"
65
+ Then I should not see "Привет, мир!"
66
+ When I go to "/2013/09/07/russian-article-with-lang-in-frontmatter.html"
67
+ Then I should see "Language: en"
68
+ Then I should see "Hello, world!"
69
+ Then I should not see "Язык: ru"
70
+ Then I should not see "Привет, мир!"
71
+
72
+ Scenario: Creating article with lang from CLI
73
+ Given a fixture app "language-app"
74
+ And a file named "config.rb" with:
75
+ """
76
+ activate :i18n
77
+ activate :blog, prefix: ":lang"
78
+ """
79
+ And I run `middleman article "My New Article" --date 2013-09-07 --lang ru`
80
+ Then the exit status should be 0
81
+ Then the following files should exist:
82
+ | source/ru/2013-09-07-my-new-article.html.markdown |
@@ -1,12 +1,12 @@
1
1
  @three_one
2
2
 
3
3
  Feature: Host Multiple Blogs with Middleman 3.1+
4
-
4
+
5
5
  Scenario: Preview
6
6
  Given a fixture app "multiblog-app"
7
7
  And a file named "config.rb" with:
8
8
  """
9
- activate :blog, :name => "blog_number_1", :prefix => "blog1", :sources => ":year-:month-:day-:title.html"
9
+ activate :blog, :name => "blog_number_1", :prefix => "blog1", :sources => ":year-:month-:day-:title.html", :paginate => true
10
10
 
11
11
  activate :blog do |blog|
12
12
  blog.name = "blog_number_2"
@@ -24,6 +24,8 @@ Feature: Host Multiple Blogs with Middleman 3.1+
24
24
  Then I should see "blog_number_1 title: Other Article"
25
25
  Then I should see "blog_number_2 length: 1"
26
26
  Then I should see "blog_number_2 title: Newer Article"
27
+ When I go to "/blog1/index.html"
28
+ Then I should see "Paginate: true"
27
29
 
28
30
  Scenario: Build
29
31
  Given a fixture app "multiblog-app"
@@ -0,0 +1,12 @@
1
+ Feature: Permalinks can include arbitrary data from frontmatter
2
+
3
+ Scenario: Articles list links using permalink with frontmatter data
4
+ Given the Server is running at "permalink-data-app"
5
+ When I go to "/index.html"
6
+ Then I should see "news/a-custom-string-2011-01-01-new-article.html"
7
+
8
+ Scenario: Articles can be accessed through permalinks with frontmatter data
9
+ Given the Server is running at "permalink-data-app"
10
+ When I go to "news/a-custom-string-2011-01-01-new-article.html"
11
+ Then I should see "Newer Article Content"
12
+ And I should see "Category: news"
@@ -41,3 +41,16 @@ Feature: Article summary generation
41
41
  When I go to "/index.html"
42
42
  Then I should see "Summary from article with no summary separator and comments in the summary."
43
43
  Then I should not see "Extended part from article from article with no summary separator and comments in the summary."
44
+
45
+ Scenario: Summary is only limited by a optional summary separator and not by length
46
+ Given a fixture app "summary-app"
47
+ And a file named "config.rb" with:
48
+ """
49
+ activate :blog do |blog|
50
+ blog.summary_length = -1
51
+ end
52
+ """
53
+ Given the Server is running at "summary-app"
54
+ When I go to "/index.html"
55
+ Then I should see "Extended part from article with no separator."
56
+ Then I should not see "Extended part from article with separator."
@@ -3,6 +3,9 @@ SimpleCov.start do
3
3
  add_filter "/features/"
4
4
  end
5
5
 
6
+ require 'coveralls'
7
+ Coveralls.wear!
8
+
6
9
  ENV["TEST"] = "true"
7
10
  ENV["AUTOLOAD_SPROCKETS"] = "false"
8
11
 
@@ -49,7 +49,7 @@ Feature: Tag pages
49
49
  Then I should see "Not Found"
50
50
  And the file "source/blog/2011-01-01-new-article.html.markdown" has the contents
51
51
  """
52
- ---
52
+ ---
53
53
  title: "Newest Article"
54
54
  date: 2011-01-01
55
55
  tags: newtag
@@ -61,3 +61,20 @@ Feature: Tag pages
61
61
  Then I should see "Not Found"
62
62
  When I go to "/tags/newtag.html"
63
63
  Then I should see "/2011-01-01-new-article.html"
64
+
65
+ Scenario: Adding a non-ASCII tag to a post in preview adds a tag page
66
+ Given the Server is running at "tags-app"
67
+ When I go to "/tags/☆☆☆.html"
68
+ Then I should see "Not Found"
69
+ And the file "source/blog/2011-01-01-new-article.html.markdown" has the contents
70
+ """
71
+ ---
72
+ title: "Newest Article"
73
+ date: 2011-01-01
74
+ tags: ☆☆☆
75
+ ---
76
+
77
+ Newer Article Content
78
+ """
79
+ When I go to "/tags/☆☆☆.html"
80
+ Then I should see "/2011-01-01-new-article.html"
@@ -1,4 +1,4 @@
1
- Feature: Setup time zoen
1
+ Feature: Setup time zone
2
2
  Scenario: Time.zone can be set through set at config.rb
3
3
  Given the Server is running at "time-zone-app"
4
4
  When I go to "/blog/2013/06/24/hello.html"
@@ -0,0 +1,3 @@
1
+ activate :blog do |blog|
2
+ blog.new_article_template = 'my_custom_article.tt'
3
+ end
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: <%= @title %>
3
+ date: <%= @date.strftime('%F %R %Z') %>
4
+ tags: default
5
+ ---
6
+
7
+ From a template!
@@ -0,0 +1,9 @@
1
+ <% data.blog.articles[0...5].each_with_index do |article, i| %>
2
+ <article class="<%= (i == 0) ? 'first' : '' %>">
3
+ <h1><a href="<%= article.url %>"><%= article.title %></a> <span><%= article.date.strftime('%b %e %Y') %></span></h1>
4
+
5
+ <%= article.summary %>
6
+
7
+ <div class="more"><a href="<%= article.url %>">read on &raquo;</a></div>
8
+ </article>
9
+ <% end %>
@@ -0,0 +1,30 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv='X-UA-Compatible' content='IE=edge;chrome=1' />
6
+
7
+ <% if is_blog_article? %>
8
+ <title><%= current_article.title %></title>
9
+ <% end %>
10
+ </head>
11
+ <body>
12
+
13
+ <div id="main" role="main">
14
+ <% if is_blog_article? %>
15
+ <article class="hentry">
16
+ <h1 class="entry-title">
17
+ <%= current_article.title %>
18
+ <time class="updated"><%= current_article.date.strftime('%b %e %Y') %></time>
19
+ </h1>
20
+
21
+ <div class="entry-content">
22
+ <%= yield %>
23
+ </div>
24
+ </article>
25
+ <% else %>
26
+ <%= yield %>
27
+ <% end %>
28
+ </div>
29
+ </body>
30
+ </html>
@@ -0,0 +1,11 @@
1
+ activate :blog do |blog|
2
+ blog.sources = ":category/:year-:month-:day-:title.html"
3
+ blog.permalink = "blog/:year-:month-:day-:title.html"
4
+
5
+ blog.custom_collections = {
6
+ :category => {
7
+ :link => '/categories/:category.html',
8
+ :template => '/category.html'
9
+ }
10
+ }
11
+ end
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: "Another Article"
3
+ date: 2011-01-02
4
+ tags:
5
+ - foo
6
+ ---
7
+
8
+ Another Article Content
@@ -0,0 +1,7 @@
1
+ Category: <%= category %>
2
+
3
+ <% if articles %>
4
+ <% articles[0...12].each do |article| %>
5
+ <li><a href="<%= article.url %>"><%= article.title %></a> <time><%= article.date.strftime('%b %e') %></time></li>
6
+ <% end %>
7
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <% blog.articles[0...12].each do |article| %>
2
+ <li><a href="<%= article.url %>"><%= article.title %></a> <time><%= article.date.strftime('%b %e') %></time></li>
3
+ <% end %>
4
+
5
+ Category Path: '<%= category_path("articles") %>'