nitweb: load catalog at startup instead of first page display
authorAlexandre Terrasa <alexandre@moz-code.org>
Fri, 17 Feb 2017 02:10:09 +0000 (21:10 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Mon, 6 Mar 2017 21:21:55 +0000 (16:21 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/nitweb.nit
src/web/api_catalog.nit

index 42e1df0..370e2a2 100644 (file)
@@ -63,6 +63,7 @@ private class NitwebPhase
        do
                var config = build_config(toolcontext, mainmodule)
                config.model.nitdoc_md_processor = config.md_processor
+               config.build_catalog
 
                var app = new App
 
index bd403ad..3a4bb19 100644 (file)
@@ -20,7 +20,12 @@ import catalog
 redef class NitwebConfig
 
        # Catalog to pass to handlers.
-       var catalog: Catalog is lazy do
+       var catalog: Catalog is noinit
+
+       # Build the catalog
+       #
+       # This method should be called at nitweb startup.
+       fun build_catalog do
                var catalog = new Catalog(modelbuilder)
                for mpackage in model.mpackages do
                        catalog.deps.add_node(mpackage)
@@ -36,7 +41,7 @@ redef class NitwebConfig
                        catalog.git_info(mpackage)
                        catalog.package_page(mpackage)
                end
-               return catalog
+               self.catalog = catalog
        end
 end