Ghost/core/server/routes/frontend.js
Hannah Wolfe bfe80da54a Enforce 2-digit dates in permalinks
fixes #1800

- changed permalink regex to require 4/2/2/slug
- changed url helper to enforce the same
- changed permalink toggle to set a specific state, this means the
  functional tests are independent again
- chnaged permalink toggle to wait for the settings page to load
- change as many frontend tests to not login as possible
2014-01-01 11:39:19 +00:00

20 lines
872 B
JavaScript

var frontend = require('../controllers/frontend');
module.exports = function (server) {
/*jslint regexp: true */
// ### Frontend routes
/* TODO: dynamic routing, homepage generator, filters ETC ETC */
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 ['', 'plain-slug']
// Given `/2012/12/24/plain-slug/` the req.params would be ['2012/12/24', 'plain-slug']
//server.get(/^\/([0-9\/]*)([^\/.]*)\/$/, frontend.single);
server.get(/^\/([0-9]{4}\/[0-9]{2}\/[0-9]{2}\/)?([^\/.]*)\/$/, frontend.single);
server.get('/', frontend.homepage);
};