Class: Zine::Page
- Inherits:
-
Object
- Object
- Zine::Page
- Defined in:
- lib/zine/page.rb
Overview
A page on the site where the content comes from a file’s markdown, and the destination’s location mirrors its own
Defined Under Namespace
Classes: FormattedData, TagData
Instance Attribute Summary collapse
-
#dest_path ⇒ Object
readonly
PostsAndHeadlines.one_new_post.
-
#formatted_data ⇒ Object
used in zine notice –.
-
#source_file ⇒ Object
used in zine notice –.
-
#template_bundle ⇒ Object
readonly
PostsAndHeadlines.one_new_post.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(md_file_name, dest, templates, site_options) ⇒ Page
constructor
A new instance of Page.
- #process(string_or_file_writer) ⇒ Object
Constructor Details
#initialize(md_file_name, dest, templates, site_options) ⇒ Page
Returns a new instance of Page.
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/zine/page.rb', line 77 def initialize(md_file_name, dest, templates, ) @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), ) @dest_path = dest @raw_text = file_parts[2] init_templates(templates) end |
Instance Attribute Details
#dest_path ⇒ Object (readonly)
PostsAndHeadlines.one_new_post
20 21 22 |
# File 'lib/zine/page.rb', line 20 def dest_path @dest_path end |
#formatted_data ⇒ Object
used in zine notice –
18 19 20 |
# File 'lib/zine/page.rb', line 18 def formatted_data @formatted_data end |
#source_file ⇒ Object
used in zine notice –
18 19 20 |
# File 'lib/zine/page.rb', line 18 def source_file @source_file end |
#template_bundle ⇒ Object (readonly)
PostsAndHeadlines.one_new_post
20 21 22 |
# File 'lib/zine/page.rb', line 20 def template_bundle @template_bundle end |
Class Method Details
.slug(text) ⇒ Object
96 97 98 99 100 |
# File 'lib/zine/page.rb', line 96 def self.slug(text) text.downcase .gsub(/[^a-z0-9]+/, '-') .gsub(/^-|-$/, '') end |
Instance Method Details
#process(string_or_file_writer) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/zine/page.rb', line 88 def process(string_or_file_writer) parse_markdown html = template_the_html compressor = HtmlCompressor::Compressor.new string_or_file_writer.write(@dest_path, compressor.compress(html)) end |