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

#binary, #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?, #stylesheet, #subrender, #tag_pages, #url, #url_dir, #url_path

Constructor Details

#initialize(site, path, pages) ⇒ GeneratedIndex

Returns a new instance of GeneratedIndex.



520
521
522
523
524
525
526
527
# File 'lib/zenweb/page.rb', line 520

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.



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

def pages
  @pages
end

Class Method Details

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



508
509
510
# File 'lib/zenweb/page.rb', line 508

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)


512
513
514
# File 'lib/zenweb/page.rb', line 512

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



516
517
518
# File 'lib/zenweb/page.rb', line 516

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)


529
530
531
# File 'lib/zenweb/page.rb', line 529

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

#wireObject



533
534
535
536
# File 'lib/zenweb/page.rb', line 533

def wire
  super
  self.depends_on pages
end