Merge: model: is_accessor
[nit.git] / src / nitweb.nit
index 071a2af..370e2a2 100644 (file)
 # Runs a webserver based on nitcorn that render things from model.
 module nitweb
 
-import popcorn::pop_config
-import popcorn::pop_auth
 import frontend
 import web
-
-redef class NitwebConfig
-
-       # Github client id used for Github OAuth login.
-       #
-       # * key: `github.client_id`
-       # * default: ``
-       var github_client_id: String is lazy do return value_or_default("github.client.id", "")
-
-       # Github client secret used for Github OAuth login.
-       #
-       # * key: `github.client_secret`
-       # * default: ``
-       var github_client_secret: String is lazy do
-               return value_or_default("github.client.secret", "")
-       end
-end
+import doc::doc_down
 
 redef class ToolContext
 
@@ -63,23 +45,25 @@ private class NitwebPhase
 
        # Build the nitweb config from `toolcontext` options.
        fun build_config(toolcontext: ToolContext, mainmodule: MModule): NitwebConfig do
-               var config_file = toolcontext.opt_config.value
-               if config_file == null then config_file = "nitweb.ini"
                var config = new NitwebConfig(
-                       config_file,
                        toolcontext.modelbuilder.model,
                        mainmodule,
                        toolcontext.modelbuilder)
+               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["app.host"] = opt_host
+               if opt_host != null then config.ini["app.host"] = opt_host
                var opt_port = toolcontext.opt_port.value
-               if opt_port >= 0 then config["app.port"] = opt_port.to_s
+               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.nitdoc_md_processor = config.md_processor
+               config.build_catalog
 
                var app = new App