diff --git a/lib/rss.js b/lib/rss.js
index 11ca4915..24416755 100755
--- a/lib/rss.js
+++ b/lib/rss.js
@@ -47,6 +47,7 @@ function generateXML (data){
ifTruePush(item.description, item_values, { description: { _cdata: item.description } });
ifTruePush(item.url, item_values, { link: item.url });
ifTruePush(item.link || item.guid || item.title, item_values, { guid: [ { _attr: { isPermaLink: !item.guid && !!item.url } }, item.guid || item.url || item.title ] });
+ ifTruePush(item.content, item_values, { 'content:encoded': { _cdata: item.content } });
item.categories.forEach(function(category) {
ifTruePush(category, item_values, { category: { _cdata: category } });
@@ -139,6 +140,7 @@ function RSS (options, items) {
description: options.description || '',
url: options.url,
guid: options.guid,
+ content: options.content,
categories: options.categories || [],
author: options.author,
date: options.date,
diff --git a/readme.md b/readme.md
index 95d5e27c..e16b75c1 100644
--- a/readme.md
+++ b/readme.md
@@ -55,6 +55,7 @@ feed.item(itemOptions);
* `guid` **unique string** A unique string feed readers use to know if an item is new or has already been seen.
If you use a guid never change it. If you don't provide a guid then your item urls must
be unique.
+ * `content` **string** Long form content for the item. Sets the content:encoded tag of the rss xml.
* `categories` _optional_ **array of strings** If provided, each array item will be added as a category element
* `author` _optional_ **string** If included it is the name of the item's creator.
If not provided the item author will be the same as the feed author. This is typical
diff --git a/test/rss.test.js b/test/rss.test.js
index d035797a..8a427f9b 100644
--- a/test/rss.test.js
+++ b/test/rss.test.js
@@ -39,18 +39,21 @@ describe('rss module', function(done) {
feed.item({
title: 'item 1',
description: 'description 1',
+ content: 'content 1',
url: 'http://example.com/article1',
date: 'May 24, 2012 04:00:00 GMT'
})
.item({
title: 'item 2',
description: 'description 2',
+ content: 'content 2',
url: 'http://example.com/article2',
date: 'May 25, 2012 04:00:00 GMT'
})
.item({
title: 'item 3',
description: 'description 3',
+ content: 'content 3',
url: 'http://example.com/article3',
guid: 'item3',
date: 'May 26, 2012 04:00:00 GMT'
@@ -58,6 +61,8 @@ describe('rss module', function(done) {
.item({
title: 'item 4 & html test with ',
description: 'description 4 uses some html',
+ content: 'content 4',
+ url: 'http://example.com/article3',
url: 'http://example.com/article4?this&that',
author: 'Guest Author',
date: 'May 27, 2012 04:00:00 GMT'
@@ -65,6 +70,7 @@ describe('rss module', function(done) {
.item({
title: 'item 5 & test for categories',
description: 'description 5',
+ content: 'content 5',
url: 'http://example.com/article5',
categories: ['Category 1','Category 2','Category 3','Category 4'],
author: 'Guest Author',
@@ -87,7 +93,7 @@ describe('rss module', function(done) {
it('should work with an easy test', function(done) {
var feed = simpleFeed();
- var expectedResult = '\nhttp://example.comhttp://example.com/icon.pngtitlehttp://example.comExample Generator' + new Date().toUTCString() +'Sun, 20 May 2012 04:00:00 GMThttp://example.com/rss/docs.html60- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
- http://example.com/article2http://example.com/article2Fri, 25 May 2012 04:00:00 GMT
- http://example.com/article3item3Sat, 26 May 2012 04:00:00 GMT
- ]]>html
]]>http://example.com/article4?this&thathttp://example.com/article4?this&thatSun, 27 May 2012 04:00:00 GMT- http://example.com/article5http://example.com/article5Mon, 28 May 2012 04:00:00 GMT
';
+ var expectedResult = '\nhttp://example.comhttp://example.com/icon.pngtitlehttp://example.comExample Generator' + new Date().toUTCString() +'Sun, 20 May 2012 04:00:00 GMThttp://example.com/rss/docs.html60- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
- http://example.com/article2http://example.com/article2Fri, 25 May 2012 04:00:00 GMT
- http://example.com/article3item3Sat, 26 May 2012 04:00:00 GMT
- ]]>html]]>http://example.com/article4?this&thathttp://example.com/article4?this&thatSun, 27 May 2012 04:00:00 GMT
- http://example.com/article5http://example.com/article5Mon, 28 May 2012 04:00:00 GMT
';
var result = feed.xml();
expect(result).to.equal(expectedResult);
@@ -114,18 +120,21 @@ describe('rss module', function(done) {
feed.item({
title: 'item 1',
description: 'description 1',
+ content: 'content 1',
url: 'http://example.com/article1',
date: 'May 24, 2012 04:00:00 GMT'
})
.item({
title: 'item 2',
description: 'description 2',
+ content: 'content 2',
url: 'http://example.com/article2',
date: 'May 25, 2012 04:00:00 GMT'
})
.item({
title: 'item 3',
description: 'description 3',
+ content: 'content 3',
url: 'http://example.com/article3',
guid: 'item3',
date: 'May 26, 2012 04:00:00 GMT'
@@ -133,6 +142,7 @@ describe('rss module', function(done) {
.item({
title: 'item 4 & html test with ',
description: 'description 4 uses some html',
+ content: 'content 4',
url: 'http://example.com/article4?this&that',
author: 'Guest Author',
date: 'May 27, 2012 04:00:00 GMT'
@@ -140,13 +150,14 @@ describe('rss module', function(done) {
.item({
title: 'item 5 & test for categories',
description: 'description 5',
+ content: 'content 5',
url: 'http://example.com/article5',
categories: ['Category 1','Category 2','Category 3','Category 4'],
author: 'Guest Author',
date: 'May 28, 2012 04:00:00 GMT'
});
- var expectedResult = '\nhttp://example.comRSS for Node' + new Date().toUTCString() +'Sun, 20 May 2012 04:00:00 GMThttp://example.com/rss/docs.html60- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
- http://example.com/article2http://example.com/article2Fri, 25 May 2012 04:00:00 GMT
- http://example.com/article3item3Sat, 26 May 2012 04:00:00 GMT
- ]]>html
]]>http://example.com/article4?this&thathttp://example.com/article4?this&thatSun, 27 May 2012 04:00:00 GMT- http://example.com/article5http://example.com/article5Mon, 28 May 2012 04:00:00 GMT
';
+ var expectedResult = '\nhttp://example.comRSS for Node' + new Date().toUTCString() +'Sun, 20 May 2012 04:00:00 GMThttp://example.com/rss/docs.html60- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
- http://example.com/article2http://example.com/article2Fri, 25 May 2012 04:00:00 GMT
- http://example.com/article3item3Sat, 26 May 2012 04:00:00 GMT
- ]]>html]]>http://example.com/article4?this&thathttp://example.com/article4?this&thatSun, 27 May 2012 04:00:00 GMT
- http://example.com/article5http://example.com/article5Mon, 28 May 2012 04:00:00 GMT
';
var result = feed.xml();
expect(result).to.equal(expectedResult);
@@ -165,6 +176,7 @@ describe('rss module', function(done) {
feed.item({
title: 'item 1',
description: 'description 1',
+ content: 'content 1',
url: 'http://example.com/article1',
date: 'May 24, 2012 04:00:00 GMT',
enclosure : 'incorrect value'
@@ -173,6 +185,7 @@ describe('rss module', function(done) {
feed.item({
title: 'item 2',
description: 'description 2',
+ content: 'content 2',
url: 'http://example.com/article1',
date: 'May 24, 2012 04:00:00 GMT',
enclosure : {url: '/media/some-file.flv'}
@@ -181,6 +194,7 @@ describe('rss module', function(done) {
feed.item({
title: 'item 3',
description: 'description 3',
+ content: 'content 3',
url: 'http://example.com/article1',
date: 'May 24, 2012 04:00:00 GMT',
enclosure : {url: '/media/image.png', file : __dirname+'/image.png'}
@@ -188,9 +202,9 @@ describe('rss module', function(done) {
var expectedResult = '\nhttp://example.comRSS for Node' + new Date().toUTCString() +''+
'' +
- '- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
'+
- '- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
'+
- '- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
'+
+ '- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
'+
+ '- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
'+
+ '- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
'+
'';
var result = feed.xml();
@@ -211,6 +225,7 @@ describe('rss module', function(done) {
feed.item({
title: 'item 1',
description: 'description 1',
+ content: 'content 1',
url: 'http://example.com/article1',
date: 'May 24, 2012 04:00:00 GMT',
lat: 12232,
@@ -220,14 +235,15 @@ describe('rss module', function(done) {
feed.item({
title: 'item 2',
description: 'description 2',
+ content: 'content 2',
url: 'http://example.com/article1',
date: 'May 24, 2012 04:00:00 GMT'
});
var expectedResult = '\nhttp://example.comRSS for Node' + new Date().toUTCString() +''+
'' +
- '- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT1223213333.23323
'+
- '- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
'+
+ '- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT1223213333.23323
'+
+ '- http://example.com/article1http://example.com/article1Thu, 24 May 2012 04:00:00 GMT
'+
'';
var result = feed.xml();