Class: Zine::DataPage

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

Overview

A page where the content comes from an array, usually an array of links to other pages, eg an index page like the home page

Instance Attribute Summary

Attributes inherited from Page

#dest_path, #formatted_data, #source_file, #template_bundle

Instance Method Summary collapse

Methods inherited from Page

#process, slug

Constructor Details

#initialize(data, templates, site_options, suffix = '.html') ⇒ DataPage

Returns a new instance of DataPage.



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

def initialize(data, templates, site_options, suffix = '.html')
  # super(front_matter, site_opt)
  init_templates(templates)
  @formatted_data = FormattedData.new({}, site_options)
  @formatted_data.page[:title] = data[:title]
  @formatted_data.data = data[:post_array]
  @dest_path = File.join(data[:build_dir],
                         Zine::Page.slug(data[:name]) + suffix)
  write
end

Instance Method Details

#writeObject



20
21
22
23
24
# File 'lib/zine/data_page.rb', line 20

def write
  html = template_the_html
  compressor = HtmlCompressor::Compressor.new
  File.write(@dest_path, compressor.compress(html))
end