2016-04-14 20:32:43 +03:00
|
|
|
var express = require('express'),
|
|
|
|
path = require('path'),
|
2016-04-11 16:58:41 +03:00
|
|
|
config = require('../config'),
|
2016-04-14 20:32:43 +03:00
|
|
|
frontend = require('../controllers/frontend'),
|
|
|
|
channels = require('../controllers/frontend/channels'),
|
2016-04-11 16:58:41 +03:00
|
|
|
utils = require('../utils'),
|
2013-12-30 11:03:29 +04:00
|
|
|
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 16:41:19 +04:00
|
|
|
frontendRoutes;
|
|
|
|
|
2016-04-11 16:58:41 +03:00
|
|
|
frontendRoutes = function frontendRoutes() {
|
2014-04-12 07:46:15 +04:00
|
|
|
var router = express.Router(),
|
2015-04-16 22:40:32 +03:00
|
|
|
subdir = config.paths.subdir,
|
2016-04-11 16:58:41 +03:00
|
|
|
routeKeywords = config.routeKeywords;
|
2013-12-30 11:03:29 +04:00
|
|
|
|
2015-12-10 18:00:02 +03:00
|
|
|
// ### Admin routes
|
|
|
|
router.get(/^\/(logout|signout)\/$/, function redirectToSignout(req, res) {
|
2016-02-09 17:14:24 +03:00
|
|
|
utils.redirect301(res, subdir + '/ghost/signout/');
|
2014-09-17 01:02:31 +04:00
|
|
|
});
|
2015-05-30 23:18:26 +03:00
|
|
|
router.get(/^\/signup\/$/, function redirectToSignup(req, res) {
|
2016-02-09 17:14:24 +03:00
|
|
|
utils.redirect301(res, subdir + '/ghost/signup/');
|
2014-09-17 01:02:31 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// redirect to /ghost and let that do the authentication to prevent redirects to /ghost//admin etc.
|
2015-05-30 23:18:26 +03:00
|
|
|
router.get(/^\/((ghost-admin|admin|wp-admin|dashboard|signin|login)\/?)$/, function redirectToAdmin(req, res) {
|
2016-02-09 17:14:24 +03:00
|
|
|
utils.redirect301(res, subdir + '/ghost/');
|
2014-09-17 01:02:31 +04:00
|
|
|
});
|
|
|
|
|
2016-02-09 17:14:24 +03:00
|
|
|
// Post Live Preview
|
|
|
|
router.get('/' + routeKeywords.preview + '/:uuid', frontend.preview);
|
2015-05-26 16:01:52 +03:00
|
|
|
|
2016-02-09 17:14:24 +03:00
|
|
|
// Channels
|
|
|
|
router.use(channels.router());
|
2014-07-20 20:32:14 +04:00
|
|
|
|
2016-04-14 20:32:43 +03:00
|
|
|
// setup routes for internal apps
|
|
|
|
// @TODO: refactor this to be a proper app route hook for internal & external apps
|
|
|
|
config.internalApps.forEach(function (appName) {
|
|
|
|
var app = require(path.join(config.paths.internalAppPath, appName));
|
|
|
|
if (app.hasOwnProperty('setupRoutes')) {
|
|
|
|
app.setupRoutes(router);
|
|
|
|
}
|
|
|
|
});
|
2016-04-11 16:58:41 +03:00
|
|
|
|
2016-08-10 13:11:41 +03:00
|
|
|
// Default
|
|
|
|
router.get('*', frontend.single);
|
|
|
|
|
2014-04-12 07:46:15 +04:00
|
|
|
return router;
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 16:41:19 +04:00
|
|
|
};
|
2014-03-24 01:49:43 +04:00
|
|
|
|
2014-09-10 08:06:24 +04:00
|
|
|
module.exports = frontendRoutes;
|