2014-03-24 01:49:43 +04:00
|
|
|
var frontend = require('../controllers/frontend'),
|
2016-02-09 17:14:24 +03:00
|
|
|
channels = require('../controllers/frontend/channels'),
|
2014-03-24 01:49:43 +04:00
|
|
|
config = require('../config'),
|
2014-04-12 07:46:15 +04:00
|
|
|
express = require('express'),
|
2014-07-28 17:19:49 +04: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;
|
|
|
|
|
2015-05-30 23:18:26 +03:00
|
|
|
frontendRoutes = function frontendRoutes(middleware) {
|
2014-04-12 07:46:15 +04:00
|
|
|
var router = express.Router(),
|
2015-04-16 22:40:32 +03:00
|
|
|
subdir = config.paths.subdir,
|
2015-05-26 16:01:52 +03:00
|
|
|
routeKeywords = config.routeKeywords,
|
|
|
|
privateRouter = express.Router();
|
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
|
|
|
});
|
|
|
|
|
2015-03-26 10:01:39 +03:00
|
|
|
// password-protected frontend route
|
2015-05-26 16:01:52 +03:00
|
|
|
privateRouter.route('/')
|
|
|
|
.get(
|
2015-07-15 19:01:23 +03:00
|
|
|
middleware.privateBlogging.isPrivateSessionAuth,
|
2015-05-26 16:01:52 +03:00
|
|
|
frontend.private
|
|
|
|
)
|
|
|
|
.post(
|
2015-07-15 19:01:23 +03:00
|
|
|
middleware.privateBlogging.isPrivateSessionAuth,
|
2015-05-26 22:04:27 +03:00
|
|
|
middleware.spamPrevention.protected,
|
2015-07-15 19:01:23 +03:00
|
|
|
middleware.privateBlogging.authenticateProtection,
|
2015-05-26 16:01:52 +03:00
|
|
|
frontend.private
|
|
|
|
);
|
2015-03-26 10:01:39 +03: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
|
|
|
// Private
|
2015-05-26 16:01:52 +03:00
|
|
|
router.use('/' + routeKeywords.private + '/', privateRouter);
|
2015-04-16 22:40:32 +03:00
|
|
|
|
2016-02-09 17:14:24 +03:00
|
|
|
// Channels
|
|
|
|
router.use(channels.router());
|
2014-07-20 20:32:14 +04:00
|
|
|
|
|
|
|
// Default
|
2014-04-12 07:46:15 +04:00
|
|
|
router.get('*', frontend.single);
|
|
|
|
|
|
|
|
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;
|