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');
|
2016-03-19 21:37:04 +01:00
|
|
|
|
2016-04-01 00:20:34 +02:00
|
|
|
class PostsController {
|
2016-04-06 21:49:26 +02:00
|
|
|
registerRoutes() {
|
2016-05-20 21:35:12 +02:00
|
|
|
page('/upload', (ctx, next) => { this._uploadPostsRoute(); });
|
|
|
|
page('/posts', (ctx, next) => { this._listPostsRoute(); });
|
2016-04-06 21:49:26 +02:00
|
|
|
page(
|
|
|
|
'/post/:id',
|
2016-05-20 21:35:12 +02:00
|
|
|
(ctx, next) => { this._showPostRoute(ctx.params.id); });
|
2016-04-06 21:49:26 +02:00
|
|
|
page(
|
|
|
|
'/post/:id/edit',
|
2016-05-20 21:35:12 +02:00
|
|
|
(ctx, next) => { this._editPostRoute(ctx.params.id); });
|
2016-04-06 21:49:26 +02:00
|
|
|
}
|
|
|
|
|
2016-05-20 21:35:12 +02:00
|
|
|
_uploadPostsRoute() {
|
2016-04-01 00:20:34 +02:00
|
|
|
topNavController.activate('upload');
|
2016-03-19 21:37:04 +01:00
|
|
|
}
|
|
|
|
|
2016-05-20 21:35:12 +02:00
|
|
|
_listPostsRoute() {
|
2016-04-01 00:20:34 +02:00
|
|
|
topNavController.activate('posts');
|
2016-03-19 21:37:04 +01:00
|
|
|
}
|
|
|
|
|
2016-05-20 21:35:12 +02:00
|
|
|
_showPostRoute(id) {
|
2016-04-01 00:20:34 +02:00
|
|
|
topNavController.activate('posts');
|
2016-03-19 21:37:04 +01:00
|
|
|
}
|
|
|
|
|
2016-05-20 21:35:12 +02:00
|
|
|
_editPostRoute(id) {
|
2016-04-01 00:20:34 +02:00
|
|
|
topNavController.activate('posts');
|
2016-03-19 21:37:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-01 00:20:34 +02:00
|
|
|
module.exports = new PostsController();
|