<commit_before>module Dimples
  class Post
    include Frontable
    include Writeable
    include Renderable

    attr_accessor :path
    attr_accessor :title
    attr_accessor :categories
    attr_accessor :template
    attr_accessor :filename
    attr_accessor :extension
    attr_accessor :layout
    attr_accessor :slug
    attr_accessor :date
    attr_accessor :year
    attr_accessor :month
    attr_accessor :day
    attr_accessor :rendered_contents
    attr_accessor :previous_post
    attr_accessor :next_post
    attr_accessor :draft

    attr_writer :contents

    def initialize(site, path)
      @site = site
      @path = path

      @filename = 'index'
      @extension = @site.config['file_extensions']['posts']

      parts = File.basename(path, File.extname(path)).match(/(\d{4})-(\d{2})-(\d{2})-(.+)/)

      @slug = parts[4]
      @date = Time.mktime(parts[1], parts[2], parts[3])

      @layout = @site.config['layouts']['post']
      @categories = {}

      @draft = false

      @year = @date.strftime('%Y')
      @month = @date.strftime('%m')
      @day = @date.strftime('%d')

      @contents = read_with_yaml(path)
    end

    def contents
      @contents
    end

    def output_file_path(parent_path)
      parts = [parent_path]

      if @site.config['paths']['post']
        path = @date.strftime(@site.config['paths']['post'])
        parts.concat(path.split('/')) if path
      end

      parts << @slug
      parts << "#{@filename}.#{@extension}"

      File.join(parts)
    end
  end
end<commit_msg>Simplified the output_file_path method to expand the given path if it looks like it has date formatting in it.<commit_after>module Dimples
  class Post
    include Frontable
    include Writeable
    include Renderable

    attr_accessor :path
    attr_accessor :title
    attr_accessor :categories
    attr_accessor :template
    attr_accessor :filename
    attr_accessor :extension
    attr_accessor :layout
    attr_accessor :slug
    attr_accessor :date
    attr_accessor :year
    attr_accessor :month
    attr_accessor :day
    attr_accessor :rendered_contents
    attr_accessor :previous_post
    attr_accessor :next_post
    attr_accessor :draft

    attr_writer :contents

    def initialize(site, path)
      @site = site
      @path = path

      @filename = 'index'
      @extension = @site.config['file_extensions']['posts']

      parts = File.basename(path, File.extname(path)).match(/(\d{4})-(\d{2})-(\d{2})-(.+)/)

      @slug = parts[4]
      @date = Time.mktime(parts[1], parts[2], parts[3])

      @layout = @site.config['layouts']['post']
      @categories = {}

      @draft = false

      @year = @date.strftime('%Y')
      @month = @date.strftime('%m')
      @day = @date.strftime('%d')

      @contents = read_with_yaml(path)
    end

    def contents
      @contents
    end

    def output_file_path(parent_path)
      parent_path = @date.strftime(parent_path) if parent_path =~ /%/
      File.join([parent_path, @slug, "#{@filename}.#{@extension}"])
    end
  end
end
{'fraction_non_alphanumeric': 0.1254125412541254, 'fraction_numerical': 0.0046204620462046205, 'mean_word_length': 2.8513341804320205, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '190691', 'n_tokens_mistral': 1005, 'n_tokens_neox': 970, 'n_words': 213}