mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
0ae0a0b490
refs #6982 - a replace for all config usages - always use config.get or config.set - this a pure replacement, no logic has changed [ci skip]
49 lines
1.7 KiB
JavaScript
49 lines
1.7 KiB
JavaScript
var express = require('express'),
|
|
path = require('path'),
|
|
config = require('../config'),
|
|
frontend = require('../controllers/frontend'),
|
|
channels = require('../controllers/frontend/channels'),
|
|
utils = require('../utils'),
|
|
|
|
frontendRoutes;
|
|
|
|
frontendRoutes = function frontendRoutes() {
|
|
var router = express.Router(),
|
|
subdir = utils.url.getSubdir(),
|
|
routeKeywords = config.get('routeKeywords');
|
|
|
|
// ### Admin routes
|
|
router.get(/^\/(logout|signout)\/$/, function redirectToSignout(req, res) {
|
|
utils.redirect301(res, subdir + '/ghost/signout/');
|
|
});
|
|
router.get(/^\/signup\/$/, function redirectToSignup(req, res) {
|
|
utils.redirect301(res, subdir + '/ghost/signup/');
|
|
});
|
|
|
|
// redirect to /ghost and let that do the authentication to prevent redirects to /ghost//admin etc.
|
|
router.get(/^\/((ghost-admin|admin|wp-admin|dashboard|signin|login)\/?)$/, function redirectToAdmin(req, res) {
|
|
utils.redirect301(res, subdir + '/ghost/');
|
|
});
|
|
|
|
// Post Live Preview
|
|
router.get('/' + routeKeywords.preview + '/:uuid', frontend.preview);
|
|
|
|
// Channels
|
|
router.use(channels.router());
|
|
|
|
// setup routes for internal apps
|
|
// @TODO: refactor this to be a proper app route hook for internal & external apps
|
|
config.get('internalApps').forEach(function (appName) {
|
|
var app = require(path.join(config.get('paths').internalAppPath, appName));
|
|
if (app.hasOwnProperty('setupRoutes')) {
|
|
app.setupRoutes(router);
|
|
}
|
|
});
|
|
|
|
// Default
|
|
router.get('*', frontend.single);
|
|
|
|
return router;
|
|
};
|
|
|
|
module.exports = frontendRoutes;
|