Ghost/core/server/apps/private-blogging/index.js
Hannah Wolfe abaf0461cf Highlighted routes, controllers & renderers
refs #5091, refs #9192

- There are several theme template "renderers" all over the codebase
- Some are in apps, and were called "controllers"
- One is in error handling
- All of them now have comments marking out how they share logic/steps
- Other comments describe routes & controllers where they live
2017-11-08 09:45:12 +00:00

46 lines
1.4 KiB
JavaScript

var config = require('../../config'),
utils = require('../../utils'),
errors = require('../../errors'),
logging = require('../../logging'),
i18n = require('../../i18n'),
middleware = require('./lib/middleware'),
router = require('./lib/router'),
registerHelpers = require('./lib/helpers'),
checkSubdir;
checkSubdir = function checkSubdir() {
var paths;
if (utils.url.getSubdir()) {
paths = utils.url.getSubdir().split('/');
if (paths.pop() === config.get('routeKeywords').private) {
logging.error(new errors.GhostError({
message: i18n.t('errors.config.urlCannotContainPrivateSubdir.error'),
context: i18n.t('errors.config.urlCannotContainPrivateSubdir.description'),
help: i18n.t('errors.config.urlCannotContainPrivateSubdir.help')
}));
// @TODO: why
process.exit(0);
}
}
};
module.exports = {
activate: function activate(ghost) {
var privateRoute = '/' + config.get('routeKeywords').private + '/';
checkSubdir();
ghost.routeService.registerRouter(privateRoute, router);
registerHelpers(ghost);
},
setupMiddleware: function setupMiddleware(siteApp) {
siteApp.use(middleware.checkIsPrivate);
siteApp.use(middleware.filterPrivateRoutes);
}
};