Merge: nitweb: misc enhancements and cleaning
authorJean Privat <jean@pryen.org>
Wed, 22 Jun 2016 17:34:47 +0000 (13:34 -0400)
committerJean Privat <jean@pryen.org>
Wed, 22 Jun 2016 17:34:47 +0000 (13:34 -0400)
## PR summary

* remove useless modules since angular introduction
* factorize some angular code
* factorize routes /package, /group, /module... into /doc
* display error messages
* add a loading progress bar

### Unified routes

Instead of having different prefix on the kind of mentity, URLs are no unified under the `doc/` prefix:

* http://nitweb.moz-code.org/doc/core
* http://nitweb.moz-code.org/doc/core::Array
* http://nitweb.moz-code.org/doc/core::Sequence::append

### Error messages

Unknown mentities now trigger an error message:

* http://nitweb.moz-code.org/doc/core::Sequence::append2

### Loading bar

There is now an orange (but discrete) progress bar in the top of the screen while loading ressources dynamically.

Checkout the top of the screen while loading: http://nitweb.moz-code.org/

Pull-Request: #2193
Reviewed-by: Jean Privat <jean@pryen.org>

20 files changed:
share/nitweb/directives/entity/namespace.html [new file with mode: 0644]
share/nitweb/index.html
share/nitweb/javascripts/entities.js
share/nitweb/javascripts/nitweb.js
share/nitweb/stylesheets/nitweb.css
share/nitweb/views/class.html
share/nitweb/views/classdef.html
share/nitweb/views/doc.html [new file with mode: 0644]
share/nitweb/views/group.html
share/nitweb/views/module.html
share/nitweb/views/package.html
share/nitweb/views/propdef.html
share/nitweb/views/property.html
src/doc/html_templates/html_model.nit
src/doc/html_templates/model_html.nit [moved from src/web/model_html.nit with 100% similarity]
src/nitweb.nit
src/web/web.nit
src/web/web_actions.nit [deleted file]
src/web/web_base.nit
src/web/web_views.nit [deleted file]

diff --git a/share/nitweb/directives/entity/namespace.html b/share/nitweb/directives/entity/namespace.html
new file mode 100644 (file)
index 0000000..6e39abf
--- /dev/null
@@ -0,0 +1,13 @@
+<span ng-if='mentity.mpackage'>
+       <entity-link mentity='mentity.mpackage' /> ::
+</span>
+<span ng-if='mentity.mmodule'>
+       <entity-link mentity='mentity.mmodule' /> ::
+</span>
+<span ng-if='mentity.intro_mclassdef'>
+       <entity-link mentity='mentity.intro_mclassdef' /> ::
+</span>
+<span ng-if='mentity.mclassdef'>
+       <entity-link mentity='mentity.mclassdef' /> ::
+</span>
+{{mentity.name}}
index 1b99a81..337750b 100644 (file)
                        integrity='sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7'
                        crossorigin='anonymous' rel='stylesheet'>
 
+               <link href='//cdnjs.cloudflare.com/ajax/libs/angular-loading-bar/0.9.0/loading-bar.min.css'
+                       type='text/css' rel='stylesheet' media='all'>
+
+
                <link href='/stylesheets/nitweb_bootstrap.css' rel='stylesheet'>
                <link href='/stylesheets/nitweb.css' rel='stylesheet'>
        </head>
@@ -51,6 +55,9 @@
                </script>
                <script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular-sanitize.js'>
                </script>
+               <script type='text/javascript'
+                       src='//cdnjs.cloudflare.com/ajax/libs/angular-loading-bar/0.9.0/loading-bar.min.js'>
+               </script>
 
                <script src='/javascripts/nitweb.js'></script>
                <script src='/javascripts/model.js'></script>
index 545bf08..9333050 100644 (file)
@@ -19,6 +19,8 @@
                .module('entities', ['ngSanitize', 'ui', 'model'])
 
                .controller('EntityCtrl', ['Model', '$routeParams', '$scope', '$sce', function(Model, $routeParams, $scope, $sce) {
+                       $scope.entityId = $routeParams.id;
+
                        this.loadEntityLinearization = function() {
                                Model.loadEntityLinearization($routeParams.id,
                                        function(data) {
@@ -58,8 +60,8 @@
                        Model.loadEntity($routeParams.id,
                                function(data) {
                                        $scope.mentity = data;
-                               }, function(err) {
-                                       $scope.error = err;
+                               }, function(message, status) {
+                                       $scope.error = {message: message, status: status};
                                });
                }])
 
                        };
                })
 
+               .directive('entityNamespace', function() {
+                       return {
+                               restrict: 'E',
+                               scope: {
+                                       mentity: '='
+                               },
+                               templateUrl: '/directives/entity/namespace.html'
+                       };
+               })
+
                .directive('entityTag', function() {
                        return {
                                restrict: 'E',
index 93b7c3a..99034a7 100644 (file)
  */
 
 (function() {
-       angular.module('nitweb', ['ngRoute', 'ngSanitize', 'entities', 'index'])
-
+       angular.module('nitweb', ['ngRoute', 'ngSanitize', 'angular-loading-bar', 'entities', 'index'])
+       .config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
+               cfpLoadingBarProvider.includeSpinner = false;
+       }])
        .config(function($routeProvider, $locationProvider) {
                $routeProvider
                        .when('/', {
                                controller: 'IndexCtrl',
                                controllerAs: 'indexCtrl'
                        })
-                       .when('/package/:id', {
-                               templateUrl: 'views/package.html',
-                               controller: 'EntityCtrl',
-                               controllerAs: 'entityCtrl'
-                       })
-                       .when('/group/:id', {
-                               templateUrl: 'views/group.html',
-                               controller: 'EntityCtrl',
-                               controllerAs: 'entityCtrl'
-                       })
-                       .when('/module/:id', {
-                               templateUrl: 'views/module.html',
-                               controller: 'EntityCtrl',
-                               controllerAs: 'entityCtrl'
-                       })
-                       .when('/class/:id', {
-                               templateUrl: 'views/class.html',
-                               controller: 'EntityCtrl',
-                               controllerAs: 'entityCtrl'
-                       })
-                       .when('/classdef/:id', {
-                               templateUrl: 'views/classdef.html',
-                               controller: 'EntityCtrl',
-                               controllerAs: 'entityCtrl'
-                       })
-                       .when('/property/:id', {
-                               templateUrl: 'views/property.html',
-                               controller: 'EntityCtrl',
-                               controllerAs: 'entityCtrl'
-                       })
-                       .when('/propdef/:id', {
-                               templateUrl: 'views/propdef.html',
+                       .when('/doc/:id', {
+                               templateUrl: 'views/doc.html',
                                controller: 'EntityCtrl',
                                controllerAs: 'entityCtrl'
                        })
index 941b5a4..9471a5d 100644 (file)
@@ -164,6 +164,12 @@ entity-list:hover .btn-filter {
        border-color: #eee;
 }
 
+/* loading bar */
+
+#loading-bar .bar {
+       background: #FF8100;
+}
+
 /* navs */
 
 .nav-tabs li { cursor: pointer; }
index 33c9fad..54da8af 100644 (file)
@@ -1,67 +1,60 @@
-<div class='container-fluid'>
-       <div class='page-header'>
-               <h2><entity-signature mentity='mentity.intro'/></h2>
-               <entity-link mentity='mentity.mpackage' /> :: {{mentity.name}}
-       </div>
-
-       <ul class='nav nav-tabs'>
-               <li role='presentation' class='active'>
-                       <a data-toggle='tab' data-target='#doc'>
-                               <span class='glyphicon glyphicon-book'/> Doc
-                       </a>
-               </li>
-               <li role='presentation'>
-                       <a data-toggle='tab' data-target='#graph' ng-click="entityCtrl.loadEntityGraph()">
-                               <span class='glyphicon glyphicon-object-align-vertical'/> Inheritance
-                       </a>
-               </li>
-               <li role='presentation'>
-                       <a data-toggle='tab' data-target='#all_props'>
-                               <span class='glyphicon glyphicon-tags'/> All properties
-                       </a>
-               </li>
-               <li role='presentation'>
-                       <a data-toggle='tab' role='tab' data-target='#linearization' aria-controls='linearization' ng-click='entityCtrl.loadEntityLinearization()'>
-                               <span class='glyphicon glyphicon-arrow-down'/> Linearization
-                       </a>
-               </li>
-       </ul>
+<ul class='nav nav-tabs'>
+       <li role='presentation' class='active'>
+               <a data-toggle='tab' data-target='#doc'>
+                       <span class='glyphicon glyphicon-book'/> Doc
+               </a>
+       </li>
+       <li role='presentation'>
+               <a data-toggle='tab' data-target='#graph' ng-click="entityCtrl.loadEntityGraph()">
+                       <span class='glyphicon glyphicon-object-align-vertical'/> Inheritance
+               </a>
+       </li>
+       <li role='presentation'>
+               <a data-toggle='tab' data-target='#all_props'>
+                       <span class='glyphicon glyphicon-tags'/> All properties
+               </a>
+       </li>
+       <li role='presentation'>
+               <a data-toggle='tab' role='tab' data-target='#linearization' aria-controls='linearization' ng-click='entityCtrl.loadEntityLinearization()'>
+                       <span class='glyphicon glyphicon-arrow-down'/> Linearization
+               </a>
+       </li>
+</ul>
 
-       <div class='tab-content'>
-               <div role='tabpanel' class='tab-pane fade in active' id='doc'>
-                       <entity-doc mentity='mentity.intro'/>
+<div class='tab-content'>
+       <div role='tabpanel' class='tab-pane fade in active' id='doc'>
+               <entity-doc mentity='mentity.intro'/>
 
-                       <entity-list list-title='Parents'
-                               list-entities='mentity.parents'
-                               list-object-filter='{}' />
+               <entity-list list-title='Parents'
+                       list-entities='mentity.parents'
+                       list-object-filter='{}' />
 
-                       <entity-list list-title='Constructors'
-                               list-entities='mentity.all_mproperties'
-                               list-object-filter='{is_init: true}' />
+               <entity-list list-title='Constructors'
+                       list-entities='mentity.all_mproperties'
+                       list-object-filter='{is_init: true}' />
 
-                       <entity-list list-title='Introduced properties'
-                               list-entities='mentity.intro_mproperties'
-                               list-object-filter='{is_init: "!true"}' />
+               <entity-list list-title='Introduced properties'
+                       list-entities='mentity.intro_mproperties'
+                       list-object-filter='{is_init: "!true"}' />
 
-                       <entity-list list-title='Redefined properties'
-                               list-entities='mentity.redef_mproperties'
-                               list-object-filter='{is_init: "!true"}' />
-               </div>
-               <div role='tabpanel' class='tab-pane fade' id='all_props'>
-                       <entity-list list-title='All properties' list-entities='mentity.all_mproperties'
-                               list-object-filter='{}' />
-               </div>
-               <div role='tabpanel' class='tab-pane fade' id='linearization'>
-                       <entity-linearization
-                               list-title='Class definitions'
-                               list-entities='linearization'
-                               list-focus='mentity.intro' />
-               </div>
-               <div role='tabpanel' class='tab-pane fade' id='graph'>
-                       <div class='card'>
-                               <div class='card-body text-center'>
-                                       <div class='graph' ng-bind-html='graph'></div>
-                               </div>
+               <entity-list list-title='Redefined properties'
+                       list-entities='mentity.redef_mproperties'
+                       list-object-filter='{is_init: "!true"}' />
+       </div>
+       <div role='tabpanel' class='tab-pane fade' id='all_props'>
+               <entity-list list-title='All properties' list-entities='mentity.all_mproperties'
+                       list-object-filter='{}' />
+       </div>
+       <div role='tabpanel' class='tab-pane fade' id='linearization'>
+               <entity-linearization
+                       list-title='Class definitions'
+                       list-entities='linearization'
+                       list-focus='mentity.intro' />
+       </div>
+       <div role='tabpanel' class='tab-pane fade' id='graph'>
+               <div class='card'>
+                       <div class='card-body text-center'>
+                               <div class='graph' ng-bind-html='graph'></div>
                        </div>
                </div>
        </div>
index 6c5354b..f44478f 100644 (file)
@@ -1,42 +1,33 @@
-<div class='container-fluid' ng-init='entityCtrl.loadEntityLinearization()'>
-       <div class='page-header'>
-               <h2><entity-signature mentity='mentity'/></h2>
-               <entity-link mentity='mentity.mpackage' />
-               :: <entity-link mentity='mentity.mmodule' />
-               :: {{mentity.name}}
-       </div>
-
-       <ul class='nav nav-tabs' role='tablist'>
-               <li role='presentation' class='warning'>
-                       <a ng-href='{{mentity.mclass.web_url}}'>
-                               <span class='glyphicon glyphicon-chevron-left'/> Go to class
-                       </a>
-               </li>
-               <li role='presentation' class='active'>
-                       <a data-toggle='tab' role='tab' data-target='#linearization' aria-controls='linearization'>
-                               <span class='glyphicon glyphicon-arrow-down'/> Linearization
-                       </a>
-               </li>
-               <li role='presentation'>
-                       <a data-toggle='tab' data-target='#code' ng-click="entityCtrl.loadEntityCode()">
-                               <span class='glyphicon glyphicon-console'/> Code
-                       </a>
-               </li>
-       </ul>
+<ul class='nav nav-tabs' role='tablist'>
+       <li role='presentation' class='warning'>
+               <a ng-href='{{mentity.mclass.web_url}}'>
+                       <span class='glyphicon glyphicon-chevron-left'/> Go to class
+               </a>
+       </li>
+       <li role='presentation' class='active'>
+               <a data-toggle='tab' role='tab' data-target='#linearization' aria-controls='linearization'>
+                       <span class='glyphicon glyphicon-arrow-down'/> Linearization
+               </a>
+       </li>
+       <li role='presentation'>
+               <a data-toggle='tab' data-target='#code' ng-click="entityCtrl.loadEntityCode()">
+                       <span class='glyphicon glyphicon-console'/> Code
+               </a>
+       </li>
+</ul>
 
-       <div class='tab-content'>
-               <div role='tabpanel' class='tab-pane fade in active' id='linearization'>
-                       <entity-linearization
-                               list-title='Class definitions'
-                               list-entities='linearization'
-                               list-focus='mentity' />
-               </div>
-               <div role='tabpanel' class='tab-pane fade' id='code'>
-                       <div class='card'>
-                               <div class='card-body'>
-                                       <pre ng-bind-html='code' />
-                                       <entity-location mentity='mentity' />
-                               </div>
+<div class='tab-content'>
+       <div role='tabpanel' class='tab-pane fade in active' id='linearization'>
+               <entity-linearization
+                       list-title='Class definitions'
+                       list-entities='linearization'
+                       list-focus='mentity' />
+       </div>
+       <div role='tabpanel' class='tab-pane fade' id='code'>
+               <div class='card'>
+                       <div class='card-body'>
+                               <pre ng-bind-html='code' />
+                               <entity-location mentity='mentity' />
                        </div>
                </div>
        </div>
diff --git a/share/nitweb/views/doc.html b/share/nitweb/views/doc.html
new file mode 100644 (file)
index 0000000..53f8a2a
--- /dev/null
@@ -0,0 +1,39 @@
+<div class='container-fluid'>
+
+       <div ng-if='error' class='alert alert-danger' role='alert'>
+               <span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span>
+               <span class='sr-only'>Error:</span>
+               <span ng-switch='error.status'>
+                       <span ng-switch-when='404'>Entity <code>{{entityId}}</code> not found!</span>
+                       <span ng-switch-default>An error occured<br/>{{error.status}}: {{error.message}}</span>
+               </span>
+       </div>
+
+       <div class='page-header'>
+               <h2><entity-signature mentity='mentity' /></h2>
+               <entity-namespace mentity='mentity' />
+       </div>
+       <div ng-switch='mentity.class_name'>
+               <div ng-switch-when='MPackage'>
+                       <div ng-include src='"/views/package.html"' />
+               </div>
+               <div ng-switch-when='MGroup'>
+                       <div ng-include src='"/views/group.html"' />
+               </div>
+               <div ng-switch-when='MModule'>
+                       <div ng-include src='"/views/module.html"' />
+               </div>
+               <div ng-switch-when='MClass'>
+                       <div ng-include src='"/views/class.html"' />
+               </div>
+               <div ng-switch-when='MClassDef'>
+                       <div ng-include src='"/views/classdef.html"' />
+               </div>
+               <div ng-switch-when='MMethod' ng-switch-when='MAttribute' ng-switch-when='MVirtualTypeProp'>
+                       <div ng-include src='"/views/property.html"' />
+               </div>
+               <div ng-switch-when='MMethodDef' ng-switch-when='MAttributeDef' ng-switch-when='MVirtualTypeDef'>
+                       <div ng-include src='"/views/propdef.html"' />
+               </div>
+       </div>
+</div>
index 53a1d2d..0b58963 100644 (file)
@@ -1,40 +1,33 @@
-<div class='container-fluid'>
-       <div class='page-header'>
-               <h2><entity-signature mentity='mentity' /></h2>
-               <entity-link mentity='mentity.mpackage' /> :: {{mentity.name}}
-       </div>
-
-       <ul class='nav nav-tabs'>
-               <li class='active'>
-                       <a data-toggle='tab' data-target='#doc'>
-                               <span class='glyphicon glyphicon-book'/> Doc
-                       </a>
-               </li>
-               <li role='presentation'>
-                       <a data-toggle='tab' data-target='#graph' ng-click="entityCtrl.loadEntityGraph()">
-                               <span class='glyphicon glyphicon-object-align-vertical'/> Imports
-                       </a>
-               </li>
-       </ul>
+<ul class='nav nav-tabs'>
+       <li class='active'>
+               <a data-toggle='tab' data-target='#doc'>
+                       <span class='glyphicon glyphicon-book'/> Doc
+               </a>
+       </li>
+       <li role='presentation'>
+               <a data-toggle='tab' data-target='#graph' ng-click="entityCtrl.loadEntityGraph()">
+                       <span class='glyphicon glyphicon-object-align-vertical'/> Imports
+               </a>
+       </li>
+</ul>
 
-       <div class='tab-content'>
-               <div role='tabpanel' class='tab-pane fade in active' id='doc'>
-                       <entity-doc mentity='mentity'/>
+<div class='tab-content'>
+       <div role='tabpanel' class='tab-pane fade in active' id='doc'>
+               <entity-doc mentity='mentity'/>
 
-                       <entity-list list-title='Parent group' list-entities='[mentity.parent]'
-                               list-object-filter='{}' ng-if='mentity.parent' />
+               <entity-list list-title='Parent group' list-entities='[mentity.parent]'
+                       list-object-filter='{}' ng-if='mentity.parent' />
 
-                       <entity-list list-title='Subgroups' list-entities='mentity.mgroups'
-                               list-object-filter='{}' />
+               <entity-list list-title='Subgroups' list-entities='mentity.mgroups'
+                       list-object-filter='{}' />
 
-                       <entity-list list-title='Modules' list-entities='mentity.mmodules'
-                               list-object-filter='{}' />
-               </div>
-               <div role='tabpanel' class='tab-pane fade' id='graph'>
-                       <div class='card'>
-                               <div class='card-body text-center'>
-                                       <div class='graph' ng-bind-html='graph'></div>
-                               </div>
+               <entity-list list-title='Modules' list-entities='mentity.mmodules'
+                       list-object-filter='{}' />
+       </div>
+       <div role='tabpanel' class='tab-pane fade' id='graph'>
+               <div class='card'>
+                       <div class='card-body text-center'>
+                               <div class='graph' ng-bind-html='graph'></div>
                        </div>
                </div>
        </div>
index ec33908..e80f9cf 100644 (file)
@@ -1,63 +1,56 @@
-<div class='container-fluid'>
-       <div class='page-header'>
-               <h2><entity-signature mentity='mentity'/></h2>
-               <entity-link mentity='mentity.mpackage' /> :: {{mentity.name}}
-       </div>
-
-       <ul class='nav nav-tabs'>
-               <li role='presentation' class='active'>
-                       <a data-toggle='tab' data-target='#doc'>
-                               <span class='glyphicon glyphicon-book'/> Doc
-                       </a>
-               </li>
-               <li role='presentation'>
-                       <a data-toggle='tab' data-target='#graph' ng-click="entityCtrl.loadEntityGraph()">
-                               <span class='glyphicon glyphicon-object-align-vertical'/> Imports
-                       </a>
-               </li>
-               <li role='presentation'>
-                       <a data-toggle='tab' data-target='#code' ng-click="entityCtrl.loadEntityCode()">
-                               <span class='glyphicon glyphicon-console'/> Code
-                       </a>
-               </li>
-               <li role='presentation'>
-                       <a data-toggle='tab' data-target='#defs' ng-click="entityCtrl.loadEntityDefs()">
-                               <span class='glyphicon glyphicon-asterisk'/> Class definitions
-                       </a>
-               </li>
-       </ul>
+<ul class='nav nav-tabs'>
+       <li role='presentation' class='active'>
+               <a data-toggle='tab' data-target='#doc'>
+                       <span class='glyphicon glyphicon-book'/> Doc
+               </a>
+       </li>
+       <li role='presentation'>
+               <a data-toggle='tab' data-target='#graph' ng-click="entityCtrl.loadEntityGraph()">
+                       <span class='glyphicon glyphicon-object-align-vertical'/> Imports
+               </a>
+       </li>
+       <li role='presentation'>
+               <a data-toggle='tab' data-target='#code' ng-click="entityCtrl.loadEntityCode()">
+                       <span class='glyphicon glyphicon-console'/> Code
+               </a>
+       </li>
+       <li role='presentation'>
+               <a data-toggle='tab' data-target='#defs' ng-click="entityCtrl.loadEntityDefs()">
+                       <span class='glyphicon glyphicon-asterisk'/> Class definitions
+               </a>
+       </li>
+</ul>
 
-       <div class='tab-content'>
-               <div role='tabpanel' class='tab-pane fade in active' id='doc'>
-                       <entity-doc mentity='mentity'/>
+<div class='tab-content'>
+       <div role='tabpanel' class='tab-pane fade in active' id='doc'>
+               <entity-doc mentity='mentity'/>
 
-                       <entity-list list-title='Imported modules' list-entities='mentity.imports'
-                               list-object-filter='{}' />
+               <entity-list list-title='Imported modules' list-entities='mentity.imports'
+                       list-object-filter='{}' />
 
-                       <entity-list list-title='Introduced classes' list-entities='mentity.intro_mclasses'
-                               list-object-filter='{}' />
+               <entity-list list-title='Introduced classes' list-entities='mentity.intro_mclasses'
+                       list-object-filter='{}' />
 
-                       <entity-list list-title='Class redefinitions' list-entities='mentity.redef_mclassdefs'
-                               list-object-filter='{}' />
+               <entity-list list-title='Class redefinitions' list-entities='mentity.redef_mclassdefs'
+                       list-object-filter='{}' />
 
-               </div>
-               <div role='tabpanel' class='tab-pane fade' id='code'>
-                       <div class='card'>
-                               <div class='card-body'>
-                                       <pre ng-bind-html='code' />
-                                       <entity-location mentity='mentity' />
-                               </div>
+       </div>
+       <div role='tabpanel' class='tab-pane fade' id='code'>
+               <div class='card'>
+                       <div class='card-body'>
+                               <pre ng-bind-html='code' />
+                               <entity-location mentity='mentity' />
                        </div>
                </div>
-               <div role='tabpanel' class='tab-pane fade' id='defs'>
-                       <entity-list list-title='Class definitions' list-entities='defs'
-                               list-object-filter='{}' />
-               </div>
-               <div class='tab-pane fade' id='graph'>
-                       <div class='card'>
-                               <div class='card-body text-center'>
-                                       <div class='graph' ng-bind-html='graph'></div>
-                               </div>
+       </div>
+       <div role='tabpanel' class='tab-pane fade' id='defs'>
+               <entity-list list-title='Class definitions' list-entities='defs'
+                       list-object-filter='{}' />
+       </div>
+       <div class='tab-pane fade' id='graph'>
+               <div class='card'>
+                       <div class='card-body text-center'>
+                               <div class='graph' ng-bind-html='graph'></div>
                        </div>
                </div>
        </div>
index 544c56d..32d9a2f 100644 (file)
@@ -1,33 +1,27 @@
-<div class='container-fluid'>
-       <div class='page-header'>
-               <h2><entity-signature mentity='mentity'/></h2>
-       </div>
-
-       <ul class='nav nav-tabs' role='tablist'>
-               <li role='presentation' class='active'>
-                       <a data-toggle='tab' role='tab' data-target='#doc' aria-controls="doc">
-                               <span class='glyphicon glyphicon-book'/> Doc
-                       </a>
-               </li>
-               <li role='presentation'>
-                       <a data-toggle='tab' data-target='#graph' ng-click="entityCtrl.loadEntityGraph()">
-                               <span class='glyphicon glyphicon-object-align-vertical'/> Dependencies
-                       </a>
-               </li>
-       </ul>
+<ul class='nav nav-tabs' role='tablist'>
+       <li role='presentation' class='active'>
+               <a data-toggle='tab' role='tab' data-target='#doc' aria-controls="doc">
+                       <span class='glyphicon glyphicon-book'/> Doc
+               </a>
+       </li>
+       <li role='presentation'>
+               <a data-toggle='tab' data-target='#graph' ng-click="entityCtrl.loadEntityGraph()">
+                       <span class='glyphicon glyphicon-object-align-vertical'/> Dependencies
+               </a>
+       </li>
+</ul>
 
-       <div class='tab-content'>
-               <div role='tabpanel' class='tab-pane fade in active' id='doc'>
-                       <entity-doc mentity='mentity'/>
+<div class='tab-content'>
+       <div role='tabpanel' class='tab-pane fade in active' id='doc'>
+               <entity-doc mentity='mentity'/>
 
-                       <entity-list list-title='Groups' list-entities='mentity.mgroups'
-                               list-object-filter='{}' />
-               </div>
-               <div role='tabpanel' class='tab-pane fade' id='graph'>
-                       <div class='card'>
-                               <div class='card-body text-center'>
-                                       <div class='graph' ng-bind-html='graph'></div>
-                               </div>
+               <entity-list list-title='Groups' list-entities='mentity.mgroups'
+                       list-object-filter='{}' />
+       </div>
+       <div role='tabpanel' class='tab-pane fade' id='graph'>
+               <div class='card'>
+                       <div class='card-body text-center'>
+                               <div class='graph' ng-bind-html='graph'></div>
                        </div>
                </div>
        </div>
index 87b0ff3..014e820 100644 (file)
@@ -1,43 +1,33 @@
-<div class='container-fluid' ng-init='entityCtrl.loadEntityLinearization()'>
-       <div class='page-header'>
-               <h2><entity-signature mentity='mentity'/></h2>
-               <entity-link mentity='mentity.mpackage' />
-               :: <entity-link mentity='mentity.mmodule' />
-               :: <entity-link mentity='mentity.mclassdef' />
-               :: {{mentity.name}}
-       </div>
-
-       <ul class='nav nav-tabs'>
-               <li role='presentation' class='warning'>
-                       <a href='{{mentity.mproperty.web_url}}'>
-                               <span class='glyphicon glyphicon-chevron-left'/> Go to property
-                       </a>
-               </li>
-               <li role='presentation' class='active'>
-                       <a data-toggle='tab' role='tab' data-target='#linearization' aria-controls='linearization'>
-                               <span class='glyphicon glyphicon-arrow-down'/> Linearization
-                       </a>
-               </li>
-               <li role='presentation'>
-                       <a data-toggle='tab' data-target='#code' ng-click="entityCtrl.loadEntityCode()">
-                               <span class='glyphicon glyphicon-console'/> Code
-                       </a>
-               </li>
-       </ul>
+<ul class='nav nav-tabs'>
+       <li role='presentation' class='warning'>
+               <a href='{{mentity.mproperty.web_url}}'>
+                       <span class='glyphicon glyphicon-chevron-left'/> Go to property
+               </a>
+       </li>
+       <li role='presentation' class='active'>
+               <a data-toggle='tab' role='tab' data-target='#linearization' aria-controls='linearization'>
+                       <span class='glyphicon glyphicon-arrow-down'/> Linearization
+               </a>
+       </li>
+       <li role='presentation'>
+               <a data-toggle='tab' data-target='#code' ng-click="entityCtrl.loadEntityCode()">
+                       <span class='glyphicon glyphicon-console'/> Code
+               </a>
+       </li>
+</ul>
 
-       <div class='tab-content'>
-               <div role='tabpanel' class='tab-pane fade in active' id='linearization'>
-                       <entity-linearization
-                               list-title='Class definitions'
-                               list-entities='linearization'
-                               list-focus='mentity' />
-               </div>
-               <div role='tabpanel' class='tab-pane fade' id='code'>
-                       <div class='card'>
-                               <div class='card-body'>
-                                       <pre ng-bind-html='code' />
-                                       <entity-location mentity='mentity' />
-                               </div>
+<div class='tab-content'>
+       <div role='tabpanel' class='tab-pane fade in active' id='linearization'>
+               <entity-linearization
+                       list-title='Class definitions'
+                       list-entities='linearization'
+                       list-focus='mentity' />
+       </div>
+       <div role='tabpanel' class='tab-pane fade' id='code'>
+               <div class='card'>
+                       <div class='card-body'>
+                               <pre ng-bind-html='code' />
+                               <entity-location mentity='mentity' />
                        </div>
                </div>
        </div>
index fea0da7..44e439e 100644 (file)
@@ -1,34 +1,24 @@
-<div class='container-fluid'>
+<ul class='nav nav-tabs'>
+       <li role='presentation' class='active'>
+               <a data-toggle='tab' data-target='#doc'>
+                       <span class='glyphicon glyphicon-book'/> Doc
+               </a>
+       </li>
+       <li role='presentation'>
+               <a data-toggle='tab' role='tab' data-target='#linearization' aria-controls='linearization' ng-click='entityCtrl.loadEntityLinearization()'>
+                       <span class='glyphicon glyphicon-arrow-down'/> Linearization
+               </a>
+       </li>
+</ul>
 
-       <div class='page-header'>
-               <h2><entity-signature mentity='mentity.intro'/></h2>
-               <entity-link mentity='mentity.mpackage' />
-               :: <entity-link mentity='mentity.intro_mclassdef' />
-               :: {{mentity.name}}
+<div class='tab-content'>
+       <div role='tabpanel' class='tab-pane fade in active' id='doc'>
+               <entity-doc mentity='mentity.intro'/>
        </div>
-
-       <ul class='nav nav-tabs'>
-               <li role='presentation' class='active'>
-                       <a data-toggle='tab' data-target='#doc'>
-                               <span class='glyphicon glyphicon-book'/> Doc
-                       </a>
-               </li>
-               <li role='presentation'>
-                       <a data-toggle='tab' role='tab' data-target='#linearization' aria-controls='linearization' ng-click='entityCtrl.loadEntityLinearization()'>
-                               <span class='glyphicon glyphicon-arrow-down'/> Linearization
-                       </a>
-               </li>
-       </ul>
-
-       <div class='tab-content'>
-               <div role='tabpanel' class='tab-pane fade in active' id='doc'>
-                       <entity-doc mentity='mentity.intro'/>
-               </div>
-               <div role='tabpanel' class='tab-pane fade' id='linearization'>
-                       <entity-linearization
-                               list-title='Class definitions'
-                               list-entities='linearization'
-                               list-focus='mentity.intro' />
-               </div>
+       <div role='tabpanel' class='tab-pane fade' id='linearization'>
+               <entity-linearization
+                       list-title='Class definitions'
+                       list-entities='linearization'
+                       list-focus='mentity.intro' />
        </div>
 </div>
index 7623c40..b8107ee 100644 (file)
@@ -18,7 +18,7 @@ module html_model
 import doc_base
 import html_components
 import ordered_tree
-import web::model_html
+import model_html
 
 redef class MEntity
        # URL of this entity’s Nitdoc page.
index 355fd6a..2e4e1d2 100644 (file)
@@ -68,7 +68,6 @@ private class NitwebPhase
 
                app.use_before("/*", new RequestClock)
                app.use("/api", new APIRouter(model, modelbuilder, mainmodule, catalog))
-               app.use("/doc/:namespace", new DocAction(model, mainmodule, modelbuilder))
                app.use("/*", new StaticHandler(toolcontext.share_dir / "nitweb", "index.html"))
                app.use_after("/*", new ConsoleLog)
 
index 8bb1e19..be5d2d1 100644 (file)
@@ -15,7 +15,6 @@
 # Components required to build a web server about the nit model.
 module web
 
-import web_actions
 import model_api
 import api_catalog
 import api_graph
diff --git a/src/web/web_actions.nit b/src/web/web_actions.nit
deleted file mode 100644 (file)
index cb193fd..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Nitcorn actions used by the nitweb server.
-module web_actions
-
-import web_views
-import uml
-
-# Display the tree of all loaded mentities.
-class TreeAction
-       super ModelHandler
-
-       redef fun get(req, res) do
-               var model = init_model_view(req)
-               var view = new HtmlHomePage(model.to_tree)
-               res.send_view(view)
-       end
-end
-
-# Display the doc of a MEntity.
-class DocAction
-       super ModelHandler
-
-       # Modelbuilder used to access sources.
-       var modelbuilder: ModelBuilder
-
-       redef fun get(req, res) do
-               var namespace = req.param("namespace")
-               var model = init_model_view(req)
-               var mentity = find_mentity(model, namespace)
-               if mentity == null then
-                       res.error(404)
-                       return
-               end
-               var view = new HtmlDocPage(modelbuilder, mentity)
-               res.send_view(view)
-       end
-end
index 476e68f..20d0b05 100644 (file)
@@ -87,21 +87,10 @@ abstract class APIHandler
        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.
-       fun render: Writable is abstract
-end
-
-redef class HttpResponse
-       # Render a NitView as response.
-       fun send_view(view: NitView, status: nullable Int) do send(view.render, status)
-end
-
 redef class MEntity
 
        # URL to `self` within the web interface.
-       fun web_url: String is abstract
+       fun web_url: String do return "/doc/" / full_name
 
        # URL to `self` within the JSON api.
        fun api_url: String do return "/api/entity/" / full_name
@@ -160,17 +149,7 @@ redef class MDoc
        end
 end
 
-redef class MPackage
-       redef var web_url = "/package/{full_name}" is lazy
-end
-
-redef class MGroup
-       redef var web_url = "/group/{full_name}" is lazy
-end
-
 redef class MModule
-       redef var web_url = "/module/{full_name}" is lazy
-
        redef fun api_json(handler) do
                var obj = super
                obj["intro_mclassdefs"] = to_mentity_refs(collect_intro_mclassdefs(private_view))
@@ -181,8 +160,6 @@ redef class MModule
 end
 
 redef class MClass
-       redef var web_url = "/class/{full_name}" is lazy
-
        redef fun api_json(handler) do
                var obj = super
                obj["all_mproperties"] = to_mentity_refs(collect_accessible_mproperties(private_view))
@@ -194,8 +171,6 @@ redef class MClass
 end
 
 redef class MClassDef
-       redef var web_url = "/classdef/{full_name}" is lazy
-
        redef fun json do
                var obj = super
                obj["intro"] = to_mentity_ref(mclass.intro)
@@ -212,8 +187,6 @@ redef class MClassDef
 end
 
 redef class MProperty
-       redef var web_url = "/property/{full_name}" is lazy
-
        redef fun json do
                var obj = super
                obj["intro_mclass"] = to_mentity_ref(intro_mclassdef.mclass)
@@ -223,8 +196,6 @@ redef class MProperty
 end
 
 redef class MPropDef
-       redef var web_url = "/propdef/{full_name}" is lazy
-
        redef fun json do
                var obj = super
                obj["intro"] = to_mentity_ref(mproperty.intro)
diff --git a/src/web/web_views.nit b/src/web/web_views.nit
deleted file mode 100644 (file)
index d8f8c9f..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Nitcorn actions used by the nitweb server.
-module web_views
-
-import web_base
-import model_html
-import highlight
-import markdown
-
-# Html homepage for the `nitweb` server.
-class HtmlHomePage
-       super NitView
-
-       # Loaded model to display.
-       var tree: MEntityTree
-
-       redef fun render do
-               var tpl = new Template
-               tpl.add new Header(1, "Loaded model")
-               tpl.add tree.html_list
-               return tpl
-       end
-end
-
-# Display the source for each mentities
-class HtmlSourcePage
-       super NitView
-
-       # Modelbuilder used to access sources.
-       var modelbuilder: ModelBuilder
-
-       # MEntity to display
-       var mentity: MEntity
-
-       # HiglightVisitor used to hilight the source code
-       var hl = new HighlightVisitor
-
-       redef fun render do
-               var tpl = new Template
-               tpl.add new Header(1, "Source Code")
-               tpl.add render_source
-               return tpl
-       end
-
-       private fun render_source: Template do
-               var node = modelbuilder.mentity2node(mentity)
-               var tpl = new Template
-               tpl.add new Header(3, "Source code")
-               if node == null then
-                       tpl.add "<p>Source for {mentity.html_name} not found.<p>"
-               else
-                       hl.enter_visit node
-                       tpl.add "<pre><code>"
-                       tpl.add hl.html
-                       tpl.add "</code></pre>"
-               end
-               return tpl
-       end
-end
-
-# Display the mdoc of the mentities.
-class HtmlDocPage
-       super HtmlSourcePage
-
-       redef fun render do
-               var tpl = new Template
-               tpl.add new Header(1, mentity.html_name)
-               tpl.add "<p>"
-               tpl.add mentity.html_declaration
-               tpl.add "</p>"
-               tpl.add "<br>"
-               var mdoc = mentity.mdoc
-               if mdoc != null then
-                       tpl.add mdoc.content.join("\n").md_to_html
-               end
-               tpl.add "<br>"
-               tpl.add render_source
-               return tpl
-       end
-end