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.



7
8
9
10
11
12
13
14
15
# File 'lib/zine/data_page.rb', line 7

def initialize(data, templates, site_options, suffix = '.html')
  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



17
18
19
20
21
# File 'lib/zine/data_page.rb', line 17

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