diff --git a/core/server/controllers/frontend.js b/core/server/controllers/frontend.js index 2fa59f48c8..427d24b435 100644 --- a/core/server/controllers/frontend.js +++ b/core/server/controllers/frontend.js @@ -71,7 +71,8 @@ frontendControllers = { 'single': function (req, res, next) { // From route check if a date was parsed // from the regex - var dateInSlug = req.params[0] !== ''; + var dateInSlug = req.params[0] ? true : false; + console.log('SINGLE', req.params, dateInSlug); when.join( api.settings.read('permalinks'), api.posts.read({slug: req.params[1]}) diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index 99f6e1f4fe..4d7fa41578 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -94,9 +94,9 @@ coreHelpers.url = function (options) { var output = '', self = this, tags = { - year: function () { return self.created_at.getFullYear(); }, - month: function () { return self.created_at.getMonth() + 1; }, - day: function () { return self.created_at.getDate(); }, + year: function () { return moment(self.created_at).format('YYYY'); }, + month: function () { return moment(self.created_at).format('MM'); }, + day: function () { return moment(self.created_at).format('DD'); }, slug: function () { return self.slug; }, id: function () { return self.id; } }, diff --git a/core/server/routes/frontend.js b/core/server/routes/frontend.js index 2ef505cd33..78cdc0bc6a 100644 --- a/core/server/routes/frontend.js +++ b/core/server/routes/frontend.js @@ -14,6 +14,7 @@ module.exports = function (server) { // 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\/]*)([^\/.]*)\/$/, frontend.single); + server.get(/^\/([0-9]{4}\/[0-9]{2}\/[0-9]{2}\/)?([^\/.]*)\/$/, frontend.single); server.get('/', frontend.homepage); }; \ No newline at end of file diff --git a/core/test/functional/base.js b/core/test/functional/base.js index 336d9231e5..542e9fa8b3 100644 --- a/core/test/functional/base.js +++ b/core/test/functional/base.js @@ -209,14 +209,23 @@ CasperTest.Routines = (function () { }, id); } - function togglePermalinks(test) { - casper.thenOpen(url + "ghost/settings/"); - casper.thenClick('#permalinks'); - casper.thenClick('.button-save'); - casper.waitFor(function successNotification() { - return this.evaluate(function () { - return document.querySelectorAll('.js-bb-notification section').length > 0; + function togglePermalinks(state) { + casper.thenOpen(url + "ghost/settings/general"); + + casper.waitForSelector('#general'); + casper.waitForOpaque('#general', function then() { + var currentState = this.evaluate(function () { + return document.querySelector('#permalinks') && document.querySelector('#permalinks').checked ? 'on' : 'off'; }); + if (currentState !== state) { + casper.thenClick('#permalinks'); + casper.thenClick('.button-save'); + casper.waitFor(function successNotification() { + return this.evaluate(function () { + return document.querySelectorAll('.js-bb-notification section').length > 0; + }); + }); + } }); } diff --git a/core/test/functional/frontend/error_test.js b/core/test/functional/frontend/error_test.js index 6beac12463..670a095b05 100644 --- a/core/test/functional/frontend/error_test.js +++ b/core/test/functional/frontend/error_test.js @@ -7,11 +7,11 @@ CasperTest.begin('Check post not found (404)', 2, function suite(test) { test.assertEqual(response.status, 404, 'Response status should be 404.'); test.assertSelectorHasText('.error-code', '404'); }); -}); +}, true); CasperTest.begin('Check frontend route not found (404)', 2, function suite(test) { casper.thenOpen(url + 'asdf/asdf/', function (response) { test.assertEqual(response.status, 404, 'Response status should be 404.'); test.assertSelectorHasText('.error-code', '404'); }); -}); \ No newline at end of file +}, true); \ No newline at end of file diff --git a/core/test/functional/frontend/feed_test.js b/core/test/functional/frontend/feed_test.js index ecd5f7cc15..7aa46d5269 100644 --- a/core/test/functional/frontend/feed_test.js +++ b/core/test/functional/frontend/feed_test.js @@ -1,11 +1,11 @@ /** * Tests if RSS exists and is working */ -/*globals CasperTest, casper */ +/*globals url, CasperTest, casper */ CasperTest.begin('Ensure that RSS is available', 11, function suite(test) { casper.thenOpen(url + 'rss/', function (response) { var content = this.getPageContent(), - siteTitle = '