0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server/apps/private-blogging/index.js
Hannah Wolfe 7dba7b52f8 💄 Misc cleanup in middleware, helpers & apps (#7479)
no issue

- unsued code:
  - there are no public assets anymore, might need to use this instead of shared in future, but for now lets remove it to reduce confusion
  - the `input password` box was incorrectly registered as an admin helper, thinking that was needed in order to render the default template. This isn't needed.
- apps:
  - small structure & comment update to amp app
  - moving input_password helper into private blogging app
  - refactor helpers in subscribers app
2016-10-04 19:09:18 +02:00

39 lines
1.3 KiB
JavaScript

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