class Awestruct::Extensions::Posts::Archive

Attributes

posts[RW]

Public Class Methods

new() click to toggle source
# File lib/awestruct/extensions/posts.rb, line 90
def initialize
  @posts        = {}
end

Public Instance Methods

<<( post ) click to toggle source
# File lib/awestruct/extensions/posts.rb, line 94
def <<( post )
  posts[post.date.year] ||= {}
  posts[post.date.year][post.date.month] ||= {}
  posts[post.date.year][post.date.month][post.date.day] ||= []
  posts[post.date.year][post.date.month][post.date.day] << post
end
generate_pages( engine, template, output_path ) click to toggle source
# File lib/awestruct/extensions/posts.rb, line 101
def generate_pages( engine, template, output_path )
  pages = []
  posts.keys.sort.each do |year|
    posts[year].keys.sort.each do |month| 
      posts[year][month].keys.sort.each do |day|
        archive_page = engine.find_and_load_site_page( template )
        archive_page.send( "archive=", posts[year][month][day] )
        archive_page.output_path = File.join( output_path, year.to_s, month.to_s, day.to_s, File.basename( template ) + ".html" )
        pages << archive_page
      end
    end
  end
  pages
end