mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 20:34:02 +03:00
40064a395a
- we export i18n from `core/frontend/services/proxy` and this is used in the most of the places in the frontend code - this commit aligns the rest of the code in core/frontend to use the proxy too - unfortunately core/frontend/services/themes/i18n.js loops back to the proxy so we have a circular dependency
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
const {i18n} = require('../../services/proxy');
|
|
const urlUtils = require('../../../shared/url-utils');
|
|
const logging = require('../../../shared/logging');
|
|
const errors = require('@tryghost/errors');
|
|
const middleware = require('./lib/middleware');
|
|
const router = require('./lib/router');
|
|
const registerHelpers = require('./lib/helpers');
|
|
|
|
// routeKeywords.private: 'private'
|
|
const PRIVATE_KEYWORD = 'private';
|
|
|
|
let checkSubdir = function checkSubdir() {
|
|
let paths = '';
|
|
|
|
if (urlUtils.getSubdir()) {
|
|
paths = urlUtils.getSubdir().split('/');
|
|
|
|
if (paths.pop() === PRIVATE_KEYWORD) {
|
|
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) {
|
|
let privateRoute = `/${PRIVATE_KEYWORD}/`;
|
|
|
|
checkSubdir();
|
|
|
|
ghost.routeService.registerRouter(privateRoute, router);
|
|
|
|
registerHelpers(ghost);
|
|
},
|
|
|
|
setupMiddleware: function setupMiddleware(siteApp) {
|
|
siteApp.use(middleware.checkIsPrivate);
|
|
siteApp.use(middleware.filterPrivateRoutes);
|
|
},
|
|
|
|
setupErrorHandling: function setupErrorHandling(siteApp) {
|
|
siteApp.use(middleware.handle404);
|
|
}
|
|
};
|