Class: Zenweb::GeneratedIndex

Inherits:
FakePage show all
Defined in:
lib/zenweb/page.rb

Overview

Generates a virtual page with an index of all tags on the given pages. You must subclass and provide a content method.

Direct Known Subclasses

MonthlyPage, SeriesPage, TagIndex, YearlyPage

Constant Summary

Constants inherited from Page

Page::KRAMDOWN_CONFIG

Instance Attribute Summary collapse

Attributes inherited from FakePage

#date

Attributes inherited from Page

#parent, #path, #site, #subpages

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Page

#[], #all_subpages, #all_subpages_by_level, #analytics, #body, #breadcrumbs, #change_frequency, #clean_url, #config, #date, #date_from_path, #date_str, #dated?, #dated_path?, #depends_on, #disqus, #disqus_counts, #erb, #extend_md, #filetype, #filetypes, #format_date, #gauges_analytics, #generate, #google_ad, #google_analytics, #html?, #include, #index?, #inspect, #layout, #link_html, #markdown, #meta, #method_missing, #no_index?, #parent_url, #render, #render_erb, #render_less, #render_md, renderers_re, #run_js_script, #series_page, #stale?, #subrender, #tag_pages, #url, #url_dir, #url_path

Constructor Details

#initialize(site, path, pages) ⇒ GeneratedIndex

Returns a new instance of GeneratedIndex.



492
493
494
495
496
497
498
499
# File 'lib/zenweb/page.rb', line 492

def initialize site, path, pages
  super site, path

  self.pages = pages.select(&:html?)
  self.date  = Time.now

  site.pages[path] = self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Zenweb::Page

Instance Attribute Details

#pagesObject

Returns the value of attribute pages.



478
479
480
# File 'lib/zenweb/page.rb', line 478

def pages
  @pages
end

Class Method Details

.collate_by(pages, key, default = nil) ⇒ Object



480
481
482
# File 'lib/zenweb/page.rb', line 480

def self.collate_by pages, key, default=nil
  pages.multi_group_by { |page| page.config[key] || default }
end

.generate_all(site, dir, pages) ⇒ Object

Raises:

  • (NotImplementedError)


484
485
486
# File 'lib/zenweb/page.rb', line 484

def self.generate_all site, dir, pages
  raise NotImplementedError, "Implement #{self}#generate_all"
end

.page_url(page) ⇒ Object

TODO: hard to do helpers on class methods



488
489
490
# File 'lib/zenweb/page.rb', line 488

def self.page_url page # TODO: hard to do helpers on class methods
  "[#{page.title}](#{page.clean_url})"
end

Instance Method Details

#contentObject

Raises:

  • (NotImplementedError)


501
502
503
# File 'lib/zenweb/page.rb', line 501

def content
  raise NotImplementedError, "Implement #{self.class}#content"
end

#wireObject



505
506
507
508
# File 'lib/zenweb/page.rb', line 505

def wire
  super
  self.depends_on pages
end