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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## Plate 0.7.2
2
+
3
+ * Added paged posts archive DSL method.
4
+
1
5
  ## Plate 0.7.1
2
6
 
3
7
  * Added DSL method `write` to create a dynamic page.
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.1**
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
@@ -1,3 +1,3 @@
1
1
  module Plate
2
- VERSION = "0.7.1" unless defined?(::Plate::VERSION)
2
+ VERSION = "0.7.2" unless defined?(::Plate::VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: