middleman-blog 3.5.3 → 3.6.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23f47f0936e797509009d946ca8e2cf1c5c7cc37
4
- data.tar.gz: 444623757d6de91c8c90a3c50945c440c588263f
3
+ metadata.gz: 6fd8e5447b47c113fc7c58ae2cd7555cc070adcf
4
+ data.tar.gz: d4586b9545fc038a1af9d415255952b0e3cdda76
5
5
  SHA512:
6
- metadata.gz: d46bbcd2deb299eb086603cc98a1d8b2246d8c50b114033e0852498de57d62747a9ae9f0aa92c4fa3fe8fad4f5d6b57c2b14c6a91ecd9a7507e60f0d2d2a517e
7
- data.tar.gz: 7914d29e266f0c96bf0d31aa3053c9c65838036d2da5f734b1133c54fff92abf3095b1a0c141160a6ad0a6a9c2ff0de5dbe5b89d9b4b10e547802ece075b6d79
6
+ metadata.gz: f35f5e4c6bb2c3b56e3bde38ff60928ecd49b56656acba2a338b7752ad6406d707b323fbea63e82041ad2fa5837205cdcefedbd791b65defd7741138814aa8c0
7
+ data.tar.gz: d8fbcc07cce2c0c330e1b0969ffe0eee303d1964752398d2d5f4d028394f6a09df65b43932c943fb41c6bd8c279fe7460968b0d07d60cef6fb870840ab5bccdc
@@ -50,6 +50,31 @@ Feature: Pagination
50
50
  Then I should not see "/2011-01-04-test-article.html"
51
51
  Then I should not see "/2011-01-03-test-article.html"
52
52
 
53
+ When I go to "/categories/ruby-on-rails.html"
54
+ Then I should see "Paginate: true"
55
+ Then I should see "Article Count: 2"
56
+ Then I should see "Num Pages: 3"
57
+ Then I should see "Page Start: 1"
58
+ Then I should see "Page End: 2"
59
+ Then I should see "Next Page: '/categories/ruby-on-rails/page/2.html'"
60
+ Then I should see "Prev Page: ''"
61
+ Then I should see "/2011-01-05-test-article.html"
62
+ Then I should see "/2011-01-04-test-article.html"
63
+ Then I should not see "/2011-01-03-test-article.html"
64
+ Then I should not see "/2011-01-02-test-article.html"
65
+
66
+ When I go to "/categories/ruby-on-rails/page/2.html"
67
+ Then I should see "Article Count: 2"
68
+ Then I should see "Num Pages: 3"
69
+ Then I should see "Page Start: 3"
70
+ Then I should see "Page End: 4"
71
+ Then I should see "Next Page: '/categories/ruby-on-rails/page/3.html'"
72
+ Then I should see "Prev Page: '/categories/ruby-on-rails.html'"
73
+ Then I should not see "/2011-01-05-test-article.html"
74
+ Then I should not see "/2011-01-04-test-article.html"
75
+ Then I should see "/2011-01-03-test-article.html"
76
+ Then I should see "/2011-01-02-test-article.html"
77
+
53
78
  Scenario: Index pages are accessible from preview server, with pagination off
54
79
  Given a fixture app "paginate-app"
55
80
  And app "paginate-app" is using config "paginate-off"
@@ -96,6 +121,21 @@ Feature: Pagination
96
121
  Then I should not see "/2011-01-04-test-article.html"
97
122
  Then I should not see "/2011-01-03-test-article.html"
98
123
 
124
+ When I go to "/categories/ruby-on-rails.html"
125
+ Then I should see "Paginate: false"
126
+ Then I should see "Article Count: 2"
127
+ Then I should see "/2011-01-05-test-article.html"
128
+ Then I should see "/2011-01-04-test-article.html"
129
+ Then I should not see "/2011-01-03-test-article.html"
130
+ Then I should not see "/2011-01-02-test-article.html"
131
+
132
+ When I go to "/categories/travel.html"
133
+ Then I should see "Paginate: false"
134
+ Then I should see "Article Count: 2"
135
+ Then I should see "/2011-02-02-test-article.html"
136
+ Then I should see "/2011-02-01-test-article.html"
137
+ Then I should not see "/2011-01-05-test-article.html"
138
+
99
139
  Scenario: Index pages are accessible from preview server, with directory_indexes on
100
140
  Given a fixture app "paginate-app"
101
141
  And app "paginate-app" is using config "directory-indexes"
@@ -114,19 +154,27 @@ Feature: Pagination
114
154
  When I go to "/tags/bar/"
115
155
  Then I should see "Next Page: '/tags/bar/page/2/'"
116
156
 
157
+ When I go to "/categories/ruby-on-rails/"
158
+ Then I should see "Next Page: '/categories/ruby-on-rails/page/2/'"
159
+
117
160
  Scenario: Index pages also get built
118
161
  Given a successfully built app at "paginate-app"
119
162
  When I cd to "build"
120
163
  Then the following files should exist:
121
- | tags/foo.html |
122
- | tags/bar.html |
123
- | tags/bar/page/2.html |
124
- | tags/bar/page/3.html |
125
- | 2011.html |
126
- | 2011/page/2.html |
164
+ | tags/foo.html |
165
+ | tags/bar.html |
166
+ | tags/bar/page/2.html |
167
+ | tags/bar/page/3.html |
168
+ | categories/ruby-on-rails.html |
169
+ | categories/ruby-on-rails/page/2.html |
170
+ | categories/ruby-on-rails/page/3.html |
171
+ | categories/travel.html |
172
+ | 2011.html |
173
+ | 2011/page/2.html |
127
174
  Then the following files should not exist:
128
175
  | tags.html |
129
176
  | calendar.html |
177
+ | category.html |
130
178
 
131
179
  And the file "2011/page/2.html" should contain "Year: '2011'"
132
180
  And the file "2011/page/2.html" should contain "Month: ''"
@@ -148,6 +196,13 @@ Feature: Pagination
148
196
  And the file "tags/bar/page/3.html" should contain "Next Page: ''"
149
197
  And the file "tags/bar/page/3.html" should contain "/2011-01-03-test-article.html"
150
198
 
199
+ And the file "categories/ruby-on-rails/page/2.html" should contain "Category: ruby-on-rails"
200
+ And the file "categories/ruby-on-rails/page/2.html" should contain "Article Count: 2"
201
+ And the file "categories/ruby-on-rails/page/2.html" should contain "Prev Page: '/categories/ruby-on-rails.html'"
202
+ And the file "categories/ruby-on-rails/page/2.html" should contain "Next Page: '/categories/ruby-on-rails/page/3.html'"
203
+ And the file "categories/ruby-on-rails/page/2.html" should contain "/2011-01-03-test-article.html"
204
+ And the file "categories/ruby-on-rails/page/2.html" should contain "/2011-01-02-test-article.html"
205
+
151
206
  Scenario: Adding a tag to a post in preview adds a new index page
152
207
  Given the Server is running at "paginate-app"
153
208
  When I go to "/tags/foo.html"
@@ -163,6 +218,7 @@ Feature: Pagination
163
218
  title: "Newest Article"
164
219
  date: 2011-02-03
165
220
  tags: foo
221
+ category: ruby-on-rails
166
222
  ---
167
223
 
168
224
  Newer Article Content
@@ -174,3 +230,11 @@ Feature: Pagination
174
230
 
175
231
  When I go to "/tags/foo/page/2.html"
176
232
  Then I should see "/2011-01-01-test-article.html"
233
+
234
+ When I go to "/categories/ruby-on-rails.html"
235
+ Then I should see "Next Page: '/categories/ruby-on-rails/page/2.html'"
236
+ Then I should see "/2011-02-03-new-article.html"
237
+ Then I should not see "/2011-01-04-test-article.html"
238
+
239
+ When I go to "/categories/ruby-on-rails/page/2.html"
240
+ Then I should see "/2011-01-04-test-article.html"
@@ -5,6 +5,13 @@ activate :blog do |blog|
5
5
  blog.tag_template = 'tag.html'
6
6
  blog.paginate = true
7
7
  blog.per_page = 5
8
+
9
+ blog.custom_collections = {
10
+ :category => {
11
+ :link => '/categories/:category.html',
12
+ :template => '/category.html'
13
+ }
14
+ }
8
15
  end
9
16
 
10
17
  activate :directory_indexes
@@ -5,4 +5,11 @@ activate :blog do |blog|
5
5
  blog.tag_template = 'tag.html'
6
6
  #blog.paginate = true
7
7
  blog.per_page = 5
8
+
9
+ blog.custom_collections = {
10
+ :category => {
11
+ :link => '/categories/:category.html',
12
+ :template => '/category.html'
13
+ }
14
+ }
8
15
  end
@@ -5,4 +5,11 @@ activate :blog do |blog|
5
5
  blog.tag_template = 'tag.html'
6
6
  blog.paginate = true
7
7
  blog.per_page = 5
8
+
9
+ blog.custom_collections = {
10
+ :category => {
11
+ :link => '/categories/:category.html',
12
+ :template => '/category.html'
13
+ }
14
+ }
8
15
  end
@@ -2,5 +2,6 @@
2
2
  title: "Test Article"
3
3
  date: 2011-01-01
4
4
  tags: foo
5
+ category: ruby-on-rails
5
6
  ---
6
7
  Test Article Content
@@ -2,5 +2,6 @@
2
2
  title: "Test Article"
3
3
  date: 2011-01-02
4
4
  tags: foo
5
+ category: ruby-on-rails
5
6
  ---
6
7
  Test Article Content
@@ -2,5 +2,6 @@
2
2
  title: "Test Article"
3
3
  date: 2011-01-03
4
4
  tags: bar
5
+ category: ruby-on-rails
5
6
  ---
6
7
  Test Article Content
@@ -2,5 +2,6 @@
2
2
  title: "Test Article"
3
3
  date: 2011-01-04
4
4
  tags: bar
5
+ category: ruby-on-rails
5
6
  ---
6
7
  Test Article Content
@@ -2,5 +2,6 @@
2
2
  title: "Test Article"
3
3
  date: 2011-01-05
4
4
  tags: bar
5
+ category: ruby-on-rails
5
6
  ---
6
7
  Test Article Content
@@ -2,5 +2,6 @@
2
2
  title: "Test Article"
3
3
  date: 2011-02-01
4
4
  tags: bar
5
+ category: travel
5
6
  ---
6
7
  Test Article Content
@@ -2,5 +2,6 @@
2
2
  title: "Test Article"
3
3
  date: 2011-02-02
4
4
  tags: bar
5
+ category: travel
5
6
  ---
6
7
  Test Article Content
@@ -0,0 +1,23 @@
1
+ ---
2
+ pageable: true
3
+ per_page: 2
4
+ ---
5
+ Category: <%= category %>
6
+
7
+ Paginate: <%= paginate %>
8
+ Article Count: <%= page_articles.size %>
9
+ <% if paginate %>
10
+ Page Num: <%= page_number %>
11
+ Num Pages: <%= num_pages %>
12
+ Per Page: <%= per_page %>
13
+ Page Start: <%= page_start %>
14
+ Page End: <%= page_end %>
15
+ Next Page: '<%= next_page.url if next_page %>'
16
+ Prev Page: '<%= prev_page.url if prev_page %>'
17
+ <% end %>
18
+
19
+ <% if page_articles %>
20
+ <% page_articles.each do |article| %>
21
+ <li><a href="<%= article.url %>"><%= article.title %></a> <time><%= article.date.strftime('%b %e') %></time></li>
22
+ <% end %>
23
+ <% end %>
@@ -1,7 +1,13 @@
1
1
  require "middleman-core"
2
2
 
3
3
  require "middleman-blog/version"
4
- require "middleman-blog/template"
4
+
5
+ begin
6
+ require "middleman-blog/template"
7
+ rescue LoadError
8
+ # v4
9
+ end
10
+
5
11
  require "middleman-blog/commands/article"
6
12
 
7
13
  ::Middleman::Extensions.register(:blog) do
@@ -57,7 +57,7 @@ module Middleman
57
57
  # An article is considered published in the following scenarios:
58
58
  #
59
59
  # 1. Frontmatter does not set +published+ to false and either
60
- # 2. The blog option +published_future_dated+ is true or
60
+ # 2. The blog option +publish_future_dated+ is true or
61
61
  # 3. The article's date is after the current time
62
62
  # @return [Boolean]
63
63
  def published?
@@ -28,7 +28,7 @@ module Middleman
28
28
  desc: "The date to create the post with (defaults to now)"
29
29
  method_option "lang",
30
30
  aliases: "-l",
31
- desc: "The language to create the post with (defaults to I18n.default_locale if avaliable)"
31
+ desc: "The language to create the post with (defaults to I18n.default_locale if available)"
32
32
  method_option "blog",
33
33
  aliases: "-b",
34
34
  desc: "The name of the blog to create the post inside (for multi-blog apps, defaults to the only blog in single-blog apps)"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: <%= @title %>
3
- date: <%= @date.strftime('%F %R %Z') %>
3
+ date: <%= @date.strftime('%F %R %z') %>
4
4
  tags:
5
5
  ---
6
6
 
@@ -86,7 +86,7 @@ module Middleman
86
86
  end
87
87
 
88
88
  def after_configuration
89
- @name ||= :"blog#{@app.blog_instances.keys.length}"
89
+ @name ||= :"blog#{::Middleman::Blog.instances.keys.length}"
90
90
 
91
91
  # TODO: break up into private methods?
92
92
 
@@ -96,7 +96,7 @@ module Middleman
96
96
  @app.ignore(options.day_template) if options.day_template
97
97
  @app.ignore options.tag_template if options.tag_template
98
98
 
99
- @app.blog_instances[@name] = self
99
+ ::Middleman::Blog.instances[@name] = self
100
100
 
101
101
  # Make sure ActiveSupport's TimeZone stuff has something to work with,
102
102
  # allowing people to set their desired time zone via Time.zone or
@@ -128,16 +128,16 @@ module Middleman
128
128
  @app.sitemap.register_resource_list_manipulator(:"blog_#{name}_calendar", @calendar_pages, false)
129
129
  end
130
130
 
131
+ if options.custom_collections
132
+ require 'middleman-blog/custom_pages'
133
+ register_custom_pages
134
+ end
135
+
131
136
  if options.paginate
132
137
  require 'middleman-blog/paginator'
133
138
  @paginator = Blog::Paginator.new(@app, self)
134
139
  @app.sitemap.register_resource_list_manipulator(:"blog_#{name}_paginate", @paginator, false)
135
140
  end
136
-
137
- if options.custom_collections
138
- require 'middleman-blog/custom_pages'
139
- register_custom_pages
140
- end
141
141
  end
142
142
 
143
143
  private
@@ -1,14 +1,26 @@
1
1
  module Middleman
2
2
  module Blog
3
+ def self.instances
4
+ @blog_instances ||= {}
5
+ end
6
+
7
+ def self.instances=(v)
8
+ @blog_instances = v
9
+ end
10
+
3
11
  # Blog-related helpers that are available to the Middleman application in +config.rb+ and in templates.
4
12
  module Helpers
13
+ def self.included(base)
14
+ ::Middleman::Blog.instances = {}
15
+ end
16
+
5
17
  # All the blog instances known to this Middleman app, keyed by name. A new blog is added
6
18
  # every time the blog extension is activated. Name them by setting the +:name+
7
19
  # option when activating - otherwise they get an automatic name like 'blog0', 'blog1', etc.
8
20
  #
9
21
  # @return [Hash<Symbol,BlogExtension>] a hash of all blog instances by name
10
22
  def blog_instances
11
- @blog_instances ||= {}
23
+ ::Middleman::Blog.instances
12
24
  end
13
25
 
14
26
  # Retrieve a {BlogExtension} instance.
@@ -33,7 +45,12 @@ module Middleman
33
45
 
34
46
  # In multiblog situations, force people to specify the blog
35
47
  if !blog_name && blog_instances.size > 1
36
- raise "You must either specify the blog name in calling this method or in your page frontmatter (using the 'blog' blog_name)"
48
+ raise "You have more than one blog so you must either use the flag --blog (ex. --blog 'myBlog') when calling this method, or add blog: [blog_name] to your page's frontmatter"
49
+ end
50
+
51
+ # Warn if a non-existent blog name provided
52
+ if blog_name && !blog_instances.keys.include?(blog_name)
53
+ raise "Non-existent blog name provided: #{blog_name}."
37
54
  end
38
55
 
39
56
  blog_name ||= blog_instances.keys.first
@@ -144,9 +144,9 @@ module Middleman
144
144
  res.path
145
145
  else
146
146
  page_url = apply_uri_template page_link, num: page_num
147
- index_re = %r{(^|/)#{Regexp.escape(@app.index_file)}$}
147
+ index_re = %r{(^|/)#{Regexp.escape(@app.config[:index_file])}$}
148
148
  if res.path =~ index_re
149
- res.path.sub(index_re, "\\1#{page_url}/#{@app.index_file}")
149
+ res.path.sub(index_re, "\\1#{page_url}/#{@app.config[:index_file]}")
150
150
  else
151
151
  res.path.sub(%r{(^|/)([^/]*)\.([^/]*)$}, "\\1\\2/#{page_url}.\\3")
152
152
  end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Blog
3
- VERSION = "3.5.3"
3
+ VERSION = "3.6.0.beta.2"
4
4
  end
5
5
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ["lib"]
18
18
  s.required_ruby_version = '>= 1.9.3'
19
19
 
20
- s.add_dependency("middleman-core", ["~> 3.2"])
20
+ s.add_dependency("middleman-core", [">= 3.3"])
21
21
  s.add_dependency("tzinfo", [">= 0.3.0"])
22
22
  s.add_dependency("addressable", ["~> 2.3.5"])
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.3
4
+ version: 3.6.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Reynolds
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-24 00:00:00.000000000 Z
12
+ date: 2014-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: middleman-core
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '3.2'
20
+ version: '3.3'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '3.2'
27
+ version: '3.3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: tzinfo
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -252,6 +252,7 @@ files:
252
252
  - fixtures/paginate-app/source/blog/2011-02-01-test-article.html.markdown
253
253
  - fixtures/paginate-app/source/blog/2011-02-02-test-article.html.markdown
254
254
  - fixtures/paginate-app/source/calendar.html.erb
255
+ - fixtures/paginate-app/source/category.html.erb
255
256
  - fixtures/paginate-app/source/index.html.erb
256
257
  - fixtures/paginate-app/source/layout.erb
257
258
  - fixtures/paginate-app/source/tag.html.erb
@@ -369,9 +370,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
369
370
  version: 1.9.3
370
371
  required_rubygems_version: !ruby/object:Gem::Requirement
371
372
  requirements:
372
- - - ">="
373
+ - - ">"
373
374
  - !ruby/object:Gem::Version
374
- version: '0'
375
+ version: 1.3.1
375
376
  requirements: []
376
377
  rubyforge_project:
377
378
  rubygems_version: 2.2.2
@@ -560,6 +561,7 @@ test_files:
560
561
  - fixtures/paginate-app/source/blog/2011-02-01-test-article.html.markdown
561
562
  - fixtures/paginate-app/source/blog/2011-02-02-test-article.html.markdown
562
563
  - fixtures/paginate-app/source/calendar.html.erb
564
+ - fixtures/paginate-app/source/category.html.erb
563
565
  - fixtures/paginate-app/source/index.html.erb
564
566
  - fixtures/paginate-app/source/layout.erb
565
567
  - fixtures/paginate-app/source/tag.html.erb