From 31ae0c69235db6d3237b0d9883a129c4db20d561 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Mon, 24 Nov 2014 22:33:49 +0000 Subject: [PATCH] Change RSS content type & use absolute URL in meta no issue - changes the content type for the RSS feeds from text/xml to application/rss+xml - changes the link rel=alternate tag to use an absolute URL for the feed in the blog meta data --- core/server/controllers/frontend.js | 2 +- core/server/helpers/ghost_head.js | 2 +- core/test/functional/routes/frontend_test.js | 4 ++-- .../unit/server_helpers/ghost_head_spec.js | 23 ++++++++++--------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/core/server/controllers/frontend.js b/core/server/controllers/frontend.js index f36891b537..4f3abcbaa4 100644 --- a/core/server/controllers/frontend.js +++ b/core/server/controllers/frontend.js @@ -545,7 +545,7 @@ frontendControllers = { feed.item(item); }); }).then(function () { - res.set('Content-Type', 'text/xml; charset=UTF-8'); + res.set('Content-Type', 'application/rss+xml; charset=UTF-8'); res.send(feed.xml()); }); }); diff --git a/core/server/helpers/ghost_head.js b/core/server/helpers/ghost_head.js index 9b262e7a03..06399a8a31 100644 --- a/core/server/helpers/ghost_head.js +++ b/core/server/helpers/ghost_head.js @@ -156,7 +156,7 @@ ghost_head = function (options) { head.push(''); head.push(''); + title + '" href="' + config.urlFor('rss', null, true) + '" />'); return filters.doFilter('ghost_head', head); }).then(function (head) { var headString = _.reduce(head, function (memo, item) { return memo + '\n ' + item; }, ''); diff --git a/core/test/functional/routes/frontend_test.js b/core/test/functional/routes/frontend_test.js index dd31de4cbf..ecf2bdf5b1 100644 --- a/core/test/functional/routes/frontend_test.js +++ b/core/test/functional/routes/frontend_test.js @@ -376,7 +376,7 @@ describe('Frontend Routing', function () { it('should respond with xml', function (done) { request.get('/rss/') - .expect('Content-Type', 'text/xml; charset=utf-8') + .expect('Content-Type', 'application/rss+xml; charset=utf-8') .expect('Cache-Control', testUtils.cacheRules['public']) .expect(200) .end(function (err, res) { @@ -751,7 +751,7 @@ describe('Frontend Routing', function () { it('should serve RSS with date permalink', function (done) { request.get('/rss/') - .expect('Content-Type', 'text/xml; charset=utf-8') + .expect('Content-Type', 'application/rss+xml; charset=utf-8') .expect('Cache-Control', testUtils.cacheRules['public']) .expect(200) .end(function (err, res) { diff --git a/core/test/unit/server_helpers/ghost_head_spec.js b/core/test/unit/server_helpers/ghost_head_spec.js index 001f559323..beaffd3a85 100644 --- a/core/test/unit/server_helpers/ghost_head_spec.js +++ b/core/test/unit/server_helpers/ghost_head_spec.js @@ -33,7 +33,7 @@ describe('{{ghost_head}} helper', function () { should.exist(rendered); rendered.string.should.equal('\n' + ' \n' + - ' '); + ' '); done(); }).catch(done); @@ -44,7 +44,7 @@ describe('{{ghost_head}} helper', function () { should.exist(rendered); rendered.string.should.equal('\n' + ' \n' + - ' '); + ' '); done(); }).catch(done); @@ -96,7 +96,7 @@ describe('{{ghost_head}} helper', function () { ' "image": "http://testurl.com/content/images/test-image.png",\n "keywords": "tag1, tag2, tag3",\n' + ' "description": "blog description..."\n}\n \n\n' + ' \n' + - ' '); + ' '); done(); }).catch(done); @@ -149,7 +149,7 @@ describe('{{ghost_head}} helper', function () { ' "image": "http://testurl.com/content/images/test-image.png",\n "keywords": "tag1, tag2, tag3",\n' + ' "description": "blog "test" description..."\n}\n \n\n' + ' \n' + - ' '); + ' '); done(); }).catch(done); @@ -198,7 +198,7 @@ describe('{{ghost_head}} helper', function () { ' "image": "http://testurl.com/content/images/test-image.png",\n' + ' "description": "blog description..."\n}\n \n\n' + ' \n' + - ' '); + ' '); done(); }).catch(done); @@ -246,7 +246,7 @@ describe('{{ghost_head}} helper', function () { ' "datePublished": "' + post.published_at + '",\n "dateModified": "' + post.updated_at + '",\n' + ' "keywords": "tag1, tag2, tag3",\n "description": "blog description..."\n}\n \n\n' + ' \n' + - ' '); + ' '); done(); }).catch(done); @@ -279,7 +279,7 @@ describe('{{ghost_head}} helper', function () { should.exist(rendered); rendered.string.should.equal('\n' + ' \n' + - ' '); + ' '); done(); }).catch(done); @@ -290,7 +290,7 @@ describe('{{ghost_head}} helper', function () { should.exist(rendered); rendered.string.should.equal('\n' + ' \n' + - ' '); + ' '); done(); }).catch(done); @@ -303,7 +303,7 @@ describe('{{ghost_head}} helper', function () { ' \n' + ' \n' + ' \n' + - ' '); + ' '); done(); }).catch(done); }); @@ -315,7 +315,7 @@ describe('{{ghost_head}} helper', function () { ' \n' + ' \n' + ' \n' + - ' '); + ' '); done(); }).catch(done); }); @@ -339,7 +339,8 @@ describe('{{ghost_head}} helper', function () { should.exist(rendered); rendered.string.should.equal('\n' + ' \n' + - ' '); + ' '); done(); }).catch(done);