# Display the tree of all loaded mentities.
class TreeAction
- super NitAction
-
- # Model to explore and render.
- var model: Model
+ super ModelAction
# View to render.
var view = new HtmlHomePage(model) is lazy
# Display the list of mentities matching `namespace`.
class SearchAction
- super NitAction
-
- # Model to explore and render.
- var model: Model
+ super ModelAction
# TODO handle more than full namespaces.
redef fun answer(request, url) do
# Display a MEntity source code.
class CodeAction
- super NitAction
-
- # Model to explore and render.
- var model: Model
+ super ModelAction
# Modelbuilder used to access sources.
var modelbuilder: ModelBuilder
# Display the doc of a MEntity.
class DocAction
- super NitAction
-
- # Model to explore and render.
- var model: Model
+ super ModelAction
# Modelbuilder used to access sources.
var modelbuilder: ModelBuilder
# Return a random list of MEntities.
class RandomAction
- super NitAction
-
- # Model to explore and render.
- var model: Model
+ super ModelAction
# TODO handle more than full namespaces.
redef fun answer(request, url) do
# Base classes used by `nitweb`.
module web_base
-import frontend
+import model::model_views
import nitcorn
import json
end
end
+# Specific nitcorn Action that uses a Model
+class ModelAction
+ super NitAction
+
+ # Model to use.
+ var model: Model
+
+ # Init the model view from the `req` uri parameters.
+ fun init_model_view(req: HttpRequest): ModelView do
+ var view = new ModelView(model)
+
+ var show_private = req.bool_arg("private") or else false
+ if not show_private then view.min_visibility = protected_visibility
+
+ view.include_fictive = req.bool_arg("fictive") or else false
+ view.include_empty_doc = req.bool_arg("empty-doc") or else true
+ view.include_test_suite = req.bool_arg("test-suite") or else false
+ view.include_attribute = req.bool_arg("attributes") or else true
+
+ return view
+ end
+end
+
# A NitView is rendered by an action.
interface NitView
# Renders this view and returns something that can be written to a HTTP response.