plate 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/plate/dsl.rb +47 -0
- data/lib/plate/version.rb +1 -1
- metadata +1 -1
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,7 @@ In addition to basic formatting with Markdown, Plate also supports generating mo
|
|
8
8
|
|
9
9
|
Plate is a command line utility installed as a Ruby Gem. Installation requires Ruby 1.8.7, 1.9.2 or 1.9.3.
|
10
10
|
|
11
|
-
Current version is **0.7.
|
11
|
+
Current version is **0.7.2**
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
data/lib/plate/dsl.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext/array'
|
3
|
+
|
1
4
|
module Plate
|
2
5
|
# The Dsl class provides the methods available in plugin files in order to extend
|
3
6
|
# the functionality a generated site.
|
@@ -234,5 +237,49 @@ module Plate
|
|
234
237
|
end
|
235
238
|
end
|
236
239
|
end
|
240
|
+
|
241
|
+
# Paged archived posts
|
242
|
+
def archive_paged_items(options, &block)
|
243
|
+
filter_category = options[:category] || nil
|
244
|
+
per_page = options[:per_page] || 10
|
245
|
+
|
246
|
+
callback :site, :after_render do |site|
|
247
|
+
posts = []
|
248
|
+
current_page = 1
|
249
|
+
|
250
|
+
site.posts.archives.keys.each do |year|
|
251
|
+
site.posts.archives[year].keys.each do |month|
|
252
|
+
site.posts.archives[year][month].each_value do |day|
|
253
|
+
posts << day.select { |post| filter_category == nil or post.category == filter_category }
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
posts.flatten!
|
259
|
+
|
260
|
+
groups = posts.in_groups_of(per_page, false)
|
261
|
+
|
262
|
+
groups.each do |group|
|
263
|
+
page = DynamicPage.new(site, "/page/#{current_page}")
|
264
|
+
proxy = PageProxy.new(page, site)
|
265
|
+
proxy._category = filter_category if filter_category
|
266
|
+
|
267
|
+
proxy.locals = {
|
268
|
+
:current_page => current_page,
|
269
|
+
:previous_page => (current_page > 1 ? (current_page - 1) : nil),
|
270
|
+
:next_page => (current_page < groups.size ? (current_page + 1) : nil),
|
271
|
+
:paged_posts => group,
|
272
|
+
:page => current_page
|
273
|
+
}
|
274
|
+
|
275
|
+
proxy.instance_eval(&block)
|
276
|
+
page.write!
|
277
|
+
proxy = nil
|
278
|
+
page = nil
|
279
|
+
|
280
|
+
current_page = current_page + 1
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
237
284
|
end
|
238
285
|
end
|
data/lib/plate/version.rb
CHANGED