middleman-blog 3.6.0.beta.2 → 4.0.0

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +18 -2
  3. data/CHANGELOG.md +6 -1
  4. data/Gemfile +13 -10
  5. data/README.md +6 -6
  6. data/Rakefile +1 -15
  7. data/features/calendar.feature +23 -0
  8. data/features/calendar_multiblog.feature +0 -2
  9. data/features/language.feature +1 -13
  10. data/features/multiblog.feature +0 -2
  11. data/features/paginate_multiblog.feature +0 -2
  12. data/features/tags.feature +14 -0
  13. data/features/tags_multiblog.feature +0 -2
  14. data/fixtures/blog-sources-subdirs-app/config.rb +1 -1
  15. data/fixtures/blog-sources-subdirs-app/source/blog.html.erb +1 -1
  16. data/fixtures/blog-sources-subdirs-app/source/blog/{another-post.md.erb → another-post.html.md.erb} +0 -0
  17. data/fixtures/blog-sources-subdirs-app/source/blog/subdir/{yet-another-post.md.erb → yet-another-post.html.md.erb} +0 -0
  18. data/fixtures/calendar-app/config-only-year.rb +9 -0
  19. data/fixtures/custom-collections-sources-app/source/index.html.erb +3 -3
  20. data/fixtures/layouts-app/source/2011/01/02/{article-in-normal-layout.markdown → article-in-normal-layout.html.markdown} +0 -0
  21. data/fixtures/layouts-app/source/2011/01/03/{article-without-layout.markdown → article-without-layout.html.markdown} +0 -0
  22. data/fixtures/permalink-data-app/source/layout.erb +1 -1
  23. data/fixtures/tags-app/config-no-tags.rb +6 -0
  24. data/lib/middleman-blog.rb +0 -9
  25. data/lib/middleman-blog/blog_article.rb +11 -9
  26. data/lib/middleman-blog/blog_data.rb +17 -13
  27. data/lib/middleman-blog/calendar_pages.rb +9 -12
  28. data/lib/middleman-blog/custom_pages.rb +3 -4
  29. data/lib/middleman-blog/extension.rb +24 -8
  30. data/lib/middleman-blog/helpers.rb +10 -17
  31. data/lib/middleman-blog/paginator.rb +9 -7
  32. data/lib/middleman-blog/tag_pages.rb +5 -3
  33. data/lib/middleman-blog/version.rb +1 -1
  34. data/middleman-blog.gemspec +3 -3
  35. data/spec/uri_templates_spec.rb +17 -17
  36. metadata +22 -31
  37. data/features/article_cli.feature +0 -16
  38. data/lib/middleman-blog/commands/article.rb +0 -58
  39. data/lib/middleman-blog/commands/article.tt +0 -6
  40. data/lib/middleman-blog/template.rb +0 -37
  41. data/lib/middleman-blog/template/config.tt +0 -118
  42. data/lib/middleman-blog/template/shared/Gemfile.tt +0 -9
  43. data/lib/middleman-blog/template/source/2012-01-01-example-article.html.markdown +0 -7
  44. data/lib/middleman-blog/template/source/calendar.html.erb +0 -33
  45. data/lib/middleman-blog/template/source/feed.xml.builder +0 -24
  46. data/lib/middleman-blog/template/source/index.html.erb +0 -24
  47. data/lib/middleman-blog/template/source/layout.erb +0 -38
  48. data/lib/middleman-blog/template/source/tag.html.erb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fd8e5447b47c113fc7c58ae2cd7555cc070adcf
4
- data.tar.gz: d4586b9545fc038a1af9d415255952b0e3cdda76
3
+ metadata.gz: a954456dd37131a13ebabbdb3cb2cd2876f31c83
4
+ data.tar.gz: 9fe2db291d746b24bef90d3acfd16e966f1381c0
5
5
  SHA512:
6
- metadata.gz: f35f5e4c6bb2c3b56e3bde38ff60928ecd49b56656acba2a338b7752ad6406d707b323fbea63e82041ad2fa5837205cdcefedbd791b65defd7741138814aa8c0
7
- data.tar.gz: d8fbcc07cce2c0c330e1b0969ffe0eee303d1964752398d2d5f4d028394f6a09df65b43932c943fb41c6bd8c279fe7460968b0d07d60cef6fb870840ab5bccdc
6
+ metadata.gz: 97feb50f6597a1123b1e9f06d5a95d7a1479997b921da68ff15d84ba484607bb664de385f7fef4f6547dd972871bc3ff62521f346dcc2d00e4e48f88b7e4248a
7
+ data.tar.gz: 6be516bced8dba93bd1320f5b00e69d31466fd41286cb71422e3afc1a03fbda4814ff23f512e610bb27698f056ea3d0ec77ad70c7c39f9299a711f8eb6d73ffc
data/.travis.yml CHANGED
@@ -1,7 +1,23 @@
1
1
  rvm:
2
- - 1.9.3
3
- - 2.0.0
2
+ - ruby-head
3
+ - jruby-head
4
4
  - jruby-19mode
5
+ - 2.2.2
6
+ - 2.1
7
+ - 2.0
8
+ os:
9
+ - linux
10
+ - osx
11
+ sudo: false
12
+ matrix:
13
+ fast_finish: true
14
+ allow_failures:
15
+ - rvm: ruby-head
16
+ - rvm: jruby-19mode
17
+ - rvm: jruby-head
18
+
19
+ gemfile:
20
+ - Gemfile
5
21
 
6
22
  script: "bundle exec rake test"
7
23
 
data/CHANGELOG.md CHANGED
@@ -1,7 +1,12 @@
1
+ 4.0.0.rc.1
2
+ ===
3
+
4
+ * Removed `article` sub command.
5
+
1
6
  3.5.3
2
7
  ===
3
8
 
4
- Update blog_article active_support requires. Fixes #205
9
+ * Update blog_article active_support requires. Fixes #205
5
10
 
6
11
  3.5.2
7
12
  ===
data/Gemfile CHANGED
@@ -1,27 +1,30 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "middleman-core", :github => "middleman/middleman", :branch => 'v3-stable'
3
+ gem "middleman-cli", github: "middleman/middleman", branch: 'master'
4
+ gem "middleman-core", github: "middleman/middleman", branch: 'master'
4
5
 
5
6
  # Specify your gem's dependencies in middleman-blog.gemspec
6
7
  gemspec
7
8
 
8
- gem "rake", "~> 10.1.0", :require => false
9
- gem "yard", "~> 0.8.0", :require => false
9
+ # Build and doc tools
10
+ gem 'rake', '~> 10.3', require: false
11
+ gem 'yard', '~> 0.8', require: false
10
12
 
11
13
  # Test tools
12
- gem "cucumber", "~> 1.3.1"
13
- gem "fivemat"
14
- gem "aruba", "~> 0.5.1"
15
- gem "rspec", "~> 2.12"
16
- gem "simplecov"
14
+ gem 'pry', '~> 0.10', group: :development, require: false
15
+ gem 'aruba', '~> 0.7.4', require: false
16
+ gem 'rspec', '~> 3.0', require: false
17
+ gem 'cucumber', '~> 2.0', require: false
17
18
 
18
19
  gem "timecop", "~> 0.6.3"
19
20
  gem "nokogiri"
20
21
  gem "kramdown"
21
22
 
22
23
  # Code Quality
23
- gem "cane", :platforms => [:mri_19, :mri_20], :require => false
24
- gem 'coveralls', :require => false
24
+ gem 'rubocop', '~> 0.24', require: false
25
+ gem 'simplecov', '~> 0.9', require: false
26
+ gem 'coveralls', '~> 0.8', require: false
27
+ gem 'codeclimate-test-reporter', '~> 0.3', require: false, group: :test
25
28
 
26
29
  platforms :ruby do
27
30
  gem "redcarpet", "~> 3.0"
data/README.md CHANGED
@@ -8,7 +8,7 @@ If you're just getting started, install the `middleman` gem and generate a new p
8
8
 
9
9
  ```
10
10
  gem install middleman
11
- middleman init MY_PROJECT
11
+ middleman init MY_PROJECT --template=blog
12
12
  ```
13
13
 
14
14
  If you already have a Middleman project: Add `gem "middleman-blog"` to your `Gemfile` and run `bundle install`
@@ -27,11 +27,11 @@ Additionally, up-to-date generated code documentation is available on [RubyDoc].
27
27
 
28
28
  ## Build & Dependency Status
29
29
 
30
- [![Gem Version](https://badge.fury.io/rb/middleman-blog.png)][gem]
31
- [![Build Status](https://travis-ci.org/middleman/middleman-blog.png)][travis]
32
- [![Dependency Status](https://gemnasium.com/middleman/middleman-blog.png?travis)][gemnasium]
33
- [![Code Quality](https://codeclimate.com/github/middleman/middleman-blog.png)][codeclimate]
34
- [![Code Coverage](https://coveralls.io/repos/middleman/middleman-blog/badge.png?branch=master)][coveralls]
30
+ [![Gem Version](https://badge.fury.io/rb/middleman-blog.svg)][gem]
31
+ [![Build Status](https://travis-ci.org/middleman/middleman-blog.svg)][travis]
32
+ [![Dependency Status](https://gemnasium.com/middleman/middleman-blog.svg?travis)][gemnasium]
33
+ [![Code Quality](https://codeclimate.com/github/middleman/middleman-blog.svg)][codeclimate]
34
+ [![Code Coverage](https://coveralls.io/repos/middleman/middleman-blog/badge.svg?branch=master)][coveralls]
35
35
  ## Community
36
36
 
37
37
  The official community forum is available at: http://forum.middlemanapp.com
data/Rakefile CHANGED
@@ -10,7 +10,6 @@ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
10
10
 
11
11
  exempt_tags = ""
12
12
  exempt_tags << "--tags ~@nojava " if RUBY_PLATFORM == "java"
13
- exempt_tags << "--tags ~@three_one " unless ::Middleman::VERSION.match(/^3\.1\./)
14
13
 
15
14
  t.cucumber_opts = "--color --tags ~@wip #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
16
15
  end
@@ -24,20 +23,7 @@ require 'rspec/core/rake_task'
24
23
  desc "Run RSpec"
25
24
  RSpec::Core::RakeTask.new do |spec|
26
25
  spec.pattern = 'spec/**/*_spec.rb'
27
- spec.rspec_opts = ['--color', '--format nested']
28
- end
29
-
30
- begin
31
- require 'cane/rake_task'
32
-
33
- desc "Run cane to check quality metrics"
34
- Cane::RakeTask.new(:quality) do |cane|
35
- cane.no_style = true
36
- cane.no_doc = true
37
- cane.abc_glob = "lib/middleman-blog/**/*.rb"
38
- end
39
- rescue LoadError
40
- # warn "cane not available, quality task not provided."
26
+ spec.rspec_opts = ['--color', '--format documentation']
41
27
  end
42
28
 
43
29
  desc "Build HTML documentation"
@@ -87,3 +87,26 @@ Feature: Calendar pages
87
87
  And the file "index.html" should contain "Month Path: '/2011/01.html'"
88
88
  And the file "index.html" should contain "Day Path: '/2011/01/01.html'"
89
89
 
90
+ Scenario: Calendar pages for months and days are not added when disabled in the config
91
+ Given a fixture app "calendar-app"
92
+ And app "calendar-app" is using config "only-year"
93
+ And I run `middleman build`
94
+ And was successfully built
95
+
96
+ When I cd to "build"
97
+ Then the following files should exist:
98
+ | 2011.html |
99
+ And the following files should not exist:
100
+ | 2011/01.html |
101
+ | 2011/01/01.html |
102
+ | 2011/01/02.html |
103
+
104
+ And the file "2011.html" should contain "/2011-01-01-new-article.html"
105
+ And the file "2011.html" should contain "/2011-01-02-another-article.html"
106
+ And the file "2011.html" should contain "Year: '2011'"
107
+ And the file "2011.html" should contain "Month: ''"
108
+ And the file "2011.html" should contain "Day: ''"
109
+
110
+ And the file "index.html" should contain "Year Path: '/2011.html'"
111
+ And the file "index.html" should contain "Month Path: ''"
112
+ And the file "index.html" should contain "Day Path: ''"
@@ -1,5 +1,3 @@
1
- @three_one
2
-
3
1
  Feature: Calendar pages
4
2
  Scenario: Calendar pages are accessible from preview server
5
3
  Given the Server is running at "calendar-multiblog-app"
@@ -42,7 +42,7 @@ Feature: Internationalized articles
42
42
  When I go to "/index.html"
43
43
  Then I should see "Some text in English. All is OK."
44
44
  When I go to "/ru/index.html"
45
- Then I should see "Некоторый текст на русском языке. Всё OK."
45
+ Then I should see "Некоторый текст на русском языке. Всё отлично."
46
46
 
47
47
  Scenario: Layout's locale match article's locale on article page
48
48
  Given a fixture app "language-app"
@@ -76,15 +76,3 @@ Feature: Internationalized articles
76
76
  Then I should see "Hello, world!"
77
77
  Then I should not see "Язык: ru"
78
78
  Then I should not see "Привет, мир!"
79
-
80
- Scenario: Creating article with lang from CLI
81
- Given a fixture app "language-app"
82
- And a file named "config.rb" with:
83
- """
84
- activate :i18n
85
- activate :blog, prefix: ":lang"
86
- """
87
- And I run `middleman article "My New Article" --date 2013-09-07 --lang ru`
88
- Then the exit status should be 0
89
- Then the following files should exist:
90
- | source/ru/2013-09-07-my-new-article.html.markdown |
@@ -1,5 +1,3 @@
1
- @three_one
2
-
3
1
  Feature: Host Multiple Blogs with Middleman 3.1+
4
2
 
5
3
  Scenario: Preview
@@ -1,5 +1,3 @@
1
- @three_one
2
-
3
1
  Feature: Pagination with Multiblog
4
2
  Scenario: Index pages are accessible from preview server
5
3
  Given the Server is running at "paginate-multiblog-app"
@@ -81,3 +81,17 @@ Feature: Tag pages
81
81
  """
82
82
  When I go to "/tags/☆☆☆.html"
83
83
  Then I should see "/2011-01-01-new-article.html"
84
+
85
+ Scenario: Tag pages are not added when disabled in configuration
86
+ Given a fixture app "tags-app"
87
+ And app "tags-app" is using config "no-tags"
88
+ And I run `middleman build`
89
+ And was successfully built
90
+
91
+ When I cd to "build"
92
+ Then the following files should not exist:
93
+ | tags.html |
94
+ | tags/foo.html |
95
+ | tags/bar.html |
96
+
97
+ And the file "index.html" should contain "Tag Path: ''"
@@ -1,5 +1,3 @@
1
- @three_one
2
-
3
1
  Feature: Tag pages with multiple blogs
4
2
  Scenario: Tag pages are accessible from preview server
5
3
  Given the Server is running at "tags-multiblog-app"
@@ -1,4 +1,4 @@
1
1
  activate :blog do |blog|
2
2
  blog.sources = "blog/:title.html"
3
- blog.permalink = "blog/{title}"
3
+ blog.permalink = "blog/{title}.html"
4
4
  end
@@ -1,3 +1,3 @@
1
1
  <% page_articles.each do |post| %>
2
2
  <li><%= link_to post.title, post %></li>
3
- <% end %>
3
+ <% end %>
@@ -0,0 +1,9 @@
1
+ Time.zone = "Pacific Time (US & Canada)"
2
+
3
+ activate :blog do |blog|
4
+ blog.sources = "blog/:year-:month-:day-:title.html"
5
+ blog.permalink = "blog/:year-:month-:day-:title.html"
6
+ blog.calendar_template = 'calendar.html'
7
+ blog.generate_month_pages = false
8
+ blog.generate_day_pages = false
9
+ end
@@ -1,5 +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 %>
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
4
 
5
5
  Category Path: '<%= category_path("articles") %>'
@@ -5,7 +5,7 @@
5
5
  <body>
6
6
  <% if is_blog_article? %>
7
7
  URL: <%= current_article.url %>
8
- Category: <%= current_article.metadata[:page]['category'] %>
8
+ Category: <%= current_article.data[:category] %>
9
9
  <%= yield %>
10
10
  <% else %>
11
11
  <%= yield %>
@@ -0,0 +1,6 @@
1
+ activate :blog do |blog|
2
+ blog.sources = "blog/:year-:month-:day-:title.html"
3
+ blog.permalink = "blog/:year-:month-:day-:title.html"
4
+ blog.tag_template = "/tag.html"
5
+ blog.generate_tag_pages = false
6
+ end
@@ -1,15 +1,6 @@
1
1
  require "middleman-core"
2
-
3
2
  require "middleman-blog/version"
4
3
 
5
- begin
6
- require "middleman-blog/template"
7
- rescue LoadError
8
- # v4
9
- end
10
-
11
- require "middleman-blog/commands/article"
12
-
13
4
  ::Middleman::Extensions.register(:blog) do
14
5
  require "middleman-blog/extension"
15
6
  ::Middleman::BlogExtension
@@ -30,7 +30,7 @@ module Middleman
30
30
  # Called automatically by Middleman.
31
31
  # @return [String]
32
32
  def render(opts={}, locs={}, &block)
33
- if opts[:layout].nil?
33
+ unless opts.has_key?(:layout)
34
34
  opts[:layout] = metadata[:options][:layout]
35
35
  opts[:layout] = blog_options.layout if opts[:layout].nil?
36
36
  # Convert to a string unless it's a boolean
@@ -136,20 +136,22 @@ module Middleman
136
136
  # activated at all, +nil+ will be returned.
137
137
  #
138
138
  # @return [Symbol] Language code (for example, +:en+ or +:de+)
139
- def lang
140
- frontmatter_lang = data['lang']
141
- filename_lang = path_part('lang')
139
+ def locale
140
+ frontmatter_locale = data['locale'] || data['lang']
141
+ filename_locale = path_part('locale') || path_part('lang')
142
142
 
143
- if frontmatter_lang && filename_lang && frontmatter_lang != filename_lang
144
- raise "The lang in #{path}'s filename (#{filename_lang.inspect}) doesn't match the lang in its frontmatter (#{frontmatter_lang.inspect})"
143
+ if frontmatter_locale && filename_locale && frontmatter_locale != filename_locale
144
+ raise "The locale in #{path}'s filename (#{filename_locale.inspect}) doesn't match the lang in its frontmatter (#{frontmatter_locale.inspect})"
145
145
  end
146
146
 
147
- locale_lang = I18n.default_locale if defined? I18n
147
+ default_locale = I18n.default_locale if defined? ::I18n
148
148
 
149
- lang = frontmatter_lang || filename_lang || locale_lang
150
- lang && lang.to_sym
149
+ found_locale = frontmatter_locale || filename_locale || default_locale
150
+ found_locale && found_locale.to_sym
151
151
  end
152
152
 
153
+ alias_method :lang, :locale
154
+
153
155
  # Attempt to figure out the date of the post. The date should be
154
156
  # present in the source path, but users may also provide a date
155
157
  # in the frontmatter in order to provide a time of day for sorting
@@ -42,12 +42,11 @@ module Middleman
42
42
  # A list of all blog articles with the given language,
43
43
  # sorted by descending date
44
44
  #
45
- # @param [Symbol] lang Language to match (optional, defaults to I18n.locale).
45
+ # @param [Symbol] locale Language to match (optional, defaults to I18n.locale).
46
46
  # @return [Array<Middleman::Sitemap::Resource>]
47
- def local_articles(lang=nil)
48
- lang ||= I18n.locale
49
- lang = lang.to_sym if lang.kind_of? String
50
- articles.select {|article| article.lang == lang }
47
+ def local_articles(locale=::I18n.locale)
48
+ locale = locale.to_sym if locale.kind_of? String
49
+ articles.select {|article| article.locale == locale }
51
50
  end
52
51
 
53
52
  # Returns a map from tag name to an array
@@ -55,6 +54,7 @@ module Middleman
55
54
  # @return [Hash<String, Array<Middleman::Sitemap::Resource>>]
56
55
  def tags
57
56
  tags = {}
57
+
58
58
  @_articles.each do |article|
59
59
  article.tags.each do |tag|
60
60
  tags[tag] ||= []
@@ -89,12 +89,12 @@ module Middleman
89
89
  next unless publishable?(article)
90
90
 
91
91
  # Add extra parameters from the URL to the page metadata
92
- extra_data = params.except *%w(year month day title lang)
92
+ extra_data = params.except *%w(year month day title lang locale)
93
93
  article.add_metadata page: extra_data unless extra_data.empty?
94
94
 
95
95
  # compute output path:
96
96
  # substitute date parts to path pattern
97
- article.destination_path = template_path @permalink_template, article
97
+ article.destination_path = template_path @permalink_template, article, extra_data
98
98
 
99
99
  @_articles << article
100
100
 
@@ -110,10 +110,13 @@ module Middleman
110
110
  article = convert_to_article(article)
111
111
  next unless publishable?(article)
112
112
 
113
+ # Add extra parameters from the URL to the page metadata
114
+ extra_data = params.except *%w(year month day title lang locale)
115
+ article.add_metadata page: extra_data unless extra_data.empty?
116
+
113
117
  # The subdir path is the article path with the index file name
114
118
  # or file extension stripped off.
115
- path = params.fetch('path')
116
- new_destination_path = template_path @subdir_permalink_template, article, path: path
119
+ new_destination_path = template_path @subdir_permalink_template, article, extra_data
117
120
 
118
121
  resource.destination_path = Middleman::Util.normalize_path(new_destination_path)
119
122
  end
@@ -145,14 +148,15 @@ module Middleman
145
148
  # @return [Hash] options
146
149
  def permalink_options(resource, extra={})
147
150
  # Allow any frontmatter data to be substituted into the permalink URL
148
- params = resource.metadata[:page].slice *@permalink_template.variables
151
+ params = resource.metadata[:page].slice *@permalink_template.variables.map(&:to_sym)
152
+
149
153
  params.each do |k, v|
150
154
  params[k] = safe_parameterize(v)
151
155
  end
152
156
 
153
157
  params.
154
158
  merge(date_to_params(resource.date)).
155
- merge(lang: resource.lang.to_s, title: resource.slug).
159
+ merge(lang: resource.lang.to_s, locale: resource.locale.to_s, title: resource.slug).
156
160
  merge(extra)
157
161
  end
158
162
 
@@ -162,8 +166,8 @@ module Middleman
162
166
  resource.extend BlogArticle
163
167
  resource.blog_controller = controller
164
168
 
165
- if !options.preserve_locale && (lang = resource.lang)
166
- resource.add_metadata options: { lang: lang }, locals: { lang: lang }
169
+ if !options.preserve_locale && (locale = resource.locale || resource.lang)
170
+ resource.add_metadata options: { lang: locale, lang: locale }, locals: { lang: locale, locale: locale }
167
171
  end
168
172
 
169
173
  resource