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 81
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 100
def fillindex(content_pages, stmap)
  st = Struct.new(:title, :content_pages, :begints, :endts)
  content_pages = content_pages.sort
  @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 94
def update_crdate_lastmod(content_pages)
  @crdate = content_pages.map(&:crdate).append(@crdate).min
  @lastmod = content_pages.map(&:lastmod).append(@lastmod).max
end