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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/octopress-multilingual.rb +20 -13
- data/lib/octopress-multilingual/jekyll.rb +16 -8
- data/lib/octopress-multilingual/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55767d804774338b29cb6aa179a2860f02340830
|
4
|
+
data.tar.gz: 9c08d484dc5849979db2f02ca88ec38077915a68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 936197c883e054290766af156b34a1ae5c7cbcaf53c577d4ef14af2b68562d700d866b5924900d24191ab4caad8ab8960cfdc636adf3c10ca6e1e2facb2f75e5
|
7
|
+
data.tar.gz: b58cc57ee3c12ce7c73991bcd38c313bc4fddd1f43228f3f7ad7eba7eff1d5064f092a61e4b994da3bbbcb0de76eeff526a913dadd371e5f4c8533ca9256604d
|
data/CHANGELOG.md
CHANGED
@@ -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
|
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
|
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
|
170
|
-
'linkposts' => linkposts_by_language
|
171
|
-
'articles' => articles_by_language
|
172
|
-
'categories' => categories_by_language
|
173
|
-
'tags' => tags_by_language
|
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
|
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
|
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
|
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.
|
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-
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octopress-hooks
|