octopress 3.0.0.rc.25 → 3.0.0.rc.26

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: fdfdb7113136116ba0904db0b22ef2886137fae3
4
- data.tar.gz: ae1f9fa89708f4960bbe79ce38553551654e0427
3
+ metadata.gz: 727ee7d51be4119ea57bded0308bd58cb049f6d3
4
+ data.tar.gz: 07414b0416d58b6cbcc92d2672433e6b45bb7379
5
5
  SHA512:
6
- metadata.gz: 680a6330b39ad2101d428990788b044e8feec7b64239b7f7dca7ec563e9d47041ddb28a0102c523f6554ca4613eed99cf58345eb2a43d13075ccaf3c17e4fa26
7
- data.tar.gz: b14dafba9c5b8d1116e25d9173817c92951bde34f48cd374d07fdb01ad6f7dbbbe5cfdfb78d44c27a7031f2c28e58817335a20b3684417c9e0f59da9730166ad
6
+ metadata.gz: 637af731d6d9020efc0564eea32ea76f7b77c4f20b3652c611bf63d09442cdc297d61a03f92b1a9ba2c9e127a5e1894e85f895b5f8f878a0d1223a19ba5c0438
7
+ data.tar.gz: d6ebdda6680265da6d21133aa732bc400c5478c8ab56b18e0cff2d1614a2fcdb122818336f1d7b2e4666b69fc8e1fb7c5e574c47bf0f5a4883a5c518f5e15a91
data/CHANGELOG.md CHANGED
@@ -1,12 +1,16 @@
1
1
  # Octopress Changelog
2
2
 
3
+ ### 3.0.0 RC26 - 2015-01-02
4
+
5
+ - Added `unpublish` command for converting posts into drafts
6
+
3
7
  ### 3.0.0 RC25 - 2015-01-02
4
8
 
5
9
  - Fixed missing scaffolding.
6
10
 
7
11
  ### 3.0.0 RC24 - 2015-01-02
8
12
 
9
- - Absorbed Octopress Docs features
13
+ - Absorbed Octopress Docs features.
10
14
 
11
15
  ### 3.0.0 RC23 - 2014-12-19
12
16
 
data/README.md CHANGED
@@ -31,7 +31,8 @@ Here are the commands for Octopress.
31
31
  | `octopress new page <PATH>` | Add a new page to your site |
32
32
  | `octopress new draft <TITLE>` | Add a new draft post to your site |
33
33
  | `octopress publish <PATH>` | Publish a draft from _drafts to _posts |
34
- | `octopress isolate [search]` | Isolate one or more posts for a faster build |
34
+ | `octopress unpublish <POST>` | Convert a post into a draft |
35
+ | `octopress isolate <POST>` | Isolate one or more posts for a faster build |
35
36
  | `octopress integrate` | Restores all posts, reverting isolation. |
36
37
 
37
38
  Run `octopress [command] --help` to learn more about any command and see its options.
data/assets/docs/index.md CHANGED
@@ -8,14 +8,17 @@ title: Using Octopress
8
8
 
9
9
  Here are the subcommands for Octopress.
10
10
 
11
- - `init <PATH>` Adds Octopress scaffolding to your site.
12
- - `new <PATH>` Like `jekyll new` + `octopress init`
13
- - `new post <TITLE>` Add a new post to your site
14
- - `new page <PATH>` Add a new page to your site
15
- - `new draft <TITLE>` Add a new draft post to your site
16
- - `publish <PATH>` Publish a draft from _drafts to _posts
17
- - `isolate [search]` Isolate one or more posts for a faster build
18
- - `integrate` Restores all posts, reverting isolation.
11
+ ```
12
+ init <PATH> # Adds Octopress scaffolding to your site
13
+ new <PATH> # Like `jekyll new` + `octopress init`
14
+ new post <TITLE> # Add a new post to your site
15
+ new page <PATH> # Add a new page to your site
16
+ new draft <TITLE> # Add a new draft post to your site
17
+ publish <POST> # Publish a draft from _drafts to _posts
18
+ unpublish <POST> # Search for a post and convert it into a draft
19
+ isolate [POST] # Stash all posts but the one you're workign on for a faster build
20
+ integrate # Restores all posts, doing the opposite of the isolate command
21
+ ```
19
22
 
20
23
  Run `octopress --help` to list sub commands and `octopress <subcommand> --help` to learn more about any subcommand and see its options.
21
24
 
@@ -96,12 +99,12 @@ you will have the `--date` option to add a date to a page.
96
99
 
97
100
  ### New Draft
98
101
 
102
+ This will create a new post in your `_drafts` directory.
103
+
99
104
  ```sh
100
105
  $ octopress new draft "My Title"
101
106
  ```
102
107
 
103
- This will create a new post in your `_drafts` directory.
104
-
105
108
  | Option | Description |
106
109
  |:-------------------|:------------------------------------------|
107
110
  | `--template PATH` | Use a template from <path> |
@@ -109,13 +112,17 @@ This will create a new post in your `_drafts` directory.
109
112
  | `--slug SLUG` | The slug for the new post. |
110
113
  | `--force` | Overwrite exsiting file. |
111
114
 
112
- ### Publish draft
115
+ ### Publish a draft
116
+
117
+ Use the `publish` command to publish a draft to the `_posts` folder. This will also rename the file with the proper date format.
113
118
 
114
119
  ```sh
115
- $ octopress publish _drafts/some-post.md
120
+ $ octopress publish _drafts/some-cool-post.md
121
+ $ octopress publish cool
116
122
  ```
117
-
118
- This will move your draft to the `_posts` directory and rename the file with the proper date.
123
+ In the first example, a draft is published using the path. The publish command can also search for a post by filename. The second command
124
+ would work the same as the first. If other drafts match your search, you will be prompted to select them from a menu. This is often much
125
+ faster than typing out the full path.
119
126
 
120
127
  | Option | Description |
121
128
  |:-------------------|:------------------------------------------|
@@ -126,6 +133,18 @@ This will move your draft to the `_posts` directory and rename the file with the
126
133
 
127
134
  When publishing a draft, the new post will use the draft's date. Pass the option `--date now` to the publish command to set the new post date from your system clock. As usual, you can pass any compatible date string as well.
128
135
 
136
+ ### Unpublish a post
137
+
138
+ Use the `unpublish` command to move a post to the `_drafts` directory, renaming the file according to the drafts convention.
139
+
140
+ ```sh
141
+ $ octopress unpublish _posts/2015-01-10-some-post.md
142
+ $ octopress unpublish some post
143
+ ```
144
+
145
+ Just like the publish command, you can either pass a path or a search string to match the file name. If more than one match is found, you
146
+ will be prompted to select from a menu of posts.
147
+
129
148
  ### Templates for Posts and pages
130
149
 
131
150
  Octopress post and page templates look like this.
@@ -163,19 +182,17 @@ File name extensions are unnecessary since they're just plain text anyway.
163
182
 
164
183
  ## Isolate
165
184
 
166
- If your site is taking a while to build, but you want to preview a post quickly, you can isolate that post temporarily with the isolate command. Here's the syntax:
185
+ The `isolate` command will allow you to stash posts in `_posts/_exile` where they will be ignored by Jekyll during the build process.
186
+ Run `octopress integrate` to restore all exiled posts. This can be helpful if you have a very large site and you want to quickly preview a build
187
+ for a single post or page.
167
188
 
189
+ ```sh
190
+ $ octopress isolate # Move all posts
191
+ $ octopress isolate _posts/2014-10-11-kittens.md # Move post at path
192
+ $ octopress isolate kittens # Move post matching search
168
193
  ```
169
- octopress isolate [SEARCH] [options]
170
- ```
171
-
172
- This will copy all other posts into `_posts/_exile` where they will be ignored by Jekyll during the build process. Here are some examples:
173
-
174
- - `octopress isolate` isolates the most recently dated post.
175
- - `octopress isolate cats` isolates all posts with the word 'cats' in the filename.
176
- - `octopress isolate --path _posts/2014-10-11-kittens.md` isolates the post at the given path.
177
194
 
178
- To reintegrate all exiled posts, run `octopress integrate` which will restore all posts from `_posts/_exile` to `_posts`.
195
+ In the third example, if multiple posts match the search a prompt will ask you to select a post from a menu.
179
196
 
180
197
  ## Configuration
181
198
 
@@ -197,7 +214,7 @@ titlecase: true
197
214
 
198
215
  ## Contributing
199
216
 
200
- 1. Fork it
217
+ 1. Fork it ( https://github.com/octopress/octopress/fork )
201
218
  2. Create your feature branch (`git checkout -b my-new-feature`)
202
219
  3. Commit your changes (`git commit -am 'Add some feature'`)
203
220
  4. Push to the branch (`git push origin my-new-feature`)
data/lib/octopress.rb CHANGED
@@ -4,10 +4,12 @@ require 'titlecase'
4
4
  module Octopress
5
5
  require 'octopress/command'
6
6
  require 'octopress/version'
7
+ require 'octopress/utils'
7
8
  require 'octopress/commands/new'
8
9
  require 'octopress/commands/docs'
9
10
  require 'octopress/commands/init'
10
11
  require 'octopress/commands/publish'
12
+ require 'octopress/commands/unpublish'
11
13
  require 'octopress/commands/isolate'
12
14
  require 'octopress/isolate'
13
15
  require 'octopress/docs'
@@ -1,13 +1,90 @@
1
1
  module Octopress
2
2
  module CommandHelpers
3
- def self.add_page_options(c)
3
+ extend self
4
+
5
+ def add_page_options(c)
4
6
  c.option 'template', '--template PATH', "New #{c.name.to_s} from a template."
5
7
  c.option 'date', '--date DATE', "Use 'now' or a String that is parseable by Time#parse."
6
8
  c.option 'force', '--force', 'Overwrite file if it already exists'
7
9
  end
8
10
 
9
- def self.add_common_options(c)
10
- c.option 'config', '--config <CONFIG_FILE>[,CONFIG_FILE2,...]', Array, 'Custom Jekyll configuration file'
11
+ def add_common_options(c)
12
+ c.option 'config', '--config <CONFIG_FILE>[,CONFIG_FILE2,...]', Array, 'Custom Jekyll configuration file'
13
+ end
14
+
15
+ def select_posts(search, action)
16
+ posts = (action == 'publish' ? find_drafts : find_posts)
17
+ posts = search_posts(search, posts)
18
+
19
+ if posts.size > 1
20
+ post = prompt_for_selection(posts, search, action)
21
+
22
+ if post.is_a? Integer
23
+ posts[post - 1]
24
+ else
25
+ abort "#{action.capitalize} canceled: You didn't enter number."
26
+ end
27
+ else
28
+ posts.first
29
+ end
11
30
  end
31
+
32
+ def find_drafts
33
+ @drafts ||= begin
34
+ dir = File.join(Octopress.site.source, '_drafts')
35
+ Find.find(dir).to_a.reject do |f|
36
+ File.directory?(f)
37
+ end
38
+ end
39
+ end
40
+
41
+ def find_all_posts
42
+ @posts ||= begin
43
+ dir = File.join(Octopress.site.source, '_posts')
44
+ Find.find(dir).to_a.reject do |f|
45
+ File.directory?(f)
46
+ end
47
+ end
48
+ end
49
+
50
+ def find_posts
51
+ find_all_posts.reject { |f| f =~ /_exile\// }
52
+ end
53
+
54
+ def find_exiled_posts
55
+ find_all_posts.select { |f| f =~ /_exile\// }
56
+ end
57
+
58
+ def search_posts(search, posts)
59
+ posts = posts.select do |p|
60
+ p =~ /#{search.gsub(/\s/, '-')}/i
61
+ end
62
+ if posts.empty?
63
+ abort (STDOUT.tty? ? "No posts found matching: #{search}".red : '')
64
+ else
65
+ posts
66
+ end
67
+ end
68
+
69
+ def prompt_for_selection(posts, search, action)
70
+ abort if !STDOUT.tty?
71
+
72
+ puts "Found #{posts.size} posts matching: '#{search}'"
73
+ posts.each_with_index do |p, i|
74
+ post = p.sub(/#{Octopress.site.source}\/_(posts|drafts)\//, '')
75
+ puts " #{i+1}) #{post}"
76
+ end
77
+
78
+ print "Which do you want to #{action}? (enter a number): "
79
+ $stdout.flush
80
+ post = $stdin.gets.strip.to_i
81
+
82
+ # Give a newline for further output
83
+ puts ''
84
+
85
+ # Handle invalid input (because "oops".to_i == 0)
86
+ (post == 0 ? nil : post)
87
+ end
88
+
12
89
  end
13
90
  end
@@ -3,16 +3,18 @@ module Octopress
3
3
  class Isolate < Command
4
4
  def self.init_with_program(p)
5
5
  p.command(:isolate) do |c|
6
- c.syntax 'isolate [search] [options]'
7
- c.description "Move posts to _posts/_exile if they do not match the search text or move the most recent post if search text is omitted."
8
- c.option 'path', '--path [STRING]', 'Isolate a post at the specified path.'
9
- c.option 'config', '--config <CONFIG_FILE>[,CONFIG_FILE2,...]', Array, 'Custom Jekyll configuration file'
6
+ c.syntax 'isolate <POST> [options]'
7
+ c.description "Move all posts not matching selected psot to _posts/_exile. Command accepts path to post or search string."
8
+ CommandHelpers.add_common_options c
10
9
 
11
10
  c.action do |args, options|
12
- if !args.empty?
13
- options['search'] = args.first
11
+ options['path'] = args.first
12
+
13
+ if options['path'] && !File.exist?(options['path'])
14
+ options['path'] = CommandHelpers.select_posts(options['path'], 'isolate')
14
15
  end
15
- Octopress::Isolate.new(options).process
16
+
17
+ isolate_post(options)
16
18
  end
17
19
  end
18
20
 
@@ -22,10 +24,18 @@ module Octopress
22
24
  c.option 'config', '--config <CONFIG_FILE>[,CONFIG_FILE2,...]', Array, 'Custom Jekyll configuration file'
23
25
 
24
26
  c.action do |args, options|
25
- Octopress::Isolate.new(options).revert
27
+ integrate_posts(options)
26
28
  end
27
29
  end
28
30
  end
31
+
32
+ def self.isolate_post(options)
33
+ Octopress::Isolate.new(options).isolate
34
+ end
35
+
36
+ def self.integrate_posts(options)
37
+ Octopress::Isolate.new(options).integrate
38
+ end
29
39
  end
30
40
  end
31
41
  end
@@ -2,7 +2,7 @@ module Octopress
2
2
  class Publish < Command
3
3
  def self.init_with_program(p)
4
4
  p.command(:publish) do |c|
5
- c.syntax 'publish <PATH> [options]'
5
+ c.syntax 'publish <DRAFT> [options]'
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'
@@ -10,13 +10,27 @@ module Octopress
10
10
  CommandHelpers.add_common_options c
11
11
 
12
12
  c.action do |args, options|
13
- abort "You must specify a path." if args.empty?
13
+ abort "You didn't specify a post." if args.empty?
14
14
  options['path'] = args.first
15
15
  options['type'] = 'post from draft'
16
- Draft.new(Octopress.site(options), options).publish
16
+
17
+ if !options['path']
18
+ abort "Publish failed: Please provide a path or a search string to select your post."
19
+ end
20
+
21
+ if File.exist?(options['path'])
22
+ publish_post(options)
23
+ else
24
+ options['path'] = CommandHelpers.select_posts(options['path'], 'publish')
25
+ publish_post(options)
26
+ end
17
27
  end
18
28
  end
19
29
  end
30
+
31
+ def self.publish_post(options)
32
+ Draft.new(Octopress.site(options), options).publish
33
+ end
20
34
  end
21
35
  end
22
36
 
@@ -0,0 +1,31 @@
1
+ module Octopress
2
+ class Unpublish < Command
3
+ def self.init_with_program(p)
4
+ p.command(:unpublish) do |c|
5
+ c.syntax 'unpublish <POST> [options]'
6
+ c.description 'Convert a post to a draft. Command accepts path to post or search string.'
7
+ CommandHelpers.add_common_options c
8
+
9
+ c.action do |args, options|
10
+ options['path'] = args.first
11
+ options['type'] = 'draft from post'
12
+
13
+ if !options['path']
14
+ abort "Unpublish failed: Please provide a path or a search string to select your post."
15
+ end
16
+ if File.exist?(options['path'])
17
+ unpublish_post(options)
18
+ else
19
+ options['path'] = CommandHelpers.select_posts(options['path'], 'unpublish')
20
+ unpublish_post(options)
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ def self.unpublish_post(options)
27
+ Post.new(Octopress.site(options), options).unpublish
28
+ end
29
+ end
30
+ end
31
+
@@ -3,6 +3,11 @@ module Octopress
3
3
 
4
4
  def set_default_options
5
5
  @options['type'] ||= 'draft'
6
+
7
+ if @options['title'].nil? && @options[:type] == 'post'
8
+ raise "Draft not created: Please choose a title.\n".red + " For example: " + "octopress new draft 'The merits of napping'".yellow
9
+ end
10
+
6
11
  @options['layout'] = @config['post_layout']
7
12
  @options['dir'] ||= ''
8
13
  @options['extension'] ||= @config['post_ext']
@@ -18,23 +23,20 @@ module Octopress
18
23
  File.join(site.source, '_drafts', name)
19
24
  end
20
25
 
21
- # -----
22
- # Methods for publishing drafts
23
- # -----
24
-
25
26
  # Create a new post from draft file
26
27
  #
27
28
  # Sets post options based on draft file contents
28
29
  # and options passed to the publish command
29
30
  #
30
31
  def publish
31
- @options['date'] ||= read_draft_date || Time.now.iso8601
32
+ @options['date'] ||= read_post_date || Time.now.iso8601
33
+ @options['title'] = read_post_title
32
34
 
33
35
  post_options = {
34
- 'title' => read_draft_title,
36
+ 'title' => @options['title'],
35
37
  'date' => @options['date'],
36
- 'slug' => publish_slug,
37
- 'content' => read_draft_content,
38
+ 'slug' => title_slug,
39
+ 'content' => read_post_content,
38
40
  'dir' => @options['dir'],
39
41
  'type' => 'post from draft'
40
42
  }
@@ -49,53 +51,6 @@ module Octopress
49
51
 
50
52
  end
51
53
 
52
- # Get the slug from options or filename
53
- #
54
- def publish_slug
55
- @options['slug'] || File.basename(@options['path'], '.*')
56
- end
57
-
58
- # Reads the file from _drafts/[path]
59
- #
60
- def read
61
- if @draft_content
62
- @draft_content
63
- else
64
- file = @options['path']
65
- abort "File #{file} not found." if !File.exist? file
66
- @draft_content = File.open(file).read
67
- end
68
- end
69
-
70
- # Get title from draft post file
71
- #
72
- def read_draft_title
73
- match = read.match(/title:\s+(.+)?$/)
74
- match[1] if match
75
- end
76
-
77
- # read_draft_date
78
- #
79
- def read_draft_date
80
- match = read.match(/date:\s+(\d.+)$/)
81
- match[1] if match
82
- end
83
-
84
- # Get content from draft post file
85
- # also update the draft's date configuration
86
- #
87
- def read_draft_content
88
- if @options['date']
89
- # remove date if it exists
90
- content = read.sub(/date:.*$\n/, "")
91
-
92
- # Insert date after title
93
- content.sub(/(title:.+$)/i, '\1'+"\ndate: #{@options['date']}")
94
- else
95
- read
96
- end
97
- end
98
-
99
54
  def default_template
100
55
  'draft'
101
56
  end
@@ -2,100 +2,47 @@ require 'find'
2
2
 
3
3
  module Octopress
4
4
  class Isolate
5
+ attr_accessor :site
6
+
5
7
  def initialize(options)
6
8
  @options = options
7
- Jekyll.logger.log_level = :error
8
- @site = Jekyll::Site.new(Jekyll.configuration(@options))
9
- Jekyll.logger.log_level = :info
9
+ @site = Octopress.site(@options)
10
10
  end
11
11
 
12
- def revert
13
- dir = File.join(@site.source, '_posts')
12
+ def integrate
13
+ dir = File.join(site.source, '_posts')
14
14
  exile_dir = File.join(dir, '_exile')
15
15
  if Dir.exist?(exile_dir)
16
- posts = find_exiled_posts
16
+ posts = CommandHelpers.find_exiled_posts
17
17
  if posts.size > 0
18
18
  FileUtils.mv(posts, dir)
19
19
  FileUtils.rmdir(File.join(dir, '_exile'))
20
20
 
21
21
  puts "Reintegrated #{posts.size} post#{'s' if posts.size != 1} from _posts/_exile"
22
22
  else
23
- puts "There aren't any posts in _posts/_exile."
23
+ abort "There aren't any posts in _posts/_exile."
24
24
  end
25
25
  else
26
- puts "There aren't any posts in _posts/_exile."
26
+ abort "There aren't any posts in _posts/_exile."
27
27
  end
28
28
  end
29
29
 
30
- def process
30
+ def isolate
31
+ post = File.expand_path(@options['path']) if @options['path']
32
+ others = (post ? find_other_posts(post) : CommandHelpers.find_posts)
33
+ exile_dir = File.join(site.source, '_posts/_exile')
31
34
 
32
- if @options['path']
33
- path = File.join(@site.source, @options['path'])
34
- if File.exist? path
35
- isolate_except(path)
36
- else
37
- puts "File not found: #{@options['path']}"
38
- end
39
- elsif @options['search']
40
- isolate_search(@options['search'])
41
- else
42
- isolate_latest
43
- end
44
- end
35
+ FileUtils.mkdir_p(exile_dir)
36
+ FileUtils.mv(others, exile_dir)
45
37
 
46
- # remove all posts that do not match string
47
- def isolate_search(string)
48
- posts = find_posts.select { |p| p =~ /#{string.gsub(/\s/, '-')}/i }
49
- isolate_except(posts)
50
- end
38
+ count = (post ? others.size : "all #{others.size}")
51
39
 
52
- # Isolate all but the most recent post
53
- def isolate_latest
54
- post = @site.read_posts('').sort_by(&:date).last
55
- path = File.join(@site.source, post.path)
56
- isolate_except(path)
40
+ puts "Moved #{count} post#{'s' if others.size != 1} into _posts/_exile"
41
+ puts "Isolated: " << "#{post.sub(Octopress.site.source + '/_posts/', '')}".yellow if post
57
42
  end
58
43
 
59
- def isolate_except(posts)
60
- others = find_other_posts(posts)
61
- posts = default_array(posts)
62
- exile_dir = @site.source, '_posts/_exile'
63
-
64
-
65
- if posts.size > 0
66
- FileUtils.mkdir_p(exile_dir)
67
- FileUtils.mv(others, exile_dir)
68
-
69
- puts "Isolated #{posts.size} post#{'s' if posts.size != 1}:"
70
- posts.each do |p|
71
- puts " - #{p.sub(@site.source+'/_posts/', '')}"
72
- end
73
- puts "Moved #{others.size} post#{'s' if others.size != 1} into _posts/_exile"
74
- else
75
- puts "No matching posts were found."
76
- end
77
- end
78
-
79
- def find_other_posts(paths)
80
- paths = default_array(paths)
81
-
82
- find_posts.reject do |p|
83
- paths.include?(p)
84
- end
85
- end
86
-
87
- def find_posts
88
- dir = File.join(@site.source, '_posts')
89
- Find.find(dir).to_a.reject do |f|
90
- File.directory?(f) || f =~ /_exile\//
91
- end
92
- end
93
-
94
- def find_exiled_posts
95
- dir = File.join(@site.source, '_posts/_exile')
96
- Find.find(dir).to_a.reject do |f|
97
- File.directory?(f)
98
- end
44
+ def find_other_posts(path)
45
+ CommandHelpers.find_posts.reject { |p| p == path }
99
46
  end
100
47
 
101
48
  def default_array(input)
@@ -3,6 +3,11 @@ module Octopress
3
3
 
4
4
  def set_default_options
5
5
  @options['type'] ||= 'post'
6
+
7
+ if @options['title'].nil? && @options[:type] == 'post'
8
+ raise "Post not created: Please choose a title.\n".red + " For example: " + "octopress new post \"Friendship with a tomato?\"".yellow
9
+ end
10
+
6
11
  @options['layout'] = @config['post_layout']
7
12
  @options['date'] = convert_date @options['date']
8
13
  @options['extension'] ||= @config['post_ext']
@@ -27,5 +32,63 @@ module Octopress
27
32
  front_matter %w{layout title date}
28
33
  end
29
34
 
35
+ def unpublish
36
+ @options['date'] = read_post_date
37
+ @options['title'] = read_post_title
38
+
39
+ post_options = {
40
+ 'title' => @options['title'],
41
+ 'date' => @options['date'],
42
+ 'slug' => title_slug,
43
+ 'content' => read_post_content,
44
+ 'dir' => @options['dir'],
45
+ 'type' => 'draft from post'
46
+ }
47
+ Draft.new(site, post_options).write
48
+
49
+ # Remove the old post file
50
+ #
51
+ FileUtils.rm @options['path']
52
+ end
53
+
54
+ # Reads the file from options[path]
55
+ #
56
+ def read
57
+ @post_content ||= begin
58
+ file = @options['path']
59
+ raise "File #{file} not found." if !File.exist? file
60
+ File.read(file)
61
+ end
62
+ end
63
+
64
+ # Get title from post file
65
+ #
66
+ def read_post_title
67
+ match = read.match(/title:\s+(.+)?$/)
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.+)$/)
75
+ match[1] if match
76
+ end
77
+
78
+ # Get content from draft post file
79
+ # also update the draft's date configuration
80
+ #
81
+ def read_post_content
82
+ if @options['date']
83
+ # remove date if it exists
84
+ content = read.sub(/date:.*$\n/, "")
85
+
86
+ # Insert date after title
87
+ content.sub(/(title:.+$)/i, '\1'+"\ndate: #{@options['date']}")
88
+ else
89
+ read
90
+ end
91
+ end
92
+
30
93
  end
31
94
  end
@@ -1,3 +1,3 @@
1
1
  module Octopress
2
- VERSION = "3.0.0.rc.25"
2
+ VERSION = "3.0.0.rc.26"
3
3
  end
data/site/Gemfile CHANGED
@@ -18,6 +18,10 @@ group :jekyll_plugins do
18
18
  gem "octopress-render-tag"#, path: "../../render-tag"
19
19
  gem "octopress-return-tag"#, path: "../../return-tag"
20
20
  gem "octopress-minify-html"#, path: "../../minify-html"
21
+ gem "octopress-quote-tag"#, path: "../../quote-tag"
22
+ gem "octopress-pullquote-tag"#, path: "../../pullquote-tag"
23
+ gem "octopress-image-tag"#, path: "../../image-tag"
24
+ gem "octopress-video-tag"#, path: "../../video-tag"
21
25
  gem "clash", path: "../../clash"
22
26
  end
23
27
 
@@ -2,11 +2,10 @@ site_tools:
2
2
  - octopress
3
3
  - octopress-deploy
4
4
  - octopress-linkblog
5
- - octopress-asset-pipeline
6
- - octopress-blockquote-tag
7
- - octopress-date-format
8
5
  - octopress-feed
6
+ - octopress-asset-pipeline
9
7
  - octopress-minify-html
8
+ - octopress-date-format
10
9
 
11
10
  themes:
12
11
  - octopress-genesis-theme
@@ -21,6 +20,9 @@ developer_tools:
21
20
  - clash
22
21
 
23
22
  liquid_plugins:
23
+ - octopress-quote-tag
24
+ - octopress-image-tag
25
+ - octopress-video-tag
24
26
  - octopress-include-tag
25
27
  - octopress-render-tag
26
28
  - octopress-wrap-tag
@@ -0,0 +1,4 @@
1
+ ---
2
+ layout: {{ layout }}
3
+ title: {{ title }}
4
+ ---
@@ -0,0 +1,4 @@
1
+ ---
2
+ layout: {{ layout }}
3
+ title: {{ title }}
4
+ ---
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: {{ layout }}
3
+ title: {{ title }}
4
+ date: {{ date }}
5
+ ---
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.25
4
+ version: 3.0.0.rc.26
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-05 00:00:00.000000000 Z
12
+ date: 2015-01-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mercenary
@@ -189,6 +189,7 @@ files:
189
189
  - lib/octopress/commands/isolate.rb
190
190
  - lib/octopress/commands/new.rb
191
191
  - lib/octopress/commands/publish.rb
192
+ - lib/octopress/commands/unpublish.rb
192
193
  - lib/octopress/docs.rb
193
194
  - lib/octopress/docs/doc.rb
194
195
  - lib/octopress/docs/hooks.rb
@@ -224,6 +225,9 @@ files:
224
225
  - site/_layouts/docs.html
225
226
  - site/_layouts/docs_index.html
226
227
  - site/_plugins/docs.rb
228
+ - site/_templates/draft
229
+ - site/_templates/page
230
+ - site/_templates/post
227
231
  - site/index.html
228
232
  - site/stylesheets/site.scss
229
233
  homepage: http://octopress.org