From b0e9076193ad0150992f279c459e3e622028fbd8 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Sat, 7 Nov 2015 16:48:24 -0500 Subject: [PATCH 1/1] nitcatalog: use the Catalog as a factory of CatalogPage Signed-off-by: Jean Privat --- src/nitcatalog.nit | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/nitcatalog.nit b/src/nitcatalog.nit index 21847ee..a42bd64 100644 --- a/src/nitcatalog.nit +++ b/src/nitcatalog.nit @@ -83,6 +83,9 @@ end class CatalogPage super Template + # The associated catalog, used to groups options and other global data + var catalog: Catalog + # Placeholder to include additional things before the ``. var more_head = new Template @@ -191,6 +194,12 @@ class Catalog # The score is loosely computed using other metrics var score = new Counter[MPackage] + # Return a empty `CatalogPage`. + fun new_page(rootpath: String): CatalogPage + do + return new CatalogPage(self, rootpath) + end + # Scan, register and add a contributor to a package fun add_contrib(person: String, mpackage: MPackage, res: Template) do @@ -273,7 +282,7 @@ class Catalog # Compute information and generate a full HTML page for a package fun package_page(mpackage: MPackage): Writable do - var res = new CatalogPage("..") + var res = new_page("..") var score = score[mpackage].to_f var name = mpackage.name.html_escape res.more_head.add """{{{name}}}""" @@ -830,7 +839,7 @@ end # INDEX -var index = new CatalogPage("") +var index = catalog.new_page("") index.more_head.add "Packages in Nit" index.add """ @@ -877,7 +886,7 @@ index.write_to_file(out/"index.html") # PEOPLE -var page = new CatalogPage("") +var page = catalog.new_page("") page.more_head.add "People of Nit" page.add """
\n

People of Nit

\n""" page.add "

By Maintainer

\n" @@ -889,7 +898,7 @@ page.write_to_file(out/"people.html") # TABLE -page = new CatalogPage("") +page = catalog.new_page("") page.more_head.add "Projets of Nit" page.add """
\n

People of Nit

\n""" page.add "

Table of Projets

\n" -- 1.7.9.5