node-rss icon indicating copy to clipboard operation
node-rss copied to clipboard

Add item content

Open efuquen opened this issue 11 years ago • 5 comments

efuquen avatar Nov 20 '14 18:11 efuquen

Looks good so far, but there is no test for this case. In addition, so that the generated XML is valid, the content namespace must be included: xmlns:content="http://purl.org/rss/1.0/modules/content/"

maxnowack avatar Nov 24 '14 17:11 maxnowack

I added it to the tests. The namespace you mentioned seems to already be included here:

https://github.com/dylang/node-rss/blob/master/lib/rss.js#L94

efuquen avatar Nov 25 '14 16:11 efuquen

ping - just seeing if anyone can review my updates to the latest comment and give the thumbs up to merge?

efuquen avatar Dec 10 '14 20:12 efuquen

With the current 1.1.1 release, you can add content:encoded data (or any other custom field) as follows:

var RSS = require('rss');

/* let's create an rss feed */
var feed = new RSS({
    title: 'title',
    description: 'description',
    custom_namespaces   : {
      "content"   : "http://purl.org/rss/1.0/modules/content/"
    },
});

// Add an item/article
feed.item({
    title:  'Item Title ',
    description: 'The description',
    custom_elements: [
      {
        "content:encoded":
            {
                _cdata: "This is the long content. <b>This & That</b>"
            }
      }
    ]
});

// generate xml with default indent (4 sp)
var xml = feed.xml({indent: true});
console.log(xml);
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title><![CDATA[title]]></title>
        <description><![CDATA[description]]></description>
        <link>http://github.com/dylang/node-rss</link>
        <generator>RSS for Node</generator>
        <lastBuildDate>Mon, 22 Dec 2014 22:52:32 GMT</lastBuildDate>
        <item>
            <title><![CDATA[Item Title ]]></title>
            <description><![CDATA[The description]]></description>
            <guid isPermaLink="false">Item Title </guid>
            <content:encoded><![CDATA[This is the long content. <b>This & That</b>]]></content:encoded>
        </item>
    </channel>
</rss>

rv-kip avatar Dec 22 '14 22:12 rv-kip

@efuquen did the custom_namespaces functionality example shown in the previous comment accomplish the same goal as you intended with your pull request?

rv-kip avatar Jun 02 '15 00:06 rv-kip