code: replace `is cached` by `is lazy`
[nit.git] / contrib / nitiwiki / src / wiki_html.nit
index 266e1d9..3427016 100644 (file)
@@ -52,7 +52,7 @@ redef class WikiEntry
        fun url: String do return wiki.config.root_url.join_path(breadcrumbs.join("/"))
 
        # Get a `<a>` template link to `self`
-       fun tpl_link: Streamable do
+       fun tpl_link: Writable do
                return "<a href=\"{url}\">{title}</a>"
        end
 end
@@ -81,6 +81,7 @@ redef class WikiSection
                end
                var index = self.index
                if index isa WikiSectionIndex then
+                       wiki.message("Render auto-index for section {out_path}", 1)
                        index.is_dirty = true
                        add_child index
                end
@@ -106,11 +107,11 @@ redef class WikiSection
        #
        # If no file `index.md` exists for this section,
        # a summary is generated using contained articles.
-       fun index: WikiArticle is cached do
+       var index: WikiArticle is lazy do
                for child in children.values do
                        if child isa WikiArticle and child.is_index then return child
                end
-               return new WikiSectionIndex(wiki, self)
+               return new WikiSectionIndex(wiki, "index", self)
        end
 
        redef fun tpl_link do return index.tpl_link
@@ -214,7 +215,7 @@ redef class WikiArticle
        end
 
        # Generate the HTML header for this article.
-       fun tpl_header: Streamable do
+       fun tpl_header: Writable do
                var file = header_file
                if not wiki.has_template(file) then return ""
                return wiki.load_template(file)
@@ -236,7 +237,7 @@ redef class WikiArticle
        # Generate the HTML summary for this article.
        #
        # Based on `headlines`
-       fun tpl_summary: Streamable do
+       fun tpl_summary: Writable do
                var headlines = self.headlines
                var tpl = new Template
                tpl.add "<ul class=\"summary list-unstyled\">"
@@ -264,7 +265,7 @@ redef class WikiArticle
        end
 
        # Generate the HTML menu for this article.
-       fun tpl_menu: Streamable do
+       fun tpl_menu: Writable do
                var file = menu_file
                if not wiki.has_template(file) then return ""
                var tpl = wiki.load_template(file)
@@ -287,7 +288,7 @@ redef class WikiArticle
        end
 
        # Generate the HTML footer for this article.
-       fun tpl_footer: Streamable do
+       fun tpl_footer: Writable do
                var file = footer_file
                if not wiki.has_template(file) then return ""
                var tpl = wiki.load_template(file)
@@ -322,10 +323,9 @@ class WikiSectionIndex
        # The section described by `self`.
        var section: WikiSection
 
-       init(wiki: Nitiwiki, section: WikiSection) do
-               super(wiki, "index")
-               self.section = section
-       end
+       redef fun title do return section.title
+
+       redef fun url do return section.url
 
        redef var is_dirty = false
 
@@ -341,12 +341,20 @@ end
 class TplArticle
        super Template
 
-       var title: nullable Streamable = null
-       var body: nullable Streamable = null
+       # Article title.
+       var title: nullable Writable = null
+
+       # Article HTML body.
+       var body: nullable Writable = null
+
+       # Sidebar of this article (if any).
        var sidebar: nullable TplSidebar = null
+
+       # Breadcrumbs from wiki root to this article.
        var breadcrumbs: nullable TplBreadcrumbs = null
 
-       init with_title(title: Streamable) do
+       # Init `self` with a `title`.
+       init with_title(title: Writable) do
                self.title = title
        end
 
@@ -381,7 +389,7 @@ class TplSidebar
        super Template
 
        # Blocks are `Stremable` pieces that will be rendered in the sidebar.
-       var blocks = new Array[Streamable]
+       var blocks = new Array[Writable]
 
        redef fun rendering do
                for block in blocks do