Sha256: 830829abdabda60ede99428ac55a3a562f887431e46d23ab4e9c02bb86725d12

Contents?: true

Size: 916 Bytes

Versions: 10

Compression:

Stored size: 916 Bytes

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

    # 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

10 entries across 10 versions & 1 rubygems

Version Path
octopress-3.0.0.rc.11 lib/octopress/post.rb
octopress-3.0.0.rc.10 lib/octopress/post.rb
octopress-3.0.0.rc.9 lib/octopress/post.rb
octopress-3.0.0.rc.8 lib/octopress/post.rb
octopress-3.0.0.rc.7 lib/octopress/post.rb
octopress-3.0.0.rc.6 lib/octopress/post.rb
octopress-3.0.0.rc.5 lib/octopress/post.rb
octopress-3.0.0.rc.4 lib/octopress/post.rb
octopress-3.0.0.rc.3 lib/octopress/post.rb
octopress-3.0.0.rc.2 lib/octopress/post.rb