jekyll-localization 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  = Revision history for jekyll-localization
2
2
 
3
+ == 0.0.7 [2010-10-14]
4
+
5
+ * Added filter "local_posts" to get posts in the language of the current page
6
+
3
7
  == 0.0.6 [2010-09-29]
4
8
 
5
9
  * Fixed an oversight in the previous version.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to jekyll-localization version 0.0.6
5
+ This documentation refers to jekyll-localization version 0.0.7
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -149,24 +149,37 @@ module Jekyll
149
149
 
150
150
  end
151
151
 
152
+ module Helpers
153
+
154
+ def localize_posts(site, page)
155
+ original_posts, lang = site.posts.dup, page.lang
156
+ site.posts.delete_if { |post| post.lang != lang } if lang
157
+
158
+ yield
159
+
160
+ ensure
161
+ site.posts.replace(original_posts) if original_posts && page.lang
162
+ end
163
+
164
+ end
165
+
152
166
  class Pagination < Generator
153
167
 
168
+ include Helpers
169
+
154
170
  alias_method :_localization_original_paginate, :paginate
155
171
 
156
172
  # Overwrites the original method to prevent double posts.
157
173
  def paginate(site, page)
158
- all_posts, lang = site.posts.dup, page.lang
159
- site.posts.delete_if { |post| post.lang != lang } if lang
160
-
161
- _localization_original_paginate(site, page)
162
- ensure
163
- site.posts.replace(all_posts) if all_posts && lang
174
+ localize_posts(site, page) { _localization_original_paginate(site, page) }
164
175
  end
165
176
 
166
177
  end
167
178
 
168
179
  module Filters
169
180
 
181
+ include Helpers
182
+
170
183
  def lang
171
184
  if @context.respond_to?(:find_variable, true)
172
185
  @context.send(:find_variable, 'page')['lang']
@@ -175,6 +188,10 @@ module Jekyll
175
188
  end
176
189
  end
177
190
 
191
+ def local_posts
192
+ localize_posts(@site, @page) { site.posts.dup }
193
+ end
194
+
178
195
  # call-seq:
179
196
  # t 'default', 'translation', ... => aString (Ruby-style)
180
197
  # 'default' | t: 'translation', ... => aString (Liquid-style)
@@ -6,7 +6,7 @@ module Jekyll
6
6
 
7
7
  MAJOR = 0
8
8
  MINOR = 0
9
- TINY = 6
9
+ TINY = 7
10
10
 
11
11
  class << self
12
12
 
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-localization
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 6
10
- version: 0.0.6
8
+ - 7
9
+ version: 0.0.7
11
10
  platform: ruby
12
11
  authors:
13
12
  - Jens Wille
@@ -16,18 +15,16 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-09-29 00:00:00 +02:00
18
+ date: 2010-10-14 00:00:00 +02:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
22
  name: jekyll-rendering
24
23
  prerelease: false
25
24
  requirement: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
25
  requirements:
28
26
  - - ">="
29
27
  - !ruby/object:Gem::Version
30
- hash: 3
31
28
  segments:
32
29
  - 0
33
30
  version: "0"
@@ -46,12 +43,12 @@ extra_rdoc_files:
46
43
  - ChangeLog
47
44
  - README
48
45
  files:
49
- - lib/jekyll/localization.rb
50
46
  - lib/jekyll/localization/version.rb
51
- - README
52
- - ChangeLog
47
+ - lib/jekyll/localization.rb
53
48
  - Rakefile
54
49
  - COPYING
50
+ - ChangeLog
51
+ - README
55
52
  has_rdoc: true
56
53
  homepage: http://github.com/blackwinter/jekyll-localization
57
54
  licenses: []
@@ -64,33 +61,29 @@ rdoc_options:
64
61
  - README
65
62
  - --line-numbers
66
63
  - --inline-source
67
- - --all
68
64
  - --charset
69
65
  - UTF-8
66
+ - --all
70
67
  require_paths:
71
68
  - lib
72
69
  required_ruby_version: !ruby/object:Gem::Requirement
73
- none: false
74
70
  requirements:
75
71
  - - ">="
76
72
  - !ruby/object:Gem::Version
77
- hash: 3
78
73
  segments:
79
74
  - 0
80
75
  version: "0"
81
76
  required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
77
  requirements:
84
78
  - - ">="
85
79
  - !ruby/object:Gem::Version
86
- hash: 3
87
80
  segments:
88
81
  - 0
89
82
  version: "0"
90
83
  requirements: []
91
84
 
92
85
  rubyforge_project:
93
- rubygems_version: 1.3.7
86
+ rubygems_version: 1.3.6
94
87
  signing_key:
95
88
  specification_version: 3
96
89
  summary: Jekyll plugin that adds localization features to the rendering engine.