mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 18:52:05 +03:00
9394fad6aa
closes #1961 - Refactor admin to use its own express instance - Refactor middlewares to work with /ghost mounted admin express instance
60 lines
2.0 KiB
JavaScript
60 lines
2.0 KiB
JavaScript
var frontend = require('../controllers/frontend'),
|
|
config = require('../config'),
|
|
express = require('express'),
|
|
utils = require('../utils'),
|
|
|
|
frontendRoutes;
|
|
|
|
frontendRoutes = function () {
|
|
var router = express.Router(),
|
|
subdir = config.paths.subdir;
|
|
|
|
// ### Admin routes
|
|
router.get(/^\/(logout|signout)\/$/, function redirect(req, res) {
|
|
/*jslint unparam:true*/
|
|
res.set({'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S});
|
|
res.redirect(301, subdir + '/ghost/signout/');
|
|
});
|
|
router.get(/^\/signup\/$/, function redirect(req, res) {
|
|
/*jslint unparam:true*/
|
|
res.set({'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S});
|
|
res.redirect(301, 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 (req, res) {
|
|
/*jslint unparam:true*/
|
|
res.redirect(subdir + '/ghost/');
|
|
});
|
|
|
|
// ### Frontend routes
|
|
router.get('/rss/', frontend.rss);
|
|
router.get('/rss/:page/', frontend.rss);
|
|
router.get('/feed/', function redirect(req, res) {
|
|
/*jshint unused:true*/
|
|
res.set({'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S});
|
|
res.redirect(301, subdir + '/rss/');
|
|
});
|
|
|
|
// Tags
|
|
router.get('/tag/:slug/rss/', frontend.rss);
|
|
router.get('/tag/:slug/rss/:page/', frontend.rss);
|
|
router.get('/tag/:slug/page/:page/', frontend.tag);
|
|
router.get('/tag/:slug/', frontend.tag);
|
|
|
|
// Authors
|
|
router.get('/author/:slug/rss/', frontend.rss);
|
|
router.get('/author/:slug/rss/:page/', frontend.rss);
|
|
router.get('/author/:slug/page/:page/', frontend.author);
|
|
router.get('/author/:slug/', frontend.author);
|
|
|
|
// Default
|
|
router.get('/page/:page/', frontend.homepage);
|
|
router.get('/', frontend.homepage);
|
|
router.get('*', frontend.single);
|
|
|
|
return router;
|
|
};
|
|
|
|
module.exports = frontendRoutes;
|