module Nukumi2 module View class Abstract attr_reader :blog, :path def initialize(registry, path) @registry = registry @blog = @registry.blog @path = path end def entries [] end def to_page(flavor) @registry.page(self, flavor) end end class Empty < Abstract end class Full < Abstract def initialize(blog, path) super @entries = blog.topictree[path] end def entries @entries.sort_by { |e| e.time }.reverse end end class Single < Full end class Last < Full def entries super.first(@registry.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