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)
catalog.git_info(mpackage)
catalog.package_page(mpackage)
end
- return catalog
+ self.catalog = catalog
end
end
-# Group all api handlers in one router.
-class APICatalogRouter
- super APIRouter
-
- init do
- use("/highlighted", new APICatalogHighLighted(config))
- use("/required", new APICatalogMostRequired(config))
- use("/bytags", new APICatalogByTags(config))
- use("/contributors", new APICatalogContributors(config))
- use("/stats", new APICatalogStats(config))
+redef class APIRouter
+ redef init do
+ super
+ use("/catalog/highlighted", new APICatalogHighLighted(config))
+ use("/catalog/required", new APICatalogMostRequired(config))
+ use("/catalog/bytags", new APICatalogByTags(config))
+ use("/catalog/contributors", new APICatalogContributors(config))
+ use("/catalog/stats", new APICatalogStats(config))
end
end
end
redef class Person
- super Jsonable
+ super Serializable
- redef fun to_json do
- var obj = new JsonObject
- obj["name"] = name
- obj["email"] = email
- obj["page"] = page
- obj["hash"] = (email or else "").md5.to_lower
- return obj.to_json
+ redef fun core_serialize_to(v) do
+ v.serialize_attribute("name", name)
+ v.serialize_attribute("email", email)
+ v.serialize_attribute("page", page)
+ v.serialize_attribute("hash", (email or else "").md5.to_lower)
end
end