2017-11-09 16:58:22 +03:00
|
|
|
var debug = require('ghost-ignition').debug('site:routes'),
|
|
|
|
|
2017-12-06 19:37:54 +03:00
|
|
|
routeService = require('../../services/route'),
|
2017-11-09 16:58:22 +03:00
|
|
|
siteRouter = routeService.siteRouter,
|
|
|
|
|
|
|
|
// Sub Routers
|
|
|
|
appRouter = routeService.appRouter,
|
2017-12-06 19:37:54 +03:00
|
|
|
channelsService = require('../../services/channels'),
|
2017-11-09 16:58:22 +03:00
|
|
|
|
|
|
|
// Controllers
|
2017-12-06 19:37:54 +03:00
|
|
|
controllers = require('../../controllers'),
|
2017-11-09 16:58:22 +03:00
|
|
|
|
|
|
|
// Utils for creating paths
|
|
|
|
// @TODO: refactor these away
|
2017-12-11 21:14:05 +03:00
|
|
|
urlService = require('../../services/url');
|
2017-11-09 16:58:22 +03:00
|
|
|
|
|
|
|
module.exports = function siteRoutes() {
|
|
|
|
// @TODO move this path out of this file!
|
2017-12-11 22:27:09 +03:00
|
|
|
// Note this also exists in api/events.js
|
2018-04-17 12:36:05 +03:00
|
|
|
// routeKeywords.preview: 'p'
|
|
|
|
var previewRoute = urlService.utils.urlJoin('/p', ':uuid', ':options?');
|
2017-11-09 16:58:22 +03:00
|
|
|
|
|
|
|
// Preview - register controller as route
|
|
|
|
// Ideal version, as we don't want these paths all over the place
|
|
|
|
// previewRoute = new Route('GET /:t_preview/:uuid/:options?', previewController);
|
|
|
|
// siteRouter.mountRoute(previewRoute);
|
|
|
|
// Orrrrr maybe preview should be an internal App??!
|
|
|
|
siteRouter.mountRoute(previewRoute, controllers.preview);
|
|
|
|
|
|
|
|
// Channels - register sub-router
|
|
|
|
// The purpose of having a parentRouter for channels, is so that we can load channels from wherever we want:
|
|
|
|
// config, settings, apps, etc, and that it will be possible for the router to be reloaded.
|
|
|
|
siteRouter.mountRouter(channelsService.router());
|
|
|
|
|
|
|
|
// Apps - register sub-router
|
|
|
|
// The purpose of having a parentRouter for apps, is that Apps can register a route whenever they want.
|
|
|
|
// Apps cannot yet deregister, it's complex to implement and I don't yet have a clear use-case for this.
|
|
|
|
siteRouter.mountRouter(appRouter.router());
|
|
|
|
|
|
|
|
// Default - register entry controller as route
|
|
|
|
siteRouter.mountRoute('*', controllers.entry);
|
|
|
|
|
|
|
|
debug('Routes:', routeService.registry.getAll());
|
|
|
|
|
|
|
|
return siteRouter.router();
|
|
|
|
};
|