class Clayoven::Toplevel::IndexPage

An “index page”

Should be an index.clay in the toplevel directory, or #{topic}.index.clay files in the toplevel directory, or some subdirectory. The ContentPage entries corresponding to this IndexPage will have to be .clay files under the #{topic}/[#{subtopic}/] directory of #{topic}.index.clay

Public Class Methods

new(filename, git) click to toggle source

Initialize permalink and target, with special handling for 'index.clay'; every other filename is a '*.index.clay'

Calls superclass method Clayoven::Toplevel::Page::new
# File lib/clayoven/toplevel.rb, line 83
def initialize(filename, git)
  super

  @permalink = if @filename == 'index.clay'
                 'index'
               else
                 filename.split('.index.clay').first
               end
  @target = "#{@permalink}.html"
end

Public Instance Methods

fillindex(content_pages, stmap) click to toggle source

Initialize Page#subtopics, and call IndexPage#update_crdate_lastmod.

# File lib/clayoven/toplevel.rb, line 101
def fillindex(content_pages, stmap)
  st = Struct.new(:title, :content_pages, :begints, :endts)
  content_pages = content_pages.sort_by { |cp| -cp.crdate.to_i }
  @subtopics = content_pages.group_by(&:subtopic).map do |subtop, grp|
    st.new(stmap[subtop], grp, grp.last.crdate, grp.first.crdate)
  end
  update_crdate_lastmod content_pages if content_pages.any?
end
update_crdate_lastmod(content_pages) click to toggle source

Page#crdate and Page#lastmod are decided, not based on git metadata, but on content_pages

# File lib/clayoven/toplevel.rb, line 95
def update_crdate_lastmod(content_pages)
  @crdate = content_pages.map(&:crdate).min
  @lastmod = content_pages.map(&:lastmod).max
end