Ghost/core/server/services/routing/bootstrap.js
kirrg001 8bb7088ba0 🔥 Removed permalink setting
refs #9742

- removed usage of single permalink setting
  - with dynamic routing this configuration does no longer makes sense
  - because you can configure your permalinks in the routes.yaml
  - furthermore you can have multiple collections with multiple permalinks
- removed @blog.permalinks
- do not export permalink setting
- do not import permalink setting
- permalink setting UI will be removed soon
- get rid of {globals.permalink} completely
- remove yaml in-built migration
- do not expose settings.permalinks via the private API
- do not allow to edit this setting
- keep phyiscal value in case a blog needs to rollback from v2 to v1
- sorted out when the routers should be created
  - ensure routes.yaml file doesn't get validated before Ghost is fully ready to start
2018-08-16 12:13:24 +02:00

76 lines
2.4 KiB
JavaScript

const debug = require('ghost-ignition').debug('services:routing:bootstrap');
const _ = require('lodash');
const settingsService = require('../settings');
const StaticRoutesRouter = require('./StaticRoutesRouter');
const StaticPagesRouter = require('./StaticPagesRouter');
const CollectionRouter = require('./CollectionRouter');
const TaxonomyRouter = require('./TaxonomyRouter');
const PreviewRouter = require('./PreviewRouter');
const ParentRouter = require('./ParentRouter');
const registry = require('./registry');
let siteRouter;
module.exports.init = (options = {start: false}) => {
debug('bootstrap');
registry.resetAllRouters();
registry.resetAllRoutes();
siteRouter = new ParentRouter('SiteRouter');
registry.setRouter('siteRouter', siteRouter);
if (options.start) {
this.start();
}
return siteRouter.router();
};
/**
* Create a set of default and dynamic routers defined in the routing yaml.
*
* @TODO:
* - is the PreviewRouter an app?
*/
module.exports.start = () => {
const previewRouter = new PreviewRouter();
siteRouter.mountRouter(previewRouter.router());
registry.setRouter('previewRouter', previewRouter);
const dynamicRoutes = settingsService.get('routes');
_.each(dynamicRoutes.routes, (value, key) => {
const staticRoutesRouter = new StaticRoutesRouter(key, value);
siteRouter.mountRouter(staticRoutesRouter.router());
registry.setRouter(staticRoutesRouter.identifier, staticRoutesRouter);
});
_.each(dynamicRoutes.taxonomies, (value, key) => {
const taxonomyRouter = new TaxonomyRouter(key, value);
siteRouter.mountRouter(taxonomyRouter.router());
registry.setRouter(taxonomyRouter.identifier, taxonomyRouter);
});
_.each(dynamicRoutes.collections, (value, key) => {
const collectionRouter = new CollectionRouter(key, value);
siteRouter.mountRouter(collectionRouter.router());
registry.setRouter(collectionRouter.identifier, collectionRouter);
});
const staticPagesRouter = new StaticPagesRouter();
siteRouter.mountRouter(staticPagesRouter.router());
registry.setRouter('staticPagesRouter', staticPagesRouter);
const appRouter = new ParentRouter('AppsRouter');
siteRouter.mountRouter(appRouter.router());
registry.setRouter('appRouter', appRouter);
debug('Routes:', registry.getAllRoutes());
};