lib/octopress/draft.rb in octopress-3.0.10 vs lib/octopress/draft.rb in octopress-3.0.11
- old
+ new
@@ -19,11 +19,15 @@
@options['date'] = convert_date @options['date']
end
end
def path
- name = "#{title_slug}.#{extension}"
+ name = if @options['path']
+ "#{path_slug(@options['path'])}.#{File.extname(@options['path']).sub(/^\./, '')}"
+ else
+ "#{title_slug}.#{extension}"
+ end
File.join(site.source, '_drafts', name)
end
# Create a new post from draft file
#
@@ -33,17 +37,18 @@
def publish
@options['date'] ||= read_post_yaml('date') || Time.now.iso8601
@options['title'] = read_post_yaml('title')
post_options = {
- 'title' => @options['title'],
- 'date' => @options['date'],
- 'slug' => title_slug,
- 'force' => @options['force'],
- 'content' => read_post_content,
- 'dir' => @options['dir'],
- 'type' => "post from draft",
- 'write_message' => "Published: #{relative_path(path)} →"
+ 'title' => @options['title'],
+ 'date' => @options['date'],
+ 'slug' => path_slug(@options['path']),
+ 'extension' => File.extname(@options['path']).sub(/^\./, ''),
+ 'content' => read_post_content,
+ 'dir' => @options['dir'],
+ 'type' => "post from draft",
+ 'write_message' => "Published: #{relative_path(path)} →",
+ 'force' => @options['force']
}
# Create a new post file
#
Post.new(site, post_options).write