jekyll-localization 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  = Revision history for jekyll-localization
2
2
 
3
+ == 0.1.6 [2012-05-24]
4
+
5
+ * Added support for Jekyll::Site#set_payload (custom extension).
6
+
3
7
  == 0.1.5 [2012-05-23]
4
8
 
5
9
  * Don't space pad day.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to jekyll-localization version 0.1.5
5
+ This documentation refers to jekyll-localization version 0.1.6
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -209,13 +209,22 @@ module Jekyll
209
209
 
210
210
  module Helpers
211
211
 
212
+ def localized_posts(posts, page, only = false)
213
+ lang = page.lang
214
+ lang ? posts.select { |post| post.lang == lang } : only ? nil : posts
215
+ end
216
+
212
217
  def localize_posts(site, page)
213
- original_posts, lang = site.posts.dup, page.lang
214
- site.posts.delete_if { |post| post.lang != lang } if lang
218
+ s = site.respond_to?(:set_payload)
219
+
220
+ o = s ? site.get_payload('posts') : site.posts.dup
221
+ l = localized_posts(o, page, true)
222
+
223
+ s ? site.set_payload('posts' => l) : site.posts.replace(l) if l
215
224
 
216
225
  yield
217
226
  ensure
218
- site.posts.replace(original_posts) if original_posts && lang
227
+ s ? site.set_payload('posts' => o) : site.posts.replace(o) if l
219
228
  end
220
229
 
221
230
  end
@@ -264,7 +273,7 @@ module Jekyll
264
273
  end
265
274
 
266
275
  def local_posts
267
- localize_posts(@site, @page) { site.posts.dup }
276
+ localized_posts(@site.posts, @page)
268
277
  end
269
278
 
270
279
  # call-seq:
@@ -6,7 +6,7 @@ module Jekyll
6
6
 
7
7
  MAJOR = 0
8
8
  MINOR = 1
9
- TINY = 5
9
+ TINY = 6
10
10
 
11
11
  class << self
12
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-localization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-05-23 00:00:00.000000000 Z
13
+ date: 2012-05-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jekyll-rendering
@@ -54,7 +54,7 @@ rdoc_options:
54
54
  - --line-numbers
55
55
  - --all
56
56
  - --title
57
- - jekyll-localization Application documentation (v0.1.5)
57
+ - jekyll-localization Application documentation (v0.1.6)
58
58
  - --main
59
59
  - README
60
60
  require_paths: