Sha256: 5fb174917146e80d9b782a978652ad55374af7336539c7cef75802c455d0cabf

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

module Octopress
  class Post < Page

    def set_default_options
      @options['type']      ||= 'post'
      @options['layout']      = @config['post_layout']
      @options['date']        = convert_date @options['date']
      @options['extension'] ||= @config['post_ext']
      @options['template']  ||= @config['post_template']
      @options['dir']       ||= ''
    end

    def path
      name = "#{date_slug}-#{title_slug}.#{extension}"
      dir = File.join(source, '_posts', @options['dir'])
      FileUtils.mkdir_p dir
      File.join(dir, name)
    end

    def default_template
      'post'
    end
    
    # Post template defaults
    #
    def default_content
      front_matter %w{layout title date}
    end

    # Returns a string which is url compatible.
    #
    def title_slug
      value = (@options['slug'] || @options['title']).downcase
      value.gsub!(/[^\x00-\x7F]/u, '')
      value.gsub!(/(&amp;|&)+/, 'and')
      value.gsub!(/[']+/, '')
      value.gsub!(/\W+/, ' ')
      value.strip!
      value.gsub!(' ', '-')
      value
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
octopress-3.0.0.rc.17 lib/octopress/post.rb
octopress-3.0.0.rc.16 lib/octopress/post.rb
octopress-3.0.0.rc.15 lib/octopress/post.rb
octopress-3.0.0.rc.14 lib/octopress/post.rb
octopress-3.0.0.rc.13 lib/octopress/post.rb
octopress-3.0.0.rc.12 lib/octopress/post.rb