mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
e302be2749
refs #9866 - invent preview api, but only used internally - the idea of a preview api is definitiely reaslistic and came up in the past a couple of times - by that we don't have to differentiate between pages or posts controller - still support v0.1 - preview controller is not registered for http, only internal handling
30 lines
710 B
JavaScript
30 lines
710 B
JavaScript
const ParentRouter = require('./ParentRouter');
|
|
const urlService = require('../url');
|
|
const controllers = require('./controllers');
|
|
|
|
class PreviewRouter extends ParentRouter {
|
|
constructor() {
|
|
super('PreviewRouter');
|
|
|
|
this.route = {value: '/p/'};
|
|
|
|
this._registerRoutes();
|
|
}
|
|
|
|
_registerRoutes() {
|
|
this.router().use(this._prepareContext.bind(this));
|
|
|
|
this.mountRoute(urlService.utils.urlJoin(this.route.value, ':uuid', ':options?'), controllers.preview);
|
|
}
|
|
|
|
_prepareContext(req, res, next) {
|
|
res.routerOptions = {
|
|
type: 'entry',
|
|
resourceType: 'preview'
|
|
};
|
|
|
|
next();
|
|
}
|
|
}
|
|
|
|
module.exports = PreviewRouter;
|