Class: Zine::Post

Inherits:
Page
  • Object
show all
Defined in:
lib/zine/post.rb

Overview

A post - content comes from the markdown, and the destination from the date

Instance Attribute Summary

Attributes inherited from Page

#dest_path, #formatted_data, #source_file, #template_bundle

Instance Method Summary collapse

Methods inherited from Page

slug

Constructor Details

#initialize(md_file_name, templates, site_options) ⇒ Post

Returns a new instance of Post.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/zine/post.rb', line 8

def initialize(md_file_name, templates, site_options)
  @source_file = md_file_name
  file_parts = File.read(md_file_name).split('---', 3)
  @formatted_data = FormattedData.new(parse_yaml(file_parts[1],
                                                 md_file_name),
                                      site_options)
  @raw_text = file_parts[2]
  init_templates(templates)
  option_dir = site_options['directories']
  @build_dir = option_dir['build'] # for tags
  @dest_path = make_path_from_date option_dir['blog']
end

Instance Method Details

#process(string_or_file_writer) ⇒ Object



21
22
23
24
25
# File 'lib/zine/post.rb', line 21

def process(string_or_file_writer)
  FileUtils.mkdir_p @dest_dir
  super string_or_file_writer
  tag_and_uri_subprocess
end

#process_without_writingObject



27
28
29
30
# File 'lib/zine/post.rb', line 27

def process_without_writing
  parse_markdown
  tag_and_uri_subprocess
end