2017-08-17 11:52:58 +01:00
|
|
|
var express = require('express'),
|
|
|
|
path = require('path'),
|
|
|
|
config = require('../config'),
|
|
|
|
frontend = require('../controllers/frontend'),
|
|
|
|
channels = require('../controllers/frontend/channels'),
|
|
|
|
utils = require('../utils');
|
|
|
|
|
|
|
|
module.exports = function frontendRoutes() {
|
2014-04-11 23:46:15 -04:00
|
|
|
var router = express.Router(),
|
2016-09-13 17:41:14 +02:00
|
|
|
routeKeywords = config.get('routeKeywords');
|
2013-12-30 02:03:29 -05:00
|
|
|
|
2015-12-10 15:00:02 +00:00
|
|
|
// ### Admin routes
|
|
|
|
router.get(/^\/(logout|signout)\/$/, function redirectToSignout(req, res) {
|
2017-03-14 16:03:30 +00:00
|
|
|
utils.redirect301(res, utils.url.urlJoin(utils.url.urlFor('admin'), '#/signout/'));
|
2014-09-16 21:02:31 +00:00
|
|
|
});
|
2015-05-30 21:18:26 +01:00
|
|
|
router.get(/^\/signup\/$/, function redirectToSignup(req, res) {
|
2017-03-14 16:03:30 +00:00
|
|
|
utils.redirect301(res, utils.url.urlJoin(utils.url.urlFor('admin'), '#/signup/'));
|
2014-09-16 21:02:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// redirect to /ghost and let that do the authentication to prevent redirects to /ghost//admin etc.
|
2015-05-30 21:18:26 +01:00
|
|
|
router.get(/^\/((ghost-admin|admin|wp-admin|dashboard|signin|login)\/?)$/, function redirectToAdmin(req, res) {
|
2017-02-02 19:51:35 +01:00
|
|
|
utils.redirect301(res, utils.url.urlFor('admin'));
|
2014-09-16 21:02:31 +00:00
|
|
|
});
|
|
|
|
|
2016-02-09 14:14:24 +00:00
|
|
|
// Post Live Preview
|
2017-08-08 08:32:55 +01:00
|
|
|
router.get(utils.url.urlJoin('/', routeKeywords.preview, ':uuid', ':options?'), frontend.preview);
|
2015-05-26 14:01:52 +01:00
|
|
|
|
2016-02-09 14:14:24 +00:00
|
|
|
// Channels
|
|
|
|
router.use(channels.router());
|
2014-07-20 17:32:14 +01:00
|
|
|
|
2016-04-14 18:32:43 +01:00
|
|
|
// setup routes for internal apps
|
|
|
|
// @TODO: refactor this to be a proper app route hook for internal & external apps
|
2017-05-29 21:48:42 +02:00
|
|
|
config.get('apps:internal').forEach(function (appName) {
|
2016-09-13 17:41:14 +02:00
|
|
|
var app = require(path.join(config.get('paths').internalAppPath, appName));
|
2016-04-14 18:32:43 +01:00
|
|
|
if (app.hasOwnProperty('setupRoutes')) {
|
|
|
|
app.setupRoutes(router);
|
|
|
|
}
|
|
|
|
});
|
2016-04-11 08:58:41 -05:00
|
|
|
|
2016-08-10 12:11:41 +02:00
|
|
|
// Default
|
|
|
|
router.get('*', frontend.single);
|
|
|
|
|
2014-04-11 23: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 13:41:19 +01:00
|
|
|
};
|