Ghost/core/server/routes/frontend.js
Harry Wolff ab80a132f3 Adds ability to quickly get to post’s edit page
fixes #1810

- updates frontend.single route to accept ‘edit’
as the last param

- updates controller.frontend to handle redirection
only when we would otherwise have rendered the page

- added unit tests for this behavior
2014-01-03 18:16:00 -05:00

20 lines
928 B
JavaScript

var frontend = require('../controllers/frontend');
module.exports = function (server) {
/*jslint regexp: true */
// ### Frontend routes
server.get('/rss/', frontend.rss);
server.get('/rss/:page/', frontend.rss);
server.get('/page/:page/', frontend.homepage);
// Only capture the :slug part of the URL
// This regex will always have two capturing groups,
// one for date, and one for the slug.
// Examples:
// Given `/plain-slug/` the req.params would be [undefined, 'plain-slug']
// Given `/2012/12/24/plain-slug/` the req.params would be ['2012/12/24/', 'plain-slug']
// Given `/plain-slug/edit/` the req.params would be [undefined, 'plain-slug', 'edit']
server.get(/^\/([0-9]{4}\/[0-9]{2}\/[0-9]{2}\/)?([^\/.]*)\/$/, frontend.single);
server.get(/^\/([0-9]{4}\/[0-9]{2}\/[0-9]{2}\/)?([^\/.]*)\/edit\/$/, frontend.edit);
server.get('/', frontend.homepage);
};