module Nukumi2 module View class Abstract attr_reader :blog, :path inject :page def initialize(blog, path) @blog = blog @path = path end def entries [] end def to_page(flavor) page(self, flavor) end end class Empty < Abstract end class Full < Abstract def initialize(blog, path) super end def entries blog.topictree[path].sort_by { |e| e.time }.reverse end end class Single < Full end class Last < Full inject :show_last def entries super.first(show_last) end end class Subtopic < Empty attr_reader :subtopics def initialize(blog, path) super @subtopics = blog.topictree.subtopics(path).map { |sub| subtopic = File.join(path, sub) [subtopic, blog.topictree.name(subtopic) || sub] }.sort end end end end