2013-11-12 09:27:12 +04:00
|
|
|
var admin = require('../controllers/admin'),
|
2013-12-10 08:41:58 +04:00
|
|
|
config = require('../config'),
|
2014-03-24 01:49:43 +04:00
|
|
|
middleware = require('../middleware').middleware,
|
|
|
|
|
|
|
|
ONE_HOUR_S = 60 * 60,
|
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
|
|
|
ONE_YEAR_S = 365 * 24 * ONE_HOUR_S,
|
2013-11-12 09:27:12 +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
|
|
|
adminRoutes;
|
|
|
|
|
|
|
|
adminRoutes = function (server) {
|
2014-03-10 07:44:08 +04:00
|
|
|
// Have ember route look for hits first
|
|
|
|
// to prevent conflicts with pre-existing routes
|
2014-06-03 22:20:30 +04:00
|
|
|
server.get('/ghost/ember/*', middleware.redirectToSignup, admin.index);
|
2014-03-10 07:44:08 +04:00
|
|
|
|
2014-01-05 10:40:53 +04:00
|
|
|
var subdir = config().paths.subdir;
|
2013-11-12 09:27:12 +04:00
|
|
|
// ### Admin routes
|
2013-11-26 13:38:54 +04:00
|
|
|
server.get('/logout/', function redirect(req, res) {
|
2013-11-12 09:27:12 +04:00
|
|
|
/*jslint unparam:true*/
|
2014-03-24 01:49:43 +04:00
|
|
|
res.set({'Cache-Control': 'public, max-age=' + ONE_YEAR_S});
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(301, subdir + '/ghost/signout/');
|
2013-11-26 13:38:54 +04:00
|
|
|
});
|
|
|
|
server.get('/signout/', function redirect(req, res) {
|
|
|
|
/*jslint unparam:true*/
|
2014-03-24 01:49:43 +04:00
|
|
|
res.set({'Cache-Control': 'public, max-age=' + ONE_YEAR_S});
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(301, subdir + '/ghost/signout/');
|
2013-11-26 13:38:54 +04:00
|
|
|
});
|
|
|
|
server.get('/signin/', function redirect(req, res) {
|
|
|
|
/*jslint unparam:true*/
|
2014-03-24 01:49:43 +04:00
|
|
|
res.set({'Cache-Control': 'public, max-age=' + ONE_YEAR_S});
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(301, subdir + '/ghost/signin/');
|
2013-11-26 13:38:54 +04:00
|
|
|
});
|
|
|
|
server.get('/signup/', function redirect(req, res) {
|
|
|
|
/*jslint unparam:true*/
|
2014-03-24 01:49:43 +04:00
|
|
|
res.set({'Cache-Control': 'public, max-age=' + ONE_YEAR_S});
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(301, subdir + '/ghost/signup/');
|
2013-11-12 09:27:12 +04:00
|
|
|
});
|
2013-11-26 13:38:54 +04:00
|
|
|
|
2014-02-25 14:51:12 +04:00
|
|
|
server.get('/ghost/signout/', admin.signout);
|
2014-06-01 23:30:50 +04:00
|
|
|
server.post('/ghost/signout/', admin.doSignout);
|
2014-02-25 14:51:12 +04:00
|
|
|
server.get('/ghost/signin/', middleware.redirectToSignup, middleware.redirectToDashboard, admin.signin);
|
|
|
|
server.post('/ghost/signin/', admin.doSignin);
|
2013-11-12 09:27:12 +04:00
|
|
|
server.get('/ghost/signup/', middleware.redirectToDashboard, admin.signup);
|
2014-02-25 14:51:12 +04:00
|
|
|
server.post('/ghost/signup/', admin.doSignup);
|
2013-11-12 09:27:12 +04:00
|
|
|
server.get('/ghost/forgotten/', middleware.redirectToDashboard, admin.forgotten);
|
2014-02-25 14:51:12 +04:00
|
|
|
server.post('/ghost/forgotten/', admin.doForgotten);
|
2013-11-22 07:17:38 +04:00
|
|
|
server.get('/ghost/reset/:token', admin.reset);
|
2014-02-25 14:51:12 +04:00
|
|
|
server.post('/ghost/reset/:token', admin.doReset);
|
|
|
|
server.post('/ghost/changepw/', admin.doChangePassword);
|
2013-11-12 09:27:12 +04:00
|
|
|
|
2014-05-01 05:50:24 +04:00
|
|
|
server.get('/ghost/editor/:id/:action', admin.editor);
|
|
|
|
server.get('/ghost/editor/:id/', admin.editor);
|
2014-02-14 14:00:11 +04:00
|
|
|
server.get('/ghost/editor/', admin.editor);
|
|
|
|
server.get('/ghost/content/', admin.content);
|
|
|
|
server.get('/ghost/settings*', admin.settings);
|
|
|
|
server.get('/ghost/debug/', admin.debug.index);
|
|
|
|
|
2014-02-27 19:48:38 +04:00
|
|
|
server.get('/ghost/export/', admin.debug.exportContent);
|
|
|
|
|
2014-02-25 14:51:12 +04:00
|
|
|
server.post('/ghost/upload/', middleware.busboy, admin.upload);
|
2013-11-12 09:27:12 +04:00
|
|
|
|
|
|
|
// redirect to /ghost and let that do the authentication to prevent redirects to /ghost//admin etc.
|
2013-11-17 22:40:26 +04:00
|
|
|
server.get(/\/((ghost-admin|admin|wp-admin|dashboard|signin)\/?)$/, function (req, res) {
|
2013-11-12 09:27:12 +04:00
|
|
|
/*jslint unparam:true*/
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(subdir + '/ghost/');
|
2013-11-12 09:27:12 +04:00
|
|
|
});
|
2014-02-20 02:56:06 +04:00
|
|
|
server.get(/\/ghost$/, function (req, res) {
|
2013-11-12 09:27:12 +04:00
|
|
|
/*jslint unparam:true*/
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(subdir + '/ghost/');
|
2013-11-12 09:27:12 +04:00
|
|
|
});
|
2014-02-27 03:15:31 +04:00
|
|
|
server.get('/ghost/', admin.indexold);
|
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
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = adminRoutes;
|