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.



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

def initialize(md_file_name, templates, site_options)
  @source_file = md_file_name
  file_parts = File.open(md_file_name, 'r').read.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



19
20
21
22
23
# File 'lib/zine/post.rb', line 19

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

#process_without_writingObject



25
26
27
28
# File 'lib/zine/post.rb', line 25

def process_without_writing
  parse_markdown
  tag_and_uri_subprocess
end