octopress-multilingual 0.0.3 → 0.0.4

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: 53be2ced0c8a63eb3b700693e9c7970d3f8d9fee
4
- data.tar.gz: 63c5a43ee90647ca20155753f6cfbe540a4c48aa
3
+ metadata.gz: ce87f2f55eaed0f5b3a9fe806e1dab7d4a07c870
4
+ data.tar.gz: 6387312bed51e706a7d9fd1fce1bdf25438874bb
5
5
  SHA512:
6
- metadata.gz: 5559796598c95835c13af44f6ecc402926572629f3ba6499f5511fed54e2063eb6d932dbfe125715647c6ef96057c23e90a1801879ac82a4ce0097e16d659a2f
7
- data.tar.gz: fdd40263d7ab8776f082297d817e2a7936be4e7137a3af86f82f5557c708d3972cf7f8b5fbc28f802a2e7198bf051fbc6780aade8585fb02efd5ae34df7049d1
6
+ metadata.gz: 7c026837759184448beff5307f3d3b69bca69ea6487d38b5d567267de55794aa2aa454e39e308b415e3341cdfa4eaccb1e1149fd5f960920ff73a029a479336c
7
+ data.tar.gz: 33eea004f47c2a1012921e4fd3ed002f5412344cbadee9b7173fa651916760ad0caa143e54d1582451c764dcec9308698c2faeeee8f58fc4bc2d4e7da622d794
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ### 0.0.2 (2015-01-18)
3
+ ### 0.0.4 (2015-01-18)
4
+
5
+ - Added support for scoping octopress-linkblog `articles` and `linkposts` loops.
6
+
7
+ ### 0.0.3 (2015-01-18)
4
8
 
5
9
  - Renamed tag to `{% set_lang %}`.
6
10
 
data/README.md CHANGED
@@ -71,6 +71,8 @@ If you are using Octopress, you can easily create a new post with the language a
71
71
  $ octopress new post "Some title" --lang en
72
72
  ```
73
73
 
74
+ This command will set the post language (in the YAML front-matter) and add it to the `_posts/en` directory.
75
+
74
76
  ### Cross-posting languages
75
77
 
76
78
  Occasionally you may wish to write a post in a single language and have it show up in other languages indexes and feeds. This can be done in your post's YAML front-matter:
@@ -132,6 +134,9 @@ Using the `set_lang` liquid block, you can temporarily switch languages while re
132
134
  {{ site.posts }} # => English posts
133
135
  ```
134
136
 
137
+ If you have the [octopress-linkblog](https://github.com/octopress/linkblog) plugin installed, this will also change scope for your
138
+ `site.articles` and `site.linkposts` loops.
139
+
135
140
  ## Post Indexes and RSS Feeds
136
141
 
137
142
  To add multilingual post indexes you can use the `set_lang` tag like this:
@@ -151,7 +156,7 @@ example, `_includes/post-index.html`. It might look this:
151
156
  ```
152
157
  {% set_lang page.lang %}
153
158
  {% for post in site.posts %}...{% endfor %}
154
- {% endpost_lang %}
159
+ {% endset_lang %}
155
160
  ```
156
161
 
157
162
  Set the page language to German and include the same partial.
@@ -61,16 +61,54 @@ module Octopress
61
61
  def site_payload(site)
62
62
  @site = site
63
63
 
64
- if main_language
65
- {
66
- 'posts' => main_language_posts,
67
- 'posts_by_language' => posts_by_language,
68
- 'languages' => languages,
69
- 'lang' => main_language
70
- }
64
+ return unless main_language
65
+
66
+ payload = {
67
+ 'posts' => main_language_posts,
68
+ 'posts_by_language' => posts_by_language,
69
+ 'languages' => languages,
70
+ 'lang' => main_language
71
+ }
72
+
73
+ if defined? Octopress::Linkblog
74
+ payload.merge!({
75
+ 'linkposts' => linkposts_by_language[main_language],
76
+ 'articles' => articles_by_language[main_language],
77
+ 'linkposts_by_language' => linkposts_by_language,
78
+ 'articles_by_language' => articles_by_language
79
+ })
71
80
  end
81
+
82
+ payload
72
83
  end
73
84
 
85
+ def articles_by_language
86
+ @articles_by_language ||= begin
87
+ articles = {}
88
+
89
+ languages.each do |lang|
90
+ articles[lang] = posts_by_language[lang].reject do |p|
91
+ p.data['linkpost']
92
+ end
93
+ end
94
+
95
+ articles
96
+ end
97
+ end
98
+
99
+ def linkposts_by_language
100
+ @linkposts_by_language ||= begin
101
+ linkposts = {}
102
+
103
+ languages.each do |lang|
104
+ linkposts[lang] = posts_by_language[lang].select do |p|
105
+ p.data['linkpost']
106
+ end
107
+ end
108
+
109
+ linkposts
110
+ end
111
+ end
74
112
 
75
113
  class SiteHook < Hooks::Site
76
114
  priority :low
@@ -36,7 +36,13 @@ module Octopress
36
36
  end
37
37
 
38
38
  def set_post_lang(lang)
39
- @context.environments.first['site']['posts'] = @lang_posts[lang]
39
+ site = @context.environments.first['site']
40
+ site['posts'] = @lang_posts[lang]
41
+
42
+ if defined? Octopress::Linkblog
43
+ site['linkposts'] = site['linkposts_by_language'][lang]
44
+ site['articles'] = site['articles_by_language'][lang]
45
+ end
40
46
  end
41
47
 
42
48
  def set_current_lang(lang)
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Multilingual
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
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.3
4
+ version: 0.0.4
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-19 00:00:00.000000000 Z
11
+ date: 2015-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octopress-hooks
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: clash
42
+ name: octopress-linkblog
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,47 +53,47 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: bundler
56
+ name: clash
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.7'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1.7'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rake
70
+ name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '1.7'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '1.7'
83
83
  - !ruby/object:Gem::Dependency
84
- name: pry-byebug
84
+ name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '10.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '10.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: octopress-debugger
99
99
  requirement: !ruby/object:Gem::Requirement