mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-11 22:13:20 +03:00
abaf0461cf
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
46 lines
1.4 KiB
JavaScript
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);
|
|
}
|
|
};
|