mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
30b4eb07f7
- This is a first pass at getting a more logical structure. The focus is on moving from admin/frontend to client/server. - The location of the databases is highly important, this isn't expected to change again In the future - client/assets should probably become public/ - more stuff should be shared (helpers etc) - cleanup some confusion around tpl and views
31 lines
1001 B
JavaScript
31 lines
1001 B
JavaScript
/**
|
|
* Main controller for Ghost frontend
|
|
*/
|
|
|
|
/*global require, module */
|
|
|
|
var Ghost = require('../../ghost'),
|
|
api = require('../api'),
|
|
|
|
ghost = new Ghost(),
|
|
frontendControllers;
|
|
|
|
frontendControllers = {
|
|
'homepage': function (req, res) {
|
|
var page = req.params.page !== undefined ? parseInt(req.params.page, 10) : 1;
|
|
api.posts.browse({page: page}).then(function (page) {
|
|
ghost.doFilter('prePostsRender', page.posts, function (posts) {
|
|
res.render('index', {posts: posts, pagination: {page: page.page, prev: page.prev, next: page.next, limit: page.limit, total: page.total, pages: page.pages}});
|
|
});
|
|
});
|
|
},
|
|
'single': function (req, res) {
|
|
api.posts.read({'slug': req.params.slug}).then(function (post) {
|
|
ghost.doFilter('prePostsRender', post.toJSON(), function (post) {
|
|
res.render('post', {post: post});
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = frontendControllers; |