nitc :: NitwebPhase
nitc :: NitwebPhase :: build_catalog
Build the catalognitc :: NitwebPhase :: build_config
Build the nitweb config fromtoolcontext
options.
nitc :: NitwebPhase :: defaultinit
nitc $ NitwebPhase :: SELF
Type of this instance, automatically specialized in every classnitc $ NitwebPhase :: process_mainmodule
Specific action to execute on the whole program.nitc :: Phase :: _in_hierarchy
The dependence relation of the phase with the other phasesnitc :: Phase :: _toolcontext
The toolcontext instance attached to the phasenitc :: NitwebPhase :: build_catalog
Build the catalognitc :: NitwebPhase :: build_config
Build the nitweb config fromtoolcontext
options.
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: Phase :: defaultinit
nitc :: NitwebPhase :: defaultinit
core :: Object :: defaultinit
nitc :: Phase :: in_hierarchy
The dependence relation of the phase with the other phasesnitc :: Phase :: in_hierarchy=
The dependence relation of the phase with the other phasescore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: Phase :: process_annotated_node
Specific actions to execute on annotated nodesnitc :: Phase :: process_mainmodule
Specific action to execute on the whole program.nitc :: Phase :: process_nclassdef
Specific actions to execute on the tree of a class definitionnitc :: Phase :: process_nmodule
Specific actions to execute on the whole tree of a modulenitc :: Phase :: process_nmodule_after
Specific actions to execute on the whole tree of a modulenitc :: Phase :: process_npropdef
Specific actions to execute on the tree of a propertynitc :: Phase :: toolcontext
The toolcontext instance attached to the phasenitc :: Phase :: toolcontext=
The toolcontext instance attached to the phase
# Phase that builds the model and wait for http request to serve pages.
private class NitwebPhase
super Phase
# Build the nitweb config from `toolcontext` options.
fun build_config(toolcontext: ToolContext, mainmodule: MModule): NitwebConfig do
var model = toolcontext.modelbuilder.model
var filter = new ModelFilter(
if toolcontext.opt_no_private.value then protected_visibility else private_visibility,
accept_fictive = not toolcontext.opt_no_fictive.value,
accept_empty_doc = not toolcontext.opt_no_empty_doc.value,
accept_test = not toolcontext.opt_no_test.value,
accept_attribute = not toolcontext.opt_no_attribute.value
)
var catalog = build_catalog(toolcontext.modelbuilder, filter)
var config = new NitwebConfig(model, mainmodule, toolcontext.modelbuilder, filter, catalog)
var config_file = toolcontext.opt_config.value
if config_file == null then config.default_config_file = "nitweb.ini"
config.parse_options(args)
var opt_host = toolcontext.opt_host.value
if opt_host != null then config.ini["app.host"] = opt_host
var opt_port = toolcontext.opt_port.value
if opt_port >= 0 then config.ini["app.port"] = opt_port.to_s
return config
end
redef fun process_mainmodule(mainmodule, mmodules)
do
var config = build_config(toolcontext, mainmodule)
config.model.index # pre load model index
config.model.nitdoc_md_processor = config.md_processor
var app = new App
app.use_before("/*", new SessionInit)
app.use_before("/*", new RequestClock)
app.use("/api", new APIRouter(config))
app.use("/login", new GithubLogin(config.github_client_id))
app.use("/oauth", new GithubOAuthCallBack(config.github_client_id, config.github_client_secret))
app.use("/logout", new GithubLogout)
app.use("/*", new StaticHandler(toolcontext.share_dir / "nitweb", "index.html"))
app.use_after("/*", new PopLogger(info_level))
app.listen(config.app_host, config.app_port)
end
# Build the catalog
#
# This method should be called at nitweb startup.
fun build_catalog(modelbuilder: ModelBuilder, filter: nullable ModelFilter): Catalog do
var catalog = new Catalog(modelbuilder)
var mpackages = modelbuilder.model.collect_mpackages(filter)
# Compute the poset
for p in mpackages do
var g = p.root
assert g != null
modelbuilder.scan_group(g)
end
# Build the catalog
for mpackage in mpackages do
catalog.package_page(mpackage)
catalog.git_info(mpackage)
catalog.mpackage_stats(mpackage)
end
return catalog
end
end
src/nitweb.nit:57,1--128,3