octopress-multilingual 0.0.7 → 0.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ddd7536d8cb455af461184f5861d2c2384c4af6
4
- data.tar.gz: f1d4232c1b20da1e832b866178e8fa245114b81d
3
+ metadata.gz: 81d74a15580418e28ebe00dcd4f8a6cb3dcbc67a
4
+ data.tar.gz: aa61892cf1e4e764dc77d5eee1a6252f8419637e
5
5
  SHA512:
6
- metadata.gz: 0292321bf1138654367fb33650b8b43d0117703084d81d51b476e9686f8d88e1f7e5c8a662102a28749aeb5a8c55f0a8c811eb0cb8c05d99543fc05fac25cf25
7
- data.tar.gz: 9ca4ea2e92f1351d5455c29e4e989c8afadbc571146eabd3b927ead584cdecf64272511630c662ea4012544d5a965d3aa425206b8dcc80eb2801e84a5c0c4a72
6
+ metadata.gz: b7c725533664f672619d4ca3a3000098eebbe7a2266d53076c9e233589514cb09d7d3d8a1851b7bd62cd0958474ec74c01d31c7512ca07f6700d10fab12b673b
7
+ data.tar.gz: 54dd83d45d96e9b5311da61ba385a4681d939b331b79a124b5573b6084a7d6aed129c315a836bd1b684c0629804e6f93ec6172b6b35efc32cfd8e15e2e60545f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.0.8 (2015-01-21)
4
+ - Fix: on posts, page.next and page.previous follow post language
5
+
3
6
  ### 0.0.7 (2015-01-21)
4
7
 
5
8
  - Fix: If no posts had been defined with the main language, posts would disappear. Most embarrassing.
data/README.md CHANGED
@@ -48,13 +48,16 @@ Note: This guide will only cover the steps listed above. Your site may still hav
48
48
 
49
49
  ## Configuration
50
50
 
51
- First, be sure to configure your Jekyll site's main language, for example:
51
+ You can for standard language codes.
52
+
53
+ First, be sure to configure your Jekyll site's main language. An site written primarily in English would add this to its Jekyll configuration:
52
54
 
53
55
  ```yaml
54
56
  lang: en
55
57
  ```
56
58
 
57
59
  Here we are setting the default language to English. Posts without a defined language will be treated as English posts.
60
+ For a list of standard language codes, refer to [ISO 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
58
61
 
59
62
  ## Defining a post's language
60
63
 
@@ -16,10 +16,6 @@ module Octopress
16
16
  << " lang: en\n\n"
17
17
  end
18
18
  end
19
-
20
- def site
21
- @site
22
- end
23
19
 
24
20
  def languages
25
21
  posts_by_language.keys
@@ -59,29 +55,29 @@ module Octopress
59
55
  @posts_without_lang ||= site.reject(&:lang)
60
56
  end
61
57
 
62
- def site_payload(site)
63
- @site = site
64
-
58
+ def site_payload
65
59
  if defined?(Octopress::Docs) && Octopress::Docs.enabled?
66
60
  {}
67
61
  else
68
62
  return unless main_language
69
63
 
64
+ @payload ||= begin
70
65
  payload = {
71
66
  'posts' => main_language_posts,
72
67
  'posts_by_language' => posts_by_language,
73
68
  'languages' => languages
74
69
  }
75
70
 
76
- if defined? Octopress::Linkblog
77
- payload.merge!({
78
- 'linkposts' => linkposts_by_language[main_language],
79
- 'articles' => articles_by_language[main_language],
80
- 'linkposts_by_language' => linkposts_by_language,
81
- 'articles_by_language' => articles_by_language
82
- })
71
+ if defined? Octopress::Linkblog
72
+ payload.merge!({
73
+ 'linkposts' => linkposts_by_language[main_language],
74
+ 'articles' => articles_by_language[main_language],
75
+ 'linkposts_by_language' => linkposts_by_language,
76
+ 'articles_by_language' => articles_by_language
77
+ })
78
+ end
79
+ payload
83
80
  end
84
- payload
85
81
  end
86
82
  end
87
83
 
@@ -113,6 +109,14 @@ module Octopress
113
109
  end
114
110
  end
115
111
 
112
+ class SiteHookRead < Hooks::Site
113
+ priority :high
114
+ # Generate site_payload so other plugins can access
115
+ def post_read(site)
116
+ Octopress::Multilingual.site = site
117
+ end
118
+ end
119
+
116
120
  class SiteHook < Hooks::Site
117
121
  priority :low
118
122
 
@@ -126,7 +130,7 @@ module Octopress
126
130
  #
127
131
 
128
132
  {
129
- 'site' => Octopress::Multilingual.site_payload(site),
133
+ 'site' => Octopress::Multilingual.site_payload,
130
134
  }
131
135
  end
132
136
  end
@@ -170,6 +174,29 @@ module Jekyll
170
174
  :lang => lang
171
175
  })
172
176
  end
177
+
178
+ def next
179
+ language = lang || site.config['lang']
180
+ posts = Octopress::Multilingual.posts_by_language[language]
181
+ pos = posts.index {|post| post.equal?(self) }
182
+ if pos && pos < posts.length - 1
183
+ posts[pos + 1]
184
+ else
185
+ nil
186
+ end
187
+ end
188
+
189
+ def previous
190
+ language = lang || site.config['lang']
191
+ posts = Octopress::Multilingual.posts_by_language[language]
192
+ pos = posts.index {|post| post.equal?(self) }
193
+ if pos && pos > 0
194
+ posts[pos - 1]
195
+ else
196
+ nil
197
+ end
198
+ end
199
+
173
200
  end
174
201
  end
175
202
 
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Multilingual
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
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: 0.0.7
4
+ version: 0.0.8
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-01-22 00:00:00.000000000 Z
11
+ date: 2015-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octopress-hooks