2016-03-19 21:37:04 +01:00
|
|
|
'use strict';
|
|
|
|
|
2016-04-06 21:49:26 +02:00
|
|
|
const page = require('page');
|
2016-04-01 00:20:34 +02:00
|
|
|
const topNavController = require('../controllers/top_nav_controller.js');
|
|
|
|
const HomeView = require('../views/home_view.js');
|
2016-05-21 11:48:23 +02:00
|
|
|
const NotFoundView = require('../views/not_found_view.js');
|
2016-04-01 00:20:34 +02:00
|
|
|
|
2016-03-19 21:37:04 +01:00
|
|
|
class HomeController {
|
2016-04-01 00:20:34 +02:00
|
|
|
constructor() {
|
2016-05-20 21:35:12 +02:00
|
|
|
this._homeView = new HomeView();
|
2016-05-21 11:48:23 +02:00
|
|
|
this._notFoundView = new NotFoundView();
|
2016-03-19 21:37:04 +01:00
|
|
|
}
|
|
|
|
|
2016-04-06 21:49:26 +02:00
|
|
|
registerRoutes() {
|
2016-05-20 21:35:12 +02:00
|
|
|
page('/', (ctx, next) => { this._indexRoute(); });
|
2016-05-21 12:03:31 +02:00
|
|
|
page('*', (ctx, next) => { this._notFoundRoute(ctx); });
|
2016-04-06 21:49:26 +02:00
|
|
|
}
|
|
|
|
|
2016-05-20 21:35:12 +02:00
|
|
|
_indexRoute() {
|
2016-04-01 00:20:34 +02:00
|
|
|
topNavController.activate('home');
|
2016-05-20 21:35:12 +02:00
|
|
|
this._homeView.render({});
|
2016-03-19 21:37:04 +01:00
|
|
|
}
|
|
|
|
|
2016-05-21 12:03:31 +02:00
|
|
|
_notFoundRoute(ctx) {
|
2016-04-01 00:20:34 +02:00
|
|
|
topNavController.activate('');
|
2016-05-21 12:03:31 +02:00
|
|
|
this._notFoundView.render({path: ctx.canonicalPath});
|
2016-03-19 21:37:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-01 00:20:34 +02:00
|
|
|
module.exports = new HomeController();
|