octopress 3.0.0.rc.1 → 3.0.0.rc.2

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: 787005c08bc0ed8ae3f2eefcf5b38ea90b372b20
4
- data.tar.gz: 8824a64b418e2eb02a19bdef317ce9040a406628
3
+ metadata.gz: 8f74a67fb8e1f25191e18ff6f921352954a306a2
4
+ data.tar.gz: 89ec3dc9c8271c44dd0af7dff544191abc04a7d9
5
5
  SHA512:
6
- metadata.gz: ccec315c07272d23b79a08a48309e92aa8781f7dbca95f15c7985ded4c3e6794e08ff2eab110d32978856442d817c6ea235de5f1bb1d67874f390540668f0724
7
- data.tar.gz: 9fb4b0328393f5880217ff015ae256149afdf0a9f8d666929d43fbb86abde7940b1603ab26b59f5930c0fb6f1cf518ccc307713a9929d022508df051d83c4cfe
6
+ metadata.gz: e2569d763c4ea1b02acfdfcde7a7119c83ba55e00130b9c46f73b8ec439aa821ede08a50b2b8b6b6bb80f92fbbebc4b82c67c1ca361b49ccfef19faf4089231b
7
+ data.tar.gz: a87bf1eb80851ff26c73404f93b8c101eb35b3184cb9c858719b5946567c7823078b9855d7ebc5ab686294102dd5eaff22e6400f94b88a93520ac858d1fff37b
data/README.md CHANGED
@@ -7,7 +7,7 @@ blogs. Pretty sweet, huh?
7
7
 
8
8
  Add this line to your application's Gemfile:
9
9
 
10
- gem 'octopress'
10
+ gem 'octopress', '~> 3.0.0.rc.1'
11
11
 
12
12
  And then execute:
13
13
 
@@ -15,7 +15,7 @@ And then execute:
15
15
 
16
16
  Or install it yourself as:
17
17
 
18
- $ gem install octopress
18
+ $ gem install octopress --pre
19
19
 
20
20
  ## Basic Usage
21
21
 
@@ -100,6 +100,7 @@ date: YYYY-MM-DDTHH:MM:SS-00:00
100
100
  | `--template PATH` | Use a template from <path> |
101
101
  | `--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) |
102
102
  | `--slug SLUG` | Slug for the new post. |
103
+ | `--dir DIR` | Create post at _posts/DIR/. |
103
104
  | `--force` | Overwrite exsiting file. |
104
105
 
105
106
  ### New Page
@@ -144,6 +145,7 @@ This will move your draft to the `_posts` directory and rename the file with the
144
145
  |:-------------------|:------------------------------------------|
145
146
  | `--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) |
146
147
  | `--slug SLUG` | Change the slug for the new post. |
148
+ | `--dir DIR` | Create post at _posts/DIR/. |
147
149
  | `--force` | Overwrite exsiting file. |
148
150
  ```
149
151
 
@@ -33,6 +33,7 @@ module Octopress
33
33
  c.description 'Add a new post to your Jekyll site.'
34
34
  CommandHelpers.add_page_options c
35
35
  c.option 'slug', '--slug SLUG', 'Use this slug in filename instead of sluggified post title.'
36
+ c.option 'dir', '--dir DIR', 'Create post at _posts/DIR/.'
36
37
  CommandHelpers.add_common_options c
37
38
 
38
39
  c.action do |args, options|
@@ -6,11 +6,13 @@ module Octopress
6
6
  c.description 'Convert a draft to a normal published post.'
7
7
  c.option 'date', '--date DATE', 'String that is parseable by Time#parse. (default: Time.now.iso8601)'
8
8
  c.option 'force', '--force', 'Overwrite file if it already exists'
9
+ c.option 'dir', '--dir DIR', 'Create post at _posts/DIR/.'
9
10
  CommandHelpers.add_common_options c
10
11
 
11
12
  c.action do |args, options|
12
13
  abort "You must specify a path." if args.empty?
13
14
  options['path'] = args.first
15
+ options['type'] = 'post from draft'
14
16
  Draft.new(options).publish
15
17
  end
16
18
  end
@@ -2,8 +2,15 @@ module Octopress
2
2
  class Draft < Post
3
3
 
4
4
  def set_default_options
5
- super
6
- @options['type'] = 'draft'
5
+ @options['type'] ||= 'draft'
6
+ @options['layout'] = @config['post_layout']
7
+ @options['dir'] ||= ''
8
+ @options['extension'] ||= @config['post_ext']
9
+ @options['template'] ||= @config['post_template']
10
+
11
+ if @options['type'] == 'draft'
12
+ @options['date'] = convert_date @options['date']
13
+ end
7
14
  end
8
15
 
9
16
  def path
@@ -21,12 +28,15 @@ module Octopress
21
28
  # and options passed to the publish command
22
29
  #
23
30
  def publish
31
+ @options['date'] ||= read_draft_date
32
+ @options['date'] = convert_date @options['date']
24
33
 
25
34
  post_options = {
26
35
  'title' => read_draft_title,
27
36
  'slug' => publish_slug,
28
37
  'date' => @options['date'],
29
38
  'content' => read_draft_content,
39
+ 'dir' => @options['dir'],
30
40
  'type' => 'post from draft'
31
41
  }
32
42
 
@@ -64,10 +74,20 @@ module Octopress
64
74
  read.match(/title:\s+(.+)?$/)[1]
65
75
  end
66
76
 
77
+ # read_draft_date
78
+ #
79
+ def read_draft_date
80
+ read.match(/date:\s+(.+)?$/)[1]
81
+ end
82
+
67
83
  # Get content from draft post file
68
84
  #
69
85
  def read_draft_content
70
- read.sub(/date:\s+.+?$/, "date: #{@options['date']}")
86
+ if @options['date']
87
+ read.sub(/date:\s+.+?$/, "date: #{@options['date']}")
88
+ else
89
+ read
90
+ end
71
91
  end
72
92
 
73
93
  end
@@ -62,23 +62,22 @@ module Octopress
62
62
 
63
63
  def set_default_options
64
64
  @options['type'] ||= 'page'
65
- @options['layout'] = @config['page_layout']
65
+ @options['layout'] = @config['page_layout']
66
66
  @options['date'] = convert_date @options['date']
67
67
  @options['extension'] ||= @config['page_ext']
68
68
  @options['template'] ||= @config['page_template']
69
69
  end
70
70
 
71
71
  def convert_date(date)
72
- if date
73
- if @options['date'] == 'now'
74
- @options['date'] = Time.now.iso8601
75
- else
76
- begin
77
- Time.parse(date.to_s).iso8601
78
- rescue => error
79
- puts 'Could not parse date. Try formatting it like YYYY-MM-DD HH:MM'
80
- abort error.message
81
- end
72
+ date ||= 'now'
73
+ if date == 'now'
74
+ @options['date'] = Time.now.iso8601
75
+ else
76
+ begin
77
+ Time.parse(date.to_s).iso8601
78
+ rescue => error
79
+ puts 'Could not parse date. Try formatting it like YYYY-MM-DD HH:MM'
80
+ abort error.message
82
81
  end
83
82
  end
84
83
  end
@@ -4,15 +4,17 @@ module Octopress
4
4
  def set_default_options
5
5
  @options['type'] ||= 'post'
6
6
  @options['layout'] = @config['post_layout']
7
- @options['date'] ||= Time.now.iso8601
8
7
  @options['date'] = convert_date @options['date']
9
8
  @options['extension'] ||= @config['post_ext']
10
9
  @options['template'] ||= @config['post_template']
10
+ @options['dir'] ||= ''
11
11
  end
12
12
 
13
13
  def path
14
14
  name = "#{date_slug}-#{title_slug}.#{extension}"
15
- File.join(source, '_posts', name)
15
+ dir = File.join(source, '_posts', @options['dir'])
16
+ FileUtils.mkdir_p dir
17
+ File.join(dir, name)
16
18
  end
17
19
 
18
20
  # Returns a string which is url compatible.
@@ -1,3 +1,3 @@
1
1
  module Octopress
2
- VERSION = "3.0.0.rc.1"
2
+ VERSION = "3.0.0.rc.2"
3
3
  end
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Another Idea"
4
+ date: 2014-02-10T15:20:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Yet Another Idea"
4
+ date: 2014-02-13T15:20:00Z
5
+ ---
6
+
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: post
3
+ title: "Some Stuff"
4
+ date: 2014-02-11T05:10:00Z
5
+ ---
6
+
@@ -0,0 +1 @@
1
+ <div class='post'>Another Idea</div>
@@ -0,0 +1 @@
1
+ <div class='post'>Some Stuff</div>
@@ -0,0 +1 @@
1
+ <div class='post'>Yet Another Idea</div>
data/test/test.rb CHANGED
@@ -42,6 +42,14 @@ FileUtils.cd('test-site') do |dir|
42
42
  expect: '_posts/2014-03-13-awesome.markdown',
43
43
  })
44
44
 
45
+ # Add a new post in a subdirectory
46
+ #
47
+ test({
48
+ desc: 'Add a new post',
49
+ cmd: 'octopress new post "Some stuff" --dir stuff --date "2014-02-11 05:10 -0000"',
50
+ expect: '_posts/stuff/2014-02-11-some-stuff.markdown',
51
+ })
52
+
45
53
  # Add a draft
46
54
  #
47
55
  test({
@@ -50,6 +58,14 @@ FileUtils.cd('test-site') do |dir|
50
58
  expect: '_drafts/stupid-idea.markdown',
51
59
  })
52
60
 
61
+ # Add another draft
62
+ #
63
+ test({
64
+ desc: 'Add another draft',
65
+ cmd: 'octopress new draft "Another idea" --date "2014-02-10 15:20 -0000"',
66
+ expect: '_drafts/another-idea.markdown',
67
+ })
68
+
53
69
  # Add a draft with a slug
54
70
  #
55
71
  test({
@@ -58,6 +74,22 @@ FileUtils.cd('test-site') do |dir|
58
74
  expect: '_drafts/idea.markdown',
59
75
  })
60
76
 
77
+ # Add yet another draft
78
+ #
79
+ test({
80
+ desc: 'Add yet another draft',
81
+ cmd: 'octopress new draft "yet another idea" --date "2014-02-13 15:20 -0000"',
82
+ expect: '_drafts/yet-another-idea.markdown',
83
+ })
84
+
85
+ # Publish a draft
86
+ #
87
+ test({
88
+ desc: 'Publish a draft',
89
+ cmd: 'octopress publish _drafts/another-idea.markdown',
90
+ expect: '_posts/2014-02-10-another-idea.markdown',
91
+ })
92
+
61
93
  # Publish a draft with a date
62
94
  #
63
95
  test({
@@ -66,6 +98,14 @@ FileUtils.cd('test-site') do |dir|
66
98
  expect: '_posts/2014-03-11-idea.markdown',
67
99
  })
68
100
 
101
+ # Publish a draft in a dir
102
+ #
103
+ test({
104
+ desc: 'Publish a draft in a dir',
105
+ cmd: 'octopress publish _drafts/yet-another-idea.markdown --dir ideas',
106
+ expect: '_posts/ideas/2014-02-13-yet-another-idea.markdown',
107
+ })
108
+
69
109
  # Add a page
70
110
  #
71
111
  test({
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.1
4
+ version: 3.0.0.rc.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
@@ -123,9 +123,15 @@ files:
123
123
  - test/expected/_layouts/page.html
124
124
  - test/expected/_layouts/post.html
125
125
  - test/expected/_octopress.yml
126
+ - test/expected/_posts/2014-02-10-another-idea.markdown
126
127
  - test/expected/_posts/2014-03-11-idea.markdown
127
128
  - test/expected/_posts/2014-03-12-awesome-stuff.markdown
128
129
  - test/expected/_posts/2014-03-13-awesome.markdown
130
+ - test/expected/_posts/ideas/2014-02-13-yet-another-idea.markdown
131
+ - test/expected/_posts/stuff/2014-02-11-some-stuff.markdown
132
+ - test/expected/_site/2014/02/10/another-idea.html
133
+ - test/expected/_site/2014/02/11/some-stuff.html
134
+ - test/expected/_site/2014/02/13/yet-another-idea.html
129
135
  - test/expected/_site/2014/03/11/idea.html
130
136
  - test/expected/_site/2014/03/12/awesome-stuff.html
131
137
  - test/expected/_site/2014/03/13/awesome.html
@@ -171,9 +177,15 @@ test_files:
171
177
  - test/expected/_layouts/page.html
172
178
  - test/expected/_layouts/post.html
173
179
  - test/expected/_octopress.yml
180
+ - test/expected/_posts/2014-02-10-another-idea.markdown
174
181
  - test/expected/_posts/2014-03-11-idea.markdown
175
182
  - test/expected/_posts/2014-03-12-awesome-stuff.markdown
176
183
  - test/expected/_posts/2014-03-13-awesome.markdown
184
+ - test/expected/_posts/ideas/2014-02-13-yet-another-idea.markdown
185
+ - test/expected/_posts/stuff/2014-02-11-some-stuff.markdown
186
+ - test/expected/_site/2014/02/10/another-idea.html
187
+ - test/expected/_site/2014/02/11/some-stuff.html
188
+ - test/expected/_site/2014/02/13/yet-another-idea.html
177
189
  - test/expected/_site/2014/03/11/idea.html
178
190
  - test/expected/_site/2014/03/12/awesome-stuff.html
179
191
  - test/expected/_site/2014/03/13/awesome.html