octopress-multilingual 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f63e94caebb32bb02400c36549a41dcdac7b6233
4
- data.tar.gz: d8d6a66d61b17e308e368beaeda4755192efdcb8
3
+ metadata.gz: 55767d804774338b29cb6aa179a2860f02340830
4
+ data.tar.gz: 9c08d484dc5849979db2f02ca88ec38077915a68
5
5
  SHA512:
6
- metadata.gz: 763b84afc697d3223900e426c8141bf6e5075e833b24860a47f079489b0d3136ee6ce3346973948027dddd1b91417b020840762e873db1f3432a239f84ad3681
7
- data.tar.gz: 5a4a430a9d3058bc3728c6c6a99635ccbee09e413f5b6248ef5d0a1437fd63c7b1a7da7e550172f6b572674fa7929eb02ea2d84820b8463b4b971d479e479edd
6
+ metadata.gz: 936197c883e054290766af156b34a1ae5c7cbcaf53c577d4ef14af2b68562d700d866b5924900d24191ab4caad8ab8960cfdc636adf3c10ca6e1e2facb2f75e5
7
+ data.tar.gz: b58cc57ee3c12ce7c73991bcd38c313bc4fddd1f43228f3f7ad7eba7eff1d5064f092a61e4b994da3bbbcb0de76eeff526a913dadd371e5f4c8533ca9256604d
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.2.0 (2015-03-05)
4
+ - New: Site methods, `tags_by_language` and `categories_by_language`.
5
+ - New: Methods `posts_by_language`, `articles_by_language`, `linkposts_by_language`, `categories_by_language`, `tags_by_language` now accept a language and return an empty array or empty hash rather than `nil` if no posts exist.
6
+
3
7
  ### 1.1.3 (2015-03-02)
4
8
  - Fix: Posts permalinks will only have language defined if the site has a default language.
5
9
 
@@ -71,7 +71,7 @@ module Octopress
71
71
  end
72
72
  end
73
73
 
74
- def posts_by_language
74
+ def posts_by_language(lang=nil)
75
75
  @posts_by_language ||= begin
76
76
  posts = site.posts.reverse.select(&:lang).group_by(&:lang)
77
77
  ## Add posts that crosspost to all languages
@@ -83,9 +83,10 @@ module Octopress
83
83
  end
84
84
 
85
85
  posts[main_language] = main_language_posts
86
-
87
86
  posts
88
87
  end
88
+
89
+ @posts_by_language[lang] || []
89
90
  end
90
91
 
91
92
  def crossposts
@@ -102,12 +103,12 @@ module Octopress
102
103
  @posts_without_lang ||= site.reject(&:lang)
103
104
  end
104
105
 
105
- def articles_by_language
106
+ def articles_by_language(lang=nil)
106
107
  @articles_by_language ||= begin
107
108
  articles = {}
108
109
 
109
110
  languages.each do |lang|
110
- if posts = posts_by_language[lang]
111
+ if posts = posts_by_language(lang)
111
112
  articles[lang] = posts.reject do |p|
112
113
  p.data['linkpost']
113
114
  end
@@ -116,14 +117,16 @@ module Octopress
116
117
 
117
118
  articles
118
119
  end
120
+
121
+ @articles_by_language[lang] || []
119
122
  end
120
123
 
121
- def linkposts_by_language
124
+ def linkposts_by_language(lang=nil)
122
125
  @linkposts_by_language ||= begin
123
126
  linkposts = {}
124
127
 
125
128
  languages.each do |lang|
126
- if posts = posts_by_language[lang]
129
+ if posts = posts_by_language(lang)
127
130
  linkposts[lang] = posts.select do |p|
128
131
  p.data['linkpost']
129
132
  end
@@ -132,6 +135,8 @@ module Octopress
132
135
 
133
136
  linkposts
134
137
  end
138
+
139
+ @linkposts_by_language[lang] || []
135
140
  end
136
141
 
137
142
  def metadata_index_by_language(index)
@@ -155,22 +160,24 @@ module Octopress
155
160
  indexes
156
161
  end
157
162
 
158
- def categories_by_language
163
+ def categories_by_language(lang=nil)
159
164
  @categories ||= metadata_index_by_language(:categories)
165
+ @categories[lang] || {}
160
166
  end
161
167
 
162
- def tags_by_language
168
+ def tags_by_language(lang=nil)
163
169
  @tags ||= metadata_index_by_language(:tags)
170
+ @tags[lang] || {}
164
171
  end
165
172
 
166
173
  def page_payload(lang)
167
174
  payload = {
168
175
  'site' => {
169
- 'posts' => posts_by_language[lang],
170
- 'linkposts' => linkposts_by_language[lang],
171
- 'articles' => articles_by_language[lang],
172
- 'categories' => categories_by_language[lang],
173
- 'tags' => tags_by_language[lang]
176
+ 'posts' => posts_by_language(lang),
177
+ 'linkposts' => linkposts_by_language(lang),
178
+ 'articles' => articles_by_language(lang),
179
+ 'categories' => categories_by_language(lang),
180
+ 'tags' => tags_by_language(lang)
174
181
  },
175
182
  'lang' => lang_dict[lang]
176
183
  }
@@ -17,16 +17,24 @@ module Jekyll
17
17
  Octopress::Multilingual.languages
18
18
  end
19
19
 
20
- def posts_by_language
21
- Octopress::Multilingual.posts_by_language
20
+ def posts_by_language(lang=nil)
21
+ Octopress::Multilingual.posts_by_language(lang)
22
22
  end
23
23
 
24
- def articles_by_language
25
- Octopress::Multilingual.articles_by_language
24
+ def articles_by_language(lang=nil)
25
+ Octopress::Multilingual.articles_by_language(lang)
26
26
  end
27
27
 
28
- def linkposts_by_language
29
- Octopress::Multilingual.linkposts_by_language
28
+ def linkposts_by_language(lang=nil)
29
+ Octopress::Multilingual.linkposts_by_language(lang)
30
+ end
31
+
32
+ def categories_by_language(lang=nil)
33
+ Octopress::Multilingual.categories_by_language(lang)
34
+ end
35
+
36
+ def tags_by_language(lang=nil)
37
+ Octopress::Multilingual.tags_by_language(lang)
30
38
  end
31
39
  end
32
40
 
@@ -117,7 +125,7 @@ module Jekyll
117
125
 
118
126
  def next
119
127
  language = lang || site.config['lang']
120
- posts = Octopress::Multilingual.posts_by_language[language]
128
+ posts = Octopress::Multilingual.posts_by_language(language)
121
129
 
122
130
  pos = posts.index {|post| post.equal?(self) }
123
131
  if pos && pos < posts.length - 1
@@ -129,7 +137,7 @@ module Jekyll
129
137
 
130
138
  def previous
131
139
  language = lang || site.config['lang']
132
- posts = Octopress::Multilingual.posts_by_language[language]
140
+ posts = Octopress::Multilingual.posts_by_language(language)
133
141
 
134
142
  pos = posts.index {|post| post.equal?(self) }
135
143
  if pos && pos > 0
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Multilingual
3
- VERSION = "1.1.3"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-multilingual
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-02 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octopress-hooks