octopress 3.0.0.rc.28 → 3.0.0.rc.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +3 -0
- data/lib/octopress.rb +1 -1
- data/lib/octopress/commands/helpers.rb +2 -1
- data/lib/octopress/draft.rb +3 -13
- data/lib/octopress/page.rb +25 -27
- data/lib/octopress/post.rb +10 -17
- data/lib/octopress/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: 6a1ddc17529ba0de8cc44c2028b351b8c3786b70
|
4
|
+
data.tar.gz: de86073fe8c3e25de3d6ba23772c028e76031bd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cfa31c15e60fd0620d9c4ec45d20e9ce36b88c68865a927d1aa4ff0f47d29863454fbaa8f8f8984d77e0c806a1c4e75df606694c79d86b3ee014034f46842b9
|
7
|
+
data.tar.gz: bc4e05a79d74ee9a18782b4d4e708d294d23f0529f6f068a995c45bf240dec817c9df20f89877f7b57bc54c4a8ccd325694011738fea89be9609e3fa76058524
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Octopress Changelog
|
2
2
|
|
3
|
-
### 3.0.0
|
3
|
+
### 3.0.0 RC29 (2015-01-17)
|
4
|
+
|
5
|
+
- Added `--lang` option for multi-language support.
|
6
|
+
|
7
|
+
### 3.0.0 RC28 (2015-01-15)
|
4
8
|
|
5
9
|
- Fix: `--template` option accepts a path, allowing shell auto-completion.
|
6
10
|
- Added short option flags for most commands.
|
data/README.md
CHANGED
@@ -74,6 +74,7 @@ date: YYYY-MM-DDTHH:MM:SS-00:00
|
|
74
74
|
|:---------------------|:----------------------------------------|
|
75
75
|
| `--template PATH` | Use a template from <path> |
|
76
76
|
| `--date DATE` | The date for the post. Should be parseable by [Time#parse](http://ruby-doc.org/stdlib-2.1.0/libdoc/time/rdoc/Time.html#method-i-parse) |
|
77
|
+
| `--lang LANGUAGE` | Set post language (e.g. en, it) for multi-language sites. |
|
77
78
|
| `--slug SLUG` | Slug for the new post. |
|
78
79
|
| `--dir DIR` | Create post at _posts/DIR/. |
|
79
80
|
| `--force` | Overwrite existing file. |
|
@@ -105,6 +106,7 @@ After the page is created, Octopress will tell you how to configure this new col
|
|
105
106
|
| `--template PATH` | Use a template from <path> |
|
106
107
|
| `--title TITLE` | The title of the new page |
|
107
108
|
| `--date DATE` | The date for the page. Should be parseable by [Time#parse](http://ruby-doc.org/stdlib-2.1.0/libdoc/time/rdoc/Time.html#method-i-parse) |
|
109
|
+
| `--lang LANGUAGE` | Set page language (e.g. en, it) for multi-language sites. |
|
108
110
|
| `--force` | Overwrite existing file. |
|
109
111
|
|
110
112
|
Note: The default page template doesn't expect a date. If you want to add dates
|
@@ -124,6 +126,7 @@ $ octopress new draft "My Title"
|
|
124
126
|
|:-------------------|:------------------------------------------|
|
125
127
|
| `--template PATH` | Use a template from <path> |
|
126
128
|
| `--date DATE` | The date for the draft. Should be parseable by [Time#parse](http://ruby-doc.org/stdlib-2.1.0/libdoc/time/rdoc/Time.html#method-i-parse) (defaults to Time.now) |
|
129
|
+
| `--lang LANGUAGE` | Set draft language (e.g. en, it) for multi-language sites. |
|
127
130
|
| `--slug SLUG` | The slug for the new post. |
|
128
131
|
| `--force` | Overwrite existing file. |
|
129
132
|
|
data/lib/octopress.rb
CHANGED
@@ -95,7 +95,7 @@ Octopress::Docs.add({
|
|
95
95
|
version: Octopress::VERSION,
|
96
96
|
description: "A framework for writing Jekyll sites ",
|
97
97
|
base_url: "octopress",
|
98
|
-
path: File.expand_path(File.join(File.dirname(__FILE__), "
|
98
|
+
path: File.expand_path(File.join(File.dirname(__FILE__), "..")),
|
99
99
|
source_url: "https://github.com/octopress/octopress",
|
100
100
|
website: "http://octopress.org",
|
101
101
|
})
|
@@ -3,8 +3,9 @@ module Octopress
|
|
3
3
|
extend self
|
4
4
|
|
5
5
|
def add_page_options(c)
|
6
|
-
c.option 'template', '-tm', '--template PATH', "New #{c.name.to_s} from a template."
|
7
6
|
c.option 'date', '-d', '--date DATE', "Use 'now' or a String that is parseable by Time#parse."
|
7
|
+
c.option 'template', '-tm', '--template PATH', "New #{c.name.to_s} from a template."
|
8
|
+
c.option 'lang', '-l', '--lang LANGUAGE', "Set a #{c.name.to_s} language (e.g. en, it) for multi-language sites."
|
8
9
|
c.option 'force', '-f', '--force', 'Overwrite file if it already exists'
|
9
10
|
end
|
10
11
|
|
data/lib/octopress/draft.rb
CHANGED
@@ -29,12 +29,13 @@ module Octopress
|
|
29
29
|
# and options passed to the publish command
|
30
30
|
#
|
31
31
|
def publish
|
32
|
-
@options['date'] ||=
|
33
|
-
@options['title'] =
|
32
|
+
@options['date'] ||= read_post_yaml('date') || Time.now.iso8601
|
33
|
+
@options['title'] = read_post_yaml('title')
|
34
34
|
|
35
35
|
post_options = {
|
36
36
|
'title' => @options['title'],
|
37
37
|
'date' => @options['date'],
|
38
|
+
'lang' => read_post_yaml('lang'),
|
38
39
|
'slug' => title_slug,
|
39
40
|
'content' => read_post_content,
|
40
41
|
'dir' => @options['dir'],
|
@@ -54,16 +55,5 @@ module Octopress
|
|
54
55
|
def default_template
|
55
56
|
'draft'
|
56
57
|
end
|
57
|
-
|
58
|
-
# Draft template defaults
|
59
|
-
#
|
60
|
-
def default_content
|
61
|
-
|
62
|
-
if @options['date']
|
63
|
-
front_matter %w{layout title date}
|
64
|
-
else
|
65
|
-
front_matter %w{layout title}
|
66
|
-
end
|
67
|
-
end
|
68
58
|
end
|
69
59
|
end
|
data/lib/octopress/page.rb
CHANGED
@@ -16,13 +16,16 @@ module Octopress
|
|
16
16
|
site.plugin_manager.conscientious_require
|
17
17
|
@config = DEFAULT_OPTIONS.merge(site.config)
|
18
18
|
@options = options
|
19
|
+
@options['lang'].downcase! if @options['lang']
|
19
20
|
set_default_options
|
20
21
|
|
22
|
+
@front_matter = %w{layout title date lang}
|
23
|
+
|
21
24
|
# Ensure title
|
22
25
|
#
|
23
26
|
@options['title'] ||= ''
|
24
27
|
|
25
|
-
# Ensure a quoted title
|
28
|
+
# Ensure a quoted title to avoid YAML parsing issues.
|
26
29
|
#
|
27
30
|
@options['title'] = "\"#{@options['title']}\""
|
28
31
|
|
@@ -135,10 +138,10 @@ module Octopress
|
|
135
138
|
elsif @options['template']
|
136
139
|
abort "No #{@options['type']} template found at #{file}"
|
137
140
|
else
|
138
|
-
parse_template
|
141
|
+
parse_template default_front_matter
|
139
142
|
end
|
140
143
|
else
|
141
|
-
parse_template
|
144
|
+
parse_template default_front_matter
|
142
145
|
end
|
143
146
|
end
|
144
147
|
|
@@ -149,13 +152,18 @@ module Octopress
|
|
149
152
|
# Render Liquid vars in YAML front-matter.
|
150
153
|
def parse_template(input)
|
151
154
|
|
152
|
-
vars = @options.dup
|
153
|
-
|
154
155
|
if @config['titlecase']
|
155
|
-
|
156
|
+
@options['title'].titlecase!
|
156
157
|
end
|
157
158
|
|
159
|
+
vars = @options.dup
|
160
|
+
|
161
|
+
# Allow templates to use slug
|
162
|
+
#
|
158
163
|
vars['slug'] = title_slug
|
164
|
+
|
165
|
+
# Allow templates to use date fragments
|
166
|
+
#
|
159
167
|
date = Time.parse(vars['date'] || Time.now.iso8601)
|
160
168
|
vars['year'] = date.year
|
161
169
|
vars['month'] = date.strftime('%m')
|
@@ -170,9 +178,7 @@ module Octopress
|
|
170
178
|
parsed = if input =~ /\A-{3}\s+(.+?)\s+-{3}(.+)?/m
|
171
179
|
input = $1
|
172
180
|
content = $2
|
173
|
-
|
174
|
-
input += "\ndate: #{vars['date']}"
|
175
|
-
end
|
181
|
+
input << default_front_matter(input)
|
176
182
|
else
|
177
183
|
content = ''
|
178
184
|
end
|
@@ -181,6 +187,16 @@ module Octopress
|
|
181
187
|
"---\n#{template.render(vars).strip}\n---\n#{content}"
|
182
188
|
end
|
183
189
|
|
190
|
+
# Ensures front-matter is set with optional arguments
|
191
|
+
#
|
192
|
+
def default_front_matter(template='')
|
193
|
+
@front_matter.dup.map do |k|
|
194
|
+
if @options[k] && !(template =~ /#{k}:/)
|
195
|
+
"\n#{k}: #{@options[k]}"
|
196
|
+
end
|
197
|
+
end.join('')
|
198
|
+
end
|
199
|
+
|
184
200
|
def date_slug
|
185
201
|
@options['date'].split('T')[0]
|
186
202
|
end
|
@@ -197,23 +213,5 @@ module Octopress
|
|
197
213
|
value.gsub!(' ', '-')
|
198
214
|
value
|
199
215
|
end
|
200
|
-
|
201
|
-
def front_matter(vars)
|
202
|
-
fm = []
|
203
|
-
vars.each do |v|
|
204
|
-
fm << "#{v}: {{ #{v} }}" if @options[v]
|
205
|
-
end
|
206
|
-
fm.join("\n")
|
207
|
-
end
|
208
|
-
|
209
|
-
# Page template defaults
|
210
|
-
#
|
211
|
-
def default_content
|
212
|
-
if @options['date']
|
213
|
-
front_matter %w{layout title date}
|
214
|
-
else
|
215
|
-
front_matter %w{layout title}
|
216
|
-
end
|
217
|
-
end
|
218
216
|
end
|
219
217
|
end
|
data/lib/octopress/post.rb
CHANGED
@@ -13,6 +13,12 @@ module Octopress
|
|
13
13
|
@options['extension'] ||= @config['post_ext']
|
14
14
|
@options['template'] ||= @config['post_template']
|
15
15
|
@options['dir'] ||= ''
|
16
|
+
|
17
|
+
# Language dir should always be added if language is set
|
18
|
+
#
|
19
|
+
if @options['lang']
|
20
|
+
@options['dir'] = File.join(@options['lang'], @options['dir'])
|
21
|
+
end
|
16
22
|
end
|
17
23
|
|
18
24
|
def path
|
@@ -26,15 +32,9 @@ module Octopress
|
|
26
32
|
'post'
|
27
33
|
end
|
28
34
|
|
29
|
-
# Post template defaults
|
30
|
-
#
|
31
|
-
def default_content
|
32
|
-
front_matter %w{layout title date}
|
33
|
-
end
|
34
|
-
|
35
35
|
def unpublish
|
36
|
-
@options['date'] =
|
37
|
-
@options['title'] =
|
36
|
+
@options['date'] = read_post_yaml('date')
|
37
|
+
@options['title'] = read_post_yaml('title')
|
38
38
|
|
39
39
|
post_options = {
|
40
40
|
'title' => @options['title'],
|
@@ -63,15 +63,8 @@ module Octopress
|
|
63
63
|
|
64
64
|
# Get title from post file
|
65
65
|
#
|
66
|
-
def
|
67
|
-
match = read.match(
|
68
|
-
match[1] if match
|
69
|
-
end
|
70
|
-
|
71
|
-
# Read date from post file
|
72
|
-
#
|
73
|
-
def read_post_date
|
74
|
-
match = read.match(/date:\s+(\d.+)$/)
|
66
|
+
def read_post_yaml(key)
|
67
|
+
match = read.match(/#{key}:\s*(.+)?$/)
|
75
68
|
match[1] if match
|
76
69
|
end
|
77
70
|
|
data/lib/octopress/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.rc.
|
4
|
+
version: 3.0.0.rc.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mercenary
|