2017-08-17 11:52:58 +01:00
|
|
|
var express = require('express'),
|
|
|
|
config = require('../config'),
|
2017-10-09 12:56:44 +01:00
|
|
|
controllers = require('../controllers'),
|
2017-10-25 16:22:46 +01:00
|
|
|
channels = require('../controllers/channels'),
|
2017-10-31 09:46:59 +00:00
|
|
|
apps = require('../services/route').appRouter,
|
2017-08-17 11:52:58 +01:00
|
|
|
utils = require('../utils');
|
|
|
|
|
2017-10-26 17:24:08 +01:00
|
|
|
module.exports = function siteRouter() {
|
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
|
|
|
|
2017-11-05 12:45:43 +00:00
|
|
|
// Admin redirects - register redirect as route
|
|
|
|
// TODO: this should be middleware!
|
2017-10-12 13:36:50 +01:00
|
|
|
router.get(/^\/(logout|signout)\/$/, function (req, res) { return utils.url.redirectToAdmin(301, res, '#/signout/'); });
|
|
|
|
router.get(/^\/signup\/$/, function (req, res) { return utils.url.redirectToAdmin(301, res, '#/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.
|
2017-10-12 13:36:50 +01:00
|
|
|
router.get(/^\/((ghost-admin|admin|wp-admin|dashboard|signin|login)\/?)$/, function (req, res) { return utils.url.redirectToAdmin(301, res, '/'); });
|
2014-09-16 21:02:31 +00:00
|
|
|
|
2017-11-05 12:45:43 +00:00
|
|
|
// Preview - register controller as route
|
2017-10-09 12:56:44 +01:00
|
|
|
router.get(utils.url.urlJoin('/', routeKeywords.preview, ':uuid', ':options?'), controllers.preview);
|
2015-05-26 14:01:52 +01:00
|
|
|
|
2017-11-05 12:45:43 +00:00
|
|
|
// Channels - register sub-router
|
2016-02-09 14:14:24 +00:00
|
|
|
router.use(channels.router());
|
2014-07-20 17:32:14 +01:00
|
|
|
|
2017-11-05 12:45:43 +00:00
|
|
|
// Apps - register sub-router
|
2017-10-31 09:46:59 +00:00
|
|
|
router.use(apps.router);
|
2016-04-11 08:58:41 -05:00
|
|
|
|
2017-11-05 12:45:43 +00:00
|
|
|
// Default - register single controller as route
|
2017-10-09 12:56:44 +01:00
|
|
|
router.get('*', controllers.single);
|
2016-08-10 12:11:41 +02:00
|
|
|
|
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
|
|
|
};
|