0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/frontend/controllers/index.js
Hannah Wolfe 32bbf2ba57 issue #165, issue #124 - cleaning up ghostGlobals
- ghost.js - globals/globalConfig has become settings / settingsCache to make it clearer
- app.js - the ghostGlobals local cache is gone, and the use of res.locals has been cleaned up and simplified, although this needs to be properly split into frontend and admin locals (to be finished in #124)
- frontend/index.js - doesn't need to be passed globals and nav properties as res.locals does this for us
2013-06-17 23:12:13 +01:00

33 lines
No EOL
916 B
JavaScript

/**
* Main controller for Ghost frontend
*/
/*global require, module */
(function () {
'use strict';
var Ghost = require('../../ghost'),
api = require('../../shared/api'),
ghost = new Ghost(),
frontendControllers;
frontendControllers = {
'homepage': function (req, res) {
api.posts.browse().then(function (page) {
ghost.doFilter('prePostsRender', page.posts, function (posts) {
res.render('index', {posts: posts});
});
});
},
'single': function (req, res) {
api.posts.read({'slug': req.params.slug}).then(function (post) {
ghost.doFilter('prePostsRender', post.toJSON(), function (post) {
res.render('single', {post: post});
});
});
}
};
module.exports = frontendControllers;
}());