Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add item content #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add item content #36

wants to merge 3 commits into from

Conversation

efuquen
Copy link

@efuquen efuquen commented Nov 20, 2014

No description provided.

@maxnowack
Copy link
Contributor

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/"

@efuquen
Copy link
Author

efuquen commented Nov 25, 2014

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
Copy link
Author

efuquen commented Dec 10, 2014

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

@rv-kip
Copy link

rv-kip commented Dec 22, 2014

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
Copy link

rv-kip commented Jun 2, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants