middleman-blog 3.3.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Gemfile-3.0 +1 -1
- data/features/custom_collections.feature +70 -0
- data/features/custom_collections_multiblog.feature +58 -0
- data/features/custom_permalinks_feature.feature +33 -0
- data/features/tags_multiblog.feature +28 -2
- data/fixtures/calendar-and-tag-app/config-directory-indexes.rb +0 -1
- data/fixtures/calendar-app/config-directory-indexes.rb +0 -1
- data/fixtures/custom-collections-app/config-blog-prefix.rb +13 -0
- data/fixtures/custom-collections-app/config-directory-indexes.rb +13 -0
- data/fixtures/custom-collections-app/config.rb +12 -0
- data/fixtures/custom-collections-app/source/blog/2011-01-01-new-article.html.markdown +8 -0
- data/fixtures/custom-collections-app/source/blog/2011-01-02-another-article.html.markdown +9 -0
- data/fixtures/custom-collections-app/source/category.html.erb +7 -0
- data/fixtures/custom-collections-app/source/index.html.erb +5 -0
- data/fixtures/custom-collections-app/source/layout.erb +13 -0
- data/fixtures/custom-collections-multiblog-app/config.rb +27 -0
- data/fixtures/custom-collections-multiblog-app/source/blog1/2011-01-01-new-article.html.markdown +7 -0
- data/fixtures/custom-collections-multiblog-app/source/blog1/2011-01-02-another-article.html.markdown +7 -0
- data/fixtures/custom-collections-multiblog-app/source/blog2/2011-01-01-new-article.html.markdown +7 -0
- data/fixtures/custom-collections-multiblog-app/source/blog2/2011-01-02-another-article.html.markdown +7 -0
- data/fixtures/custom-collections-multiblog-app/source/category1.html.erb +7 -0
- data/fixtures/custom-collections-multiblog-app/source/category2.html.erb +7 -0
- data/fixtures/custom-collections-multiblog-app/source/index.html.erb +8 -0
- data/fixtures/custom-collections-multiblog-app/source/layout.erb +13 -0
- data/fixtures/custom-permalinks-app/config-directory-indexes.rb +7 -0
- data/fixtures/custom-permalinks-app/config.rb +5 -0
- data/fixtures/custom-permalinks-app/source/blog/2011-01-01-new-article.html.markdown +7 -0
- data/fixtures/custom-permalinks-app/source/blog/2011-01-02-another-article.html.markdown +7 -0
- data/fixtures/custom-permalinks-app/source/blog/2011-01-03-third-article.html.markdown +7 -0
- data/fixtures/custom-permalinks-app/source/index.html.erb +3 -0
- data/fixtures/custom-permalinks-app/source/layout.erb +13 -0
- data/fixtures/indexes-app/config.rb +0 -1
- data/fixtures/layouts-app/config.rb +0 -2
- data/fixtures/multiblog-app/source/index.html.erb +1 -3
- data/fixtures/paginate-app/config-directory-indexes.rb +0 -1
- data/fixtures/tags-app/config-directory-indexes.rb +0 -1
- data/fixtures/tags-app/config.rb +1 -1
- data/fixtures/tags-multiblog-app/config.rb +1 -1
- data/fixtures/tags-multiblog-app/source/blog1/frontmatter_blog_tags.html.erb +9 -0
- data/fixtures/tags-multiblog-app/source/blog1/named_blog_tags.html.erb +5 -0
- data/fixtures/tags-multiblog-app/source/blog2/frontmatter_blog_tags.html.erb +9 -0
- data/fixtures/tags-multiblog-app/source/blog2/named_blog_tags.html.erb +5 -0
- data/lib/middleman-blog/blog_article.rb +7 -2
- data/lib/middleman-blog/blog_data.rb +37 -20
- data/lib/middleman-blog/custom_pages.rb +85 -0
- data/lib/middleman-blog/extension_3_0.rb +28 -1
- data/lib/middleman-blog/extension_3_1.rb +71 -1
- data/lib/middleman-blog/paginator.rb +2 -2
- data/lib/middleman-blog/template/source/feed.xml.builder +1 -1
- data/lib/middleman-blog/template/source/layout.erb +1 -0
- data/lib/middleman-blog/version.rb +1 -1
- data/middleman-blog.gemspec +1 -2
- metadata +67 -18
@@ -24,6 +24,7 @@ module Middleman
|
|
24
24
|
option :per_page, 10, 'Articles per page when paginating'
|
25
25
|
option :page_link, "page/:num", 'HTTP path for paging'
|
26
26
|
option :publish_future_dated, false, 'Whether to pubish articles dated in the future'
|
27
|
+
option :custom_collections, {}, 'Hash of custom frontmatter properties to collect articles on and their options'
|
27
28
|
|
28
29
|
attr_accessor :data, :uid
|
29
30
|
|
@@ -58,6 +59,10 @@ module Middleman
|
|
58
59
|
options.year_link = File.join(options.prefix, options.year_link)
|
59
60
|
options.month_link = File.join(options.prefix, options.month_link)
|
60
61
|
options.day_link = File.join(options.prefix, options.day_link)
|
62
|
+
|
63
|
+
options.custom_collections.each do |key, opts|
|
64
|
+
opts[:link] = File.join(options.prefix, opts[:link])
|
65
|
+
end
|
61
66
|
end
|
62
67
|
end
|
63
68
|
|
@@ -120,6 +125,58 @@ module Middleman
|
|
120
125
|
false
|
121
126
|
)
|
122
127
|
end
|
128
|
+
|
129
|
+
if options.custom_collections
|
130
|
+
require 'middleman-blog/custom_pages'
|
131
|
+
register_custom_pages
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# Register any custom page collections that may be set in the config
|
136
|
+
#
|
137
|
+
# A custom resource list manipulator will be generated for each key in the
|
138
|
+
# custom collections hash.
|
139
|
+
#
|
140
|
+
# The following will collect posts on the "category" frontmatter property:
|
141
|
+
# ```
|
142
|
+
# activate :blog do |blog|
|
143
|
+
# blog.custom_collections = {
|
144
|
+
# link: "/categories/:category.html",
|
145
|
+
# template: "/category.html"
|
146
|
+
# }
|
147
|
+
# end
|
148
|
+
# ```
|
149
|
+
#
|
150
|
+
# Category pages in the example above will use the category.html as a template file
|
151
|
+
# and it will be ignored when building.
|
152
|
+
def register_custom_pages
|
153
|
+
options.custom_collections.each do |property, options|
|
154
|
+
@app.ignore options[:template]
|
155
|
+
@app.sitemap.register_resource_list_manipulator(
|
156
|
+
:"blog_#{uid}_#{property}",
|
157
|
+
::Middleman::Blog::CustomPages.new(property, @app, self),
|
158
|
+
false
|
159
|
+
)
|
160
|
+
|
161
|
+
generate_custom_helper(property)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# Generate helpers to access the path to a custom collection.
|
166
|
+
#
|
167
|
+
# For example, when using a custom property called "category" to collect articles on
|
168
|
+
# the method **category_path** will be generated.
|
169
|
+
#
|
170
|
+
# @param [Symbol] custom_property Custom property which is being used to collect articles on
|
171
|
+
def generate_custom_helper(custom_property)
|
172
|
+
m = Module.new
|
173
|
+
m.module_eval(%Q{
|
174
|
+
def #{custom_property}_path(value, key = nil)
|
175
|
+
sitemap.find_resource_by_path(::Middleman::Blog::CustomPages.link(blog_controller(key).options, :#{custom_property}, value)).try(:url)
|
176
|
+
end
|
177
|
+
})
|
178
|
+
|
179
|
+
app.class.send(:include, m)
|
123
180
|
end
|
124
181
|
|
125
182
|
# Helpers for use within templates and layouts.
|
@@ -129,7 +186,20 @@ module Middleman
|
|
129
186
|
end
|
130
187
|
|
131
188
|
def blog_controller(key=nil)
|
132
|
-
key
|
189
|
+
if !key && current_resource
|
190
|
+
key = current_resource.metadata[:page]["blog"]
|
191
|
+
|
192
|
+
if !key && current_resource.respond_to?(:blog_controller) && current_resource.blog_controller
|
193
|
+
return current_resource.blog_controller
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# In multiblog situations, force people to specify the blog
|
198
|
+
if !key && blog_instances.size > 1
|
199
|
+
raise "You must either specify the blog name in calling this method or in your page frontmatter (using the 'blog' key)"
|
200
|
+
end
|
201
|
+
|
202
|
+
key ||= blog_instances.keys.first
|
133
203
|
blog_instances[key.to_sym]
|
134
204
|
end
|
135
205
|
|
@@ -49,11 +49,11 @@ module Middleman
|
|
49
49
|
|
50
50
|
resources.each do |res|
|
51
51
|
next if res.ignored?
|
52
|
-
|
52
|
+
|
53
53
|
md = res.metadata
|
54
54
|
|
55
55
|
# Skip other blogs' resources
|
56
|
-
res_controller = md[:locals]["blog_controller"] || res.blog_controller
|
56
|
+
res_controller = md[:locals]["blog_controller"] || (res.respond_to?(:blog_controller) && res.blog_controller)
|
57
57
|
next if @blog_controller && res_controller && (res_controller != @blog_controller)
|
58
58
|
override_controller = md[:page]["blog"]
|
59
59
|
next if @blog_controller && override_controller && override_controller != @blog_controller.uid
|
@@ -6,7 +6,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
|
|
6
6
|
xml.id URI.join(site_url, blog.options.prefix.to_s)
|
7
7
|
xml.link "href" => URI.join(site_url, blog.options.prefix.to_s)
|
8
8
|
xml.link "href" => URI.join(site_url, current_page.path), "rel" => "self"
|
9
|
-
xml.updated
|
9
|
+
xml.updated(blog.articles.first.date.to_time.iso8601) unless blog.articles.empty?
|
10
10
|
xml.author { xml.name "Blog Author" }
|
11
11
|
|
12
12
|
blog.articles[0..5].each do |article|
|
data/middleman-blog.gemspec
CHANGED
@@ -15,7 +15,6 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.files = `git ls-files -z`.split("\0")
|
16
16
|
s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0")
|
17
17
|
s.require_paths = ["lib"]
|
18
|
-
s.add_dependency("middleman-core", ["~> 3.
|
19
|
-
s.add_dependency("middleman-more", ["~> 3.0"])
|
18
|
+
s.add_dependency("middleman-core", ["~> 3.2"])
|
20
19
|
s.add_dependency("tzinfo", ["~> 0.3.0"])
|
21
20
|
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.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Reynolds
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: middleman-core
|
@@ -17,28 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '3.
|
20
|
+
version: '3.2'
|
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.
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: middleman-more
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ~>
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '3.0'
|
35
|
-
type: :runtime
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ~>
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '3.0'
|
27
|
+
version: '3.2'
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: tzinfo
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,6 +64,9 @@ files:
|
|
78
64
|
- features/calendar-and-tag.feature
|
79
65
|
- features/calendar.feature
|
80
66
|
- features/calendar_multiblog.feature
|
67
|
+
- features/custom_collections.feature
|
68
|
+
- features/custom_collections_multiblog.feature
|
69
|
+
- features/custom_permalinks_feature.feature
|
81
70
|
- features/directory_indexes.feature
|
82
71
|
- features/filename_date.feature
|
83
72
|
- features/future_date.feature
|
@@ -129,6 +118,30 @@ files:
|
|
129
118
|
- fixtures/calendar-multiblog-app/source/calendar2.html.erb
|
130
119
|
- fixtures/calendar-multiblog-app/source/index.html.erb
|
131
120
|
- fixtures/calendar-multiblog-app/source/layout.erb
|
121
|
+
- fixtures/custom-collections-app/config-blog-prefix.rb
|
122
|
+
- fixtures/custom-collections-app/config-directory-indexes.rb
|
123
|
+
- fixtures/custom-collections-app/config.rb
|
124
|
+
- fixtures/custom-collections-app/source/blog/2011-01-01-new-article.html.markdown
|
125
|
+
- fixtures/custom-collections-app/source/blog/2011-01-02-another-article.html.markdown
|
126
|
+
- fixtures/custom-collections-app/source/category.html.erb
|
127
|
+
- fixtures/custom-collections-app/source/index.html.erb
|
128
|
+
- fixtures/custom-collections-app/source/layout.erb
|
129
|
+
- fixtures/custom-collections-multiblog-app/config.rb
|
130
|
+
- fixtures/custom-collections-multiblog-app/source/blog1/2011-01-01-new-article.html.markdown
|
131
|
+
- fixtures/custom-collections-multiblog-app/source/blog1/2011-01-02-another-article.html.markdown
|
132
|
+
- fixtures/custom-collections-multiblog-app/source/blog2/2011-01-01-new-article.html.markdown
|
133
|
+
- fixtures/custom-collections-multiblog-app/source/blog2/2011-01-02-another-article.html.markdown
|
134
|
+
- fixtures/custom-collections-multiblog-app/source/category1.html.erb
|
135
|
+
- fixtures/custom-collections-multiblog-app/source/category2.html.erb
|
136
|
+
- fixtures/custom-collections-multiblog-app/source/index.html.erb
|
137
|
+
- fixtures/custom-collections-multiblog-app/source/layout.erb
|
138
|
+
- fixtures/custom-permalinks-app/config-directory-indexes.rb
|
139
|
+
- fixtures/custom-permalinks-app/config.rb
|
140
|
+
- fixtures/custom-permalinks-app/source/blog/2011-01-01-new-article.html.markdown
|
141
|
+
- fixtures/custom-permalinks-app/source/blog/2011-01-02-another-article.html.markdown
|
142
|
+
- fixtures/custom-permalinks-app/source/blog/2011-01-03-third-article.html.markdown
|
143
|
+
- fixtures/custom-permalinks-app/source/index.html.erb
|
144
|
+
- fixtures/custom-permalinks-app/source/layout.erb
|
132
145
|
- fixtures/default-template-app/Gemfile
|
133
146
|
- fixtures/default-template-app/config.rb
|
134
147
|
- fixtures/default-template-app/source/2013-04-01-new-article.html.markdown
|
@@ -252,8 +265,12 @@ files:
|
|
252
265
|
- fixtures/tags-multiblog-app/config.rb
|
253
266
|
- fixtures/tags-multiblog-app/source/blog1/2011-01-01-new-article.html.markdown
|
254
267
|
- fixtures/tags-multiblog-app/source/blog1/2011-01-02-another-article.html.markdown
|
268
|
+
- fixtures/tags-multiblog-app/source/blog1/frontmatter_blog_tags.html.erb
|
269
|
+
- fixtures/tags-multiblog-app/source/blog1/named_blog_tags.html.erb
|
255
270
|
- fixtures/tags-multiblog-app/source/blog2/2011-01-01-new-article.html.markdown
|
256
271
|
- fixtures/tags-multiblog-app/source/blog2/2011-01-02-another-article.html.markdown
|
272
|
+
- fixtures/tags-multiblog-app/source/blog2/frontmatter_blog_tags.html.erb
|
273
|
+
- fixtures/tags-multiblog-app/source/blog2/named_blog_tags.html.erb
|
257
274
|
- fixtures/tags-multiblog-app/source/index.html.erb
|
258
275
|
- fixtures/tags-multiblog-app/source/layout.erb
|
259
276
|
- fixtures/tags-multiblog-app/source/tag1.html.erb
|
@@ -266,6 +283,7 @@ files:
|
|
266
283
|
- lib/middleman-blog/calendar_pages.rb
|
267
284
|
- lib/middleman-blog/commands/article.rb
|
268
285
|
- lib/middleman-blog/commands/article.tt
|
286
|
+
- lib/middleman-blog/custom_pages.rb
|
269
287
|
- lib/middleman-blog/extension_3_0.rb
|
270
288
|
- lib/middleman-blog/extension_3_1.rb
|
271
289
|
- lib/middleman-blog/paginator.rb
|
@@ -314,6 +332,9 @@ test_files:
|
|
314
332
|
- features/calendar-and-tag.feature
|
315
333
|
- features/calendar.feature
|
316
334
|
- features/calendar_multiblog.feature
|
335
|
+
- features/custom_collections.feature
|
336
|
+
- features/custom_collections_multiblog.feature
|
337
|
+
- features/custom_permalinks_feature.feature
|
317
338
|
- features/directory_indexes.feature
|
318
339
|
- features/filename_date.feature
|
319
340
|
- features/future_date.feature
|
@@ -365,6 +386,30 @@ test_files:
|
|
365
386
|
- fixtures/calendar-multiblog-app/source/calendar2.html.erb
|
366
387
|
- fixtures/calendar-multiblog-app/source/index.html.erb
|
367
388
|
- fixtures/calendar-multiblog-app/source/layout.erb
|
389
|
+
- fixtures/custom-collections-app/config-blog-prefix.rb
|
390
|
+
- fixtures/custom-collections-app/config-directory-indexes.rb
|
391
|
+
- fixtures/custom-collections-app/config.rb
|
392
|
+
- fixtures/custom-collections-app/source/blog/2011-01-01-new-article.html.markdown
|
393
|
+
- fixtures/custom-collections-app/source/blog/2011-01-02-another-article.html.markdown
|
394
|
+
- fixtures/custom-collections-app/source/category.html.erb
|
395
|
+
- fixtures/custom-collections-app/source/index.html.erb
|
396
|
+
- fixtures/custom-collections-app/source/layout.erb
|
397
|
+
- fixtures/custom-collections-multiblog-app/config.rb
|
398
|
+
- fixtures/custom-collections-multiblog-app/source/blog1/2011-01-01-new-article.html.markdown
|
399
|
+
- fixtures/custom-collections-multiblog-app/source/blog1/2011-01-02-another-article.html.markdown
|
400
|
+
- fixtures/custom-collections-multiblog-app/source/blog2/2011-01-01-new-article.html.markdown
|
401
|
+
- fixtures/custom-collections-multiblog-app/source/blog2/2011-01-02-another-article.html.markdown
|
402
|
+
- fixtures/custom-collections-multiblog-app/source/category1.html.erb
|
403
|
+
- fixtures/custom-collections-multiblog-app/source/category2.html.erb
|
404
|
+
- fixtures/custom-collections-multiblog-app/source/index.html.erb
|
405
|
+
- fixtures/custom-collections-multiblog-app/source/layout.erb
|
406
|
+
- fixtures/custom-permalinks-app/config-directory-indexes.rb
|
407
|
+
- fixtures/custom-permalinks-app/config.rb
|
408
|
+
- fixtures/custom-permalinks-app/source/blog/2011-01-01-new-article.html.markdown
|
409
|
+
- fixtures/custom-permalinks-app/source/blog/2011-01-02-another-article.html.markdown
|
410
|
+
- fixtures/custom-permalinks-app/source/blog/2011-01-03-third-article.html.markdown
|
411
|
+
- fixtures/custom-permalinks-app/source/index.html.erb
|
412
|
+
- fixtures/custom-permalinks-app/source/layout.erb
|
368
413
|
- fixtures/default-template-app/Gemfile
|
369
414
|
- fixtures/default-template-app/config.rb
|
370
415
|
- fixtures/default-template-app/source/2013-04-01-new-article.html.markdown
|
@@ -488,8 +533,12 @@ test_files:
|
|
488
533
|
- fixtures/tags-multiblog-app/config.rb
|
489
534
|
- fixtures/tags-multiblog-app/source/blog1/2011-01-01-new-article.html.markdown
|
490
535
|
- fixtures/tags-multiblog-app/source/blog1/2011-01-02-another-article.html.markdown
|
536
|
+
- fixtures/tags-multiblog-app/source/blog1/frontmatter_blog_tags.html.erb
|
537
|
+
- fixtures/tags-multiblog-app/source/blog1/named_blog_tags.html.erb
|
491
538
|
- fixtures/tags-multiblog-app/source/blog2/2011-01-01-new-article.html.markdown
|
492
539
|
- fixtures/tags-multiblog-app/source/blog2/2011-01-02-another-article.html.markdown
|
540
|
+
- fixtures/tags-multiblog-app/source/blog2/frontmatter_blog_tags.html.erb
|
541
|
+
- fixtures/tags-multiblog-app/source/blog2/named_blog_tags.html.erb
|
493
542
|
- fixtures/tags-multiblog-app/source/index.html.erb
|
494
543
|
- fixtures/tags-multiblog-app/source/layout.erb
|
495
544
|
- fixtures/tags-multiblog-app/source/tag1.html.erb
|