lib/octopress/draft.rb in octopress-3.0.0.rc.1 vs lib/octopress/draft.rb in octopress-3.0.0.rc.2

- old
+ new

@@ -1,11 +1,18 @@ module Octopress class Draft < Post def set_default_options - super - @options['type'] = 'draft' + @options['type'] ||= 'draft' + @options['layout'] = @config['post_layout'] + @options['dir'] ||= '' + @options['extension'] ||= @config['post_ext'] + @options['template'] ||= @config['post_template'] + + if @options['type'] == 'draft' + @options['date'] = convert_date @options['date'] + end end def path name = "#{title_slug}.#{extension}" File.join(source, '_drafts', name) @@ -19,16 +26,19 @@ # # Sets post options based on draft file contents # and options passed to the publish command # def publish + @options['date'] ||= read_draft_date + @options['date'] = convert_date @options['date'] post_options = { 'title' => read_draft_title, 'slug' => publish_slug, 'date' => @options['date'], 'content' => read_draft_content, + 'dir' => @options['dir'], 'type' => 'post from draft' } # Create a new post file # @@ -62,13 +72,23 @@ # def read_draft_title read.match(/title:\s+(.+)?$/)[1] end + # read_draft_date + # + def read_draft_date + read.match(/date:\s+(.+)?$/)[1] + end + # Get content from draft post file # def read_draft_content - read.sub(/date:\s+.+?$/, "date: #{@options['date']}") + if @options['date'] + read.sub(/date:\s+.+?$/, "date: #{@options['date']}") + else + read + end end end end