Git Product home page Git Product logo

node-rss's Introduction

rss Build Status rss

RSS feed generator. Add RSS feeds to any project. Supports enclosures and GeoRSS.

Usage

Create a new feed

var RSS = require('rss');

var feed = new RSS(feedOptions);
feedOptions
  • title string Title of your site or feed
  • description optional string A short description of the feed.
  • generator optional string Feed generator.
  • feed_url url string Url to the rss feed.
  • site_url url string Url to the site that the feed is for.
  • image_url optional url string Small image for feed readers to use.
  • docs optional url string Url to documentation on this feed.
  • managingEditor optional string Who manages content in this feed.
  • webMaster optional string Who manages feed availability and technical support.
  • copyright optional string Copyright information for this feed.
  • language optional string The language of the content of this feed.
  • categories optional array of strings One or more categories this feed belongs to.
  • pubDate optional Date object or date string The publication date for content in the feed
  • ttl optional integer Number of minutes feed can be cached before refreshing from source.
  • hub optional PubSubHubbub hub url Where is the PubSubHub hub located.
  • custom_namespaces optional object Put additional namespaces in element (without 'xmlns:' prefix)
  • custom_elements optional array Put additional elements in the feed (node-xml syntax)

Add items to a feed

An item can be used for a blog entry, project update, log entry, etc. Your RSS feed can have any number of items. Most feeds use 20 or fewer items.

feed.item(itemOptions);
itemOptions
  • title string Title of this particular item.
  • description string Content for the item. Can contain html but link and image urls must be absolute path including hostname.
  • url url string Url to the item. This could be a blog entry.
  • 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.
  • 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 except on multi-author blogs.
  • date Date object or date string The date and time of when the item was created. Feed readers use this to determine the sort order. Some readers will also use it to determine if the content should be presented as unread.
  • lat optional number The latitude coordinate of the item.
  • long optional number The longitude coordinate of the item.
  • custom_elements optional array Put additional elements in the item (node-xml syntax)
  • enclosure optional object An enclosure object
    /* enclosure takes url or file key for the enclosure object
    
      url:  _required_ url to file object (or file)
      file: _required_ path to binary file (or url)
      size: _optional_ size of the file
      type: _optional_ if not provided the mimetype will be guessed
                       based on the extension of the file or url,
                       passing type to the enclosure will override the guessed type
    */
    
    {
      'url'  : 'http://www.example.com/path/to/image',
      'size' : 1668, //
      'type' : 'image/jpeg'
    }
Feed XML
var xml = feed.xml({indent: true});

This returns the XML as a string.

indent optional boolean or string What to use as a tab. Defaults to no tabs (compressed). For example you can use '\t' for tab character, or ' ' for two-space tabs. If you set it to true it will use four spaces.

Example Usage

var RSS = require('rss');

/* lets create an rss feed */
var feed = new RSS({
    title: 'title',
    description: 'description',
    feed_url: 'http://example.com/rss.xml',
    site_url: 'http://example.com',
    image_url: 'http://example.com/icon.png',
    docs: 'http://example.com/rss/docs.html',
    managingEditor: 'Dylan Greene',
    webMaster: 'Dylan Greene',
    copyright: '2013 Dylan Greene',
    language: 'en',
    categories: ['Category 1','Category 2','Category 3'],
    pubDate: 'May 20, 2012 04:00:00 GMT',
    ttl: '60',
    custom_namespaces: {
      'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'
    },
    custom_elements: [
      {'itunes:subtitle': 'A show about everything'},
      {'itunes:author': 'John Doe'},
      {'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store'},
      {'itunes:owner': [
        {'itunes:name': 'John Doe'},
        {'itunes:email': '[email protected]'}
      ]},
      {'itunes:image': {
        _attr: {
          href: 'http://example.com/podcasts/everything/AllAboutEverything.jpg'
        }
      }},
      {'itunes:category': [
        {_attr: {
          text: 'Technology'
        }},
        {'itunes:category': {
          _attr: {
            text: 'Gadgets'
          }
        }}
      ]}
    ]
});

/* loop over data and add to feed */
feed.item({
    title:  'item title',
    description: 'use this for the content. It can include html.',
    url: 'http://example.com/article4?this&that', // link to the item
    guid: '1123', // optional - defaults to url
    categories: ['Category 1','Category 2','Category 3','Category 4'], // optional - array of item categories
    author: 'Guest Author', // optional - defaults to feed author property
    date: 'May 27, 2012', // any format that js Date can parse.
    lat: 33.417974, //optional latitude field for GeoRSS
    long: -111.933231, //optional longitude field for GeoRSS
    enclosure: {url:'...', file:'path-to-file'}, // optional enclosure
    custom_elements: [
      {'itunes:author': 'John Doe'},
      {'itunes:subtitle': 'A short primer on table spices'},
      {'itunes:image': {
        _attr: {
          href: 'http://example.com/podcasts/everything/AllAboutEverything/Episode1.jpg'
        }
      }},
      {'itunes:duration': '7:04'}
    ]
});

// cache the xml to send to clients
var xml = feed.xml();

Notes

  • You do not need to escape anything. This module will escape characters when necessary.
  • This module is very fast but you might as well cache the output of xml() and serve it until something changes.

Inspiration

I started this module years ago (April 2011) because there weren't any Node modules for creating RSS. Nearly 50 modules use RSS, as well as many web sites and the popular Ghost publishing platform.

Contributing

Contributions to the project are welcome. Feel free to fork and improve. I do my best accept pull requests in a timely manor, especially when tests and updated docs are included.

About the Author

Hi! Thanks for checking out this project! My name is Dylan Greene. When not overwhelmed with my two young kids I enjoy contributing to the open source community. I'm also a tech lead at Opower. @dylang @dylang

Here's some of my other Node projects:

Name Description npm Downloads
npm‑check Check for outdated, incorrect, and unused dependencies. npm-check
grunt‑notify Automatic desktop notifications for Grunt errors and warnings. Supports OS X, Windows, Linux. grunt-notify
shortid Amazingly short non-sequential url-friendly unique id generator. shortid
grunt‑prompt Interactive prompt for your Grunt config using console checkboxes, text input with filtering, password fields. grunt-prompt
xml Fast and simple xml generator. Supports attributes, CDATA, etc. Includes tests and examples. xml
changelog Command line tool (and Node module) that generates a changelog in color output, markdown, or json for modules in npmjs.org's registry as well as any public github.com repo. changelog
space‑hogs Discover surprisingly large directories from the command line. space-hogs
observatory Beautiful UI for showing tasks running on the command line. observatory
captionbot Get captions for image using Microsoft's CaptionBot 🤖 captionbot
grunt‑attention Display attention-grabbing messages in the terminal grunt-attention
what‑dog Get the breed of a dog from an image using Microsoft's what-dog. what-dog
anthology Module information and stats for any @npmjs user anthology
random‑puppy Get a random imgur image url, by default a puppy. random-puppy
grunt‑cat Echo a file to the terminal. Works with text, figlets, ascii art, and full-color ansi. grunt-cat

This list was generated using anthology.

License

Copyright (c) 2017 Dylan Greene, contributors.

Released under the MIT license.

Screenshots are CC BY-SA (Attribution-ShareAlike).


Generated using grunt-readme with grunt-templates-dylang on Wednesday, January 11, 2017. _To make changes to this document look in /templates/readme/

node-rss's People

Contributors

alexjorgef avatar andris9 avatar dermidgen avatar dylang avatar erisds avatar evantill avatar iamstarkov avatar jasonkarns avatar kemitchell avatar langmi avatar maxnowack avatar mithgol avatar renovate-bot avatar renovate[bot] avatar soluml avatar xdamman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-rss's Issues

attribute of custom element

I am trying to write the following:

<media:content url="https://s3.amazonaws.com/dropbox/input/channeldemo/GO/BEEER-nPtMH.mp4">
<media:thumbnail>https://i.ytimg.com/vi/nPtMHSYtPc4/hqdefault.jpg</media:thumbnail>
<media:provider>bugm3n0t1000</media:provider>
<media:subtitle/>
<media:categories>Comedy</media:categories>
<media:tags>beer</media:tags>
<media:duration>12</media:duration>
<media:rating>4.98665046692</media:rating>
<media:likes>7466</media:likes>
<media:dislikes>25</media:dislikes>
</media:content>

However, using the code below I can't seem to add the attribute to media:content. Instead I have to place it on another element.

        custom_elements: [
        {
            'media:content':
            [
              {'media:url': {
                _attr: {
                  url: s3InputBucket + '/' + CHANNEL_FOLDER_NAME + '/' + info._filename
                }
              }},

Retrieving XML from an RSS feed

I think this would be the perfect place to ask this RSS community for suggestions on retrieving the XML from an RSS feed via a url. I have used rss-parser and xml-js but I think these options fail in retrieving the XML from the url of the RSS feed. Any suggestions?

Or would there be a way of accomplish this using node-rss?

Atom support

I'm looking forward to atom support.

Could you reply on this issue, when the module supports atom?

I'm also working on a atom library (pvorb/node-atomize) that has pretty much the same goal for atom feeds. Maybe we should join forces?

confusing documentation: first time running app fails

maybe you can help me understand how to fix this

screen shot 2015-01-08 at 6 22 36 pm

running app.js:

var RSS = require('rss');

/* lets create an rss feed */
var feed = new RSS({
    title: 'title',
    description: 'description',
    feed_url: 'http://example.com/rss.xml',
    site_url: 'http://example.com',
    image_url: 'http://example.com/icon.png',
    docs: 'http://example.com/rss/docs.html',
    managingEditor: 'Dylan Greene',
    webMaster: 'Dylan Greene',
    copyright: '2013 Dylan Greene',
    language: 'en',
    categories: ['Category 1','Category 2','Category 3'],
    pubDate: 'May 20, 2012 04:00:00 GMT',
    ttl: '60',
    customNamespaces: {
      'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'
    },
    custom: [
      {'itunes:subtitle': 'A show about everything'},
      {'itunes:author': 'John Doe'},
      {'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store'},
      {'itunes:owner': [
        {'itunes:name': 'John Doe'},
        {'itunes:email': '[email protected]'}
      ]},
      {'itunes:image': {
        _attr: {
          href: 'http://example.com/podcasts/everything/AllAboutEverything.jpg'
        }
      }},
      {'itunes:category': [
        {_attr: {
          text: 'Technology'
        }},
        {'itunes:category': {
          _attr: {
            text: 'Gadgets'
          }
        }}
      ]}
    ]
});

/* loop over data and add to feed */
feed.item({
    title:  'item title',
    description: 'use this for the content. It can include html.',
    url: 'http://example.com/article4?this&that', // link to the item
    guid: '1123', // optional - defaults to url
    categories: ['Category 1','Category 2','Category 3','Category 4'], // optional - array of item categories
    author: 'Guest Author', // optional - defaults to feed author property
    date: 'May 27, 2012', // any format that js Date can parse.
    lat: 33.417974, //optional latitude field for GeoRSS
    long: -111.933231, //optional longitude field for GeoRSS
    enclosure: {url:'...', file:'path-to-file'}, // optional enclosure
    custom: [
      {'itunes:author': 'John Doe'},
      {'itunes:subtitle': 'A short primer on table spices'},
      {'itunes:image': {
        _attr: {
          href: 'http://example.com/podcasts/everything/AllAboutEverything/Episode1.jpg'
        }
      }},
      {'itunes:duration': '7:04'}
    ]
});

// cache the xml to send to clients
var xml = feed.xml();

Using custom elements

I am generating a podcast RSS feed for iTunes and I want to use a custom element like <itunes:author> and other elements listed here. Is there a way to easily do this?

If additional functionality is needed, I would be happy to write the code and make a PR.

This will be used in rss middleware for @assemble.

Author element on channel fails validation

In the example code in the Readme.md, you show an author element on the "feed" which generates an author sub-element on channel.

If you set the author property on the feed, but not when generating items (optional), it outputs an author element on channel in addition to the generator element on channel and is missing from the item. If you then try to validate that feed with an online tool, it complains about the author element on channel.

http://feedvalidator.org
http://www.rssboard.org/rss-specification#requiredChannelElements

rss feed not handling html anchor tags properly

I generated a podcast RSS feed using a module derived from node-rss. The feed works fine in general. But the text content I have within the content:encoded includes some html, especially url links wrapped in tag. And those are not being recognized by iTunes. Here is the xml for one item in my feed

        <item>
          <title><![CDATA[How To Read People's Energy In 3 Seconds, Ep 18]]></title>
          <description><![CDATA[some words...<p>Subscribe to The True Voyage: A Soundcast For The Journey Within on <a href="https://mysoundwise.com/soundcasts/1508293913676s">Soundwise</a></p>]]></description>
          <link>https://mysoundwise.com/episodes/1517178943974e</link>
          <guid isPermaLink="true">https://mysoundwise.com/episodes/1517178943974e</guid>
          <category><![CDATA[Self-Help]]></category>
          <category><![CDATA[Spirituality]]></category>
          <category><![CDATA[Philosophy]]></category>
          <dc:creator><![CDATA[Natasha Che]]></dc:creator>
          <pubDate>Sun, 28 Jan 2018 22:45:08 GMT</pubDate>
          <enclosure url="https://website.com/audiofile.mp3" length="0" type="audio/mpeg"/>
          <content:encoded><![CDATA[some words...<p>Subscribe to <a href="https://mysoundwise.com/soundcasts/1508293913676s">The True Voyage: A Soundcast For The Journey Within</a> on <a href="https://mysoundwise.com/soundcasts/1508293913676s">Soundwise</a></p>]]></content:encoded>
          <itunes:author>Natasha Che</itunes:author>
          <itunes:subtitle>How To Read People&apos;s Energy In 3 Seconds, Ep 18</itunes:subtitle>
          <itunes:summary>some words...Subscribe to &lt;a href=&quot;https://mysoundwise.com/soundcasts/1508293913676s&quot;&gt;The True Voyage: A Soundcast For The Journey Within&lt;/a&gt; on &lt;a href=&quot;https://mysoundwise.com/soundcasts/1508293913676s&quot;&gt;Soundwise&lt;/a&gt;&lt;/p&gt;</itunes:summary>
          <itunes:explicit>No</itunes:explicit>
          <itunes:duration>1177</itunes:duration>
          <itunes:image href="https://website.com/image.jpg"/>
          <itunes:title>How To Read People&apos;s Energy In 3 Seconds, Ep 18</itunes:title>
        </item>

It seems iTunes is rendering the content in content:encoded in their episode description. But the url links are not being recognized for some reason. I used

            customElements: [
              {
                'content:encoded':
                  {
                    _cdata: 'some string including html tags'
                  }
              }
            ]

for the content:encoded element. It looks correct to me. Not sure why the anchor tags are not being picked up by iTunes.

Doesn't seem towrite non-standard fields

My feed contains non-standard fields such as mediavalue. They aren't written in the feed by default. Should I inject them in a namespace and if so, which, and how?

Error at install

When installing, gets error: error: no type named 'GCPrologueCallback' in 'v8::Isolate'

Plus 5 deprecations warnings.

What is libxmljs is no longer compatible with?

feed.item errors when passed directly to Array.prototype.forEach

I have a static site generator which, shockingly, is using node-rss to output RSS feeds.

This code runs successfully:

file.data.posts.map(function(post) {
	return {
		title: post.title,
		url: urlPrefix + file.relative,
		categories: post.categories,
		// TODO: normalize URLs to absolute URLs
		// See the `rss` docs for details
		description: post.contents,
		date: new Date(post.time.epoch * 1000)
	};
}).forEach(function(item) {
	feed.item(item);
});

As I'm sure you've guessed, file.data.posts is an array of posts. All that this does is map each post in to a node-rss-compatible item object and then call .item() on each object.

This code is theoretically functionally equivalent:

file.data.posts.map(function(post) {
	return {
		title: post.title,
		url: urlPrefix + file.relative,
		categories: post.categories,
		// TODO: normalize URLs to absolute URLs
		// See the `rss` docs for details
		description: post.contents,
		date: new Date(post.time.epoch * 1000)
	};
}).forEach(feed.item);

but it fails with TypeError: Cannot read property 'items' of undefined. Note that feed.item is being passed directly into forEach - presumably this is mangling this somehow, causing the error.

Here's the full stack trace:

/Users/alex/Development/github/strugee.github.com/node_modules/rss/lib/index.js:179
        this.items.push(item);
            ^

TypeError: Cannot read property 'items' of undefined
    at RSS.item (/Users/alex/Development/github/strugee.github.com/node_modules/rss/lib/index.js:179:13)
    at Array.forEach (native)
    at DestroyableTransform._transform (/Users/alex/Development/github/strugee.github.com/node_modules/stratic-indexes-to-rss/index.js:62:6)
    at DestroyableTransform.Transform._read (/Users/alex/Development/github/strugee.github.com/node_modules/readable-stream/lib/_stream_transform.js:159:10)
    at DestroyableTransform.Transform._write (/Users/alex/Development/github/strugee.github.com/node_modules/readable-stream/lib/_stream_transform.js:147:83)
    at doWrite (/Users/alex/Development/github/strugee.github.com/node_modules/readable-stream/lib/_stream_writable.js:313:64)
    at writeOrBuffer (/Users/alex/Development/github/strugee.github.com/node_modules/readable-stream/lib/_stream_writable.js:302:5)
    at DestroyableTransform.Writable.write (/Users/alex/Development/github/strugee.github.com/node_modules/readable-stream/lib/_stream_writable.js:241:11)
    at DestroyableTransform.ondata (/Users/alex/Development/github/strugee.github.com/node_modules/readable-stream/lib/_stream_readable.js:531:20)
    at emitOne (events.js:96:13)

I'm on [email protected], [email protected].

Needs release tags and changelog

Would love to see GitHub Releases used, or at the very least, git tags applied to past (and future) releases. And a changelog file or summary of changes as part of GH Releases

How to add new items to existing feed?

Newbie question here: how do you add new items to a feed that's created earlier? After creating a feed link with initial setups, how do you add new items to it at a later date? Can you retrieve the feed object with the cached xml somehow?

Item's not rendered within feed

            var feed = feedCreator.create({
                title: 'mysite',
                description: 'RSS akışı',
                url: 'http://www.mysite.com/feed/'
            });

            _.each(juices, function (juice) {
                feed.item({
                    title: juice.name,
                    description: juice.descripton,
                    url: util.format('http://www.mysite.com/likit/'),
                    date: juice.createdAt
                });
            });

            res.send(feed.xml());

output;

<?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[BuharMetre.com]]></title><description><![CDATA[BuharMetre.com RSS akışı]]></description><link>http://www.buharmetre.com</link><image><url>http://www.buharmetre.com/images/logo/logo.png</url><title>BuharMetre.com</title><link>http://www.buharmetre.com</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 09 May 2016 08:57:43 GMT</lastBuildDate><atom:link href="http://www.buharmetre.com/feed/" rel="self" type="application/rss+xml"/><pubDate>Mon, 09 May 2016 08:57:43 GMT</pubDate><copyright><![CDATA[© 2016 BuharMetre.com]]></copyright><language><![CDATA[tr]]></language><managingEditor><![CDATA[BuharMetre.com]]></managingEditor><webMaster><![CDATA[BuharMetre.com]]></webMaster><ttl>60</ttl><category><![CDATA[Likit]]></category></channel></rss>

So my added items are not added to feed and I'm sure that the query has items.

Enclosure Item looks for "size" and not length.

If I do a passthrough of this RSS enclosure element:

<enclosure url="http://example.com/file.mp3" length="5242880" type="audio/mpeg"/>

using this code:

    if (item.enclosures && Array.isArray(item.enclosures)){
        item.enclosures.forEach(function(enclosure){
            if (enclosure.type === 'audio/mpeg') {
                itemOptions.enclosure = enclosure;
            }
         }
    }

I get

<enclosure url="http://example.com/file.mp3" length="0" type="audio/mpeg"/>

"size" isn't the normal field name: https://en.wikipedia.org/wiki/RSS_enclosure

Language not making it's way to RSS

I've read the readmes and examples to make an aggregate podcast feed composed of several other podcasts. Everything works as intended, but iTunes will not validate my feed because the language is missing. I have tried "language": "en" or "language": "en-us" right beneath my description in my feed config, but it never makes it way over to the RSS feed.

Any guidance for me?

Enclosure Support

I need support for adding an enclosure to my feed like a podcast. I may take a stab at this later.

Btw, thanks for sharing this nifty module! It's almost exactly what I needed :)

output rss :(

node -v
v0.10.20

cd ~/lib/node_modules
npm install mocha chai rss

$ npm test

[email protected] test /home/user/lib/node_modules/rss
./node_modules/.bin/mocha --reporter spec

rss module
✓ should work with an empty feed
✓ should work with an easy test
✓ should work without image_url
✓ should work with an enclosure
✓ should work with geoRSS

5 passing (71ms)

$ npm test

[email protected] test /home/user/lib/node_modules/rss/node_modules/xml
./node_modules/.bin/mocha --reporter spec

xml module
✓ can be have no elements
✓ works with simple options
✓ works with deeply nested objects
✓ indents property
✓ supports xml attributes
✓ supports cdata
✓ supports encoding
✓ supports stream interface

8 passing (66ms)

create a script rss.new.js

var RSS = require('rss');

var feed = new RSS({
title: 'title',
description: 'description',
feed_url: 'http://example.com/rss.xml',
site_url: 'http://example.com',
});

feed.item({
title: 'item title',
description: 'use this for the content. It can include html.',
url: 'http://example.com/article4?this&that',
date: 'May 27, 2012'
});

var xml = feed.xml();

check

$ node rss.new.js
no output file and does not create a rss :(

$ node rss.new.js > my_app_log.log 2> my_app_err.log
in the log is empty :(
no network activity :(

Please give a working script for verification.

No CDATA

Is it possible to create XML without a CDATA?

Inoreader does not recognize rss

When I use node-rss to generate RSS, the generated RSS can not be recognized by Inoreader. Here's my code:

  let feed = new RSS({
    title: username,
    description: `${username}/${reposName}'s issue`,
    feed_url: `https://${SELF_DOMAIN}/${encodeURIComponent(url)}/feed`,
    site_url: url
  })

  issues.forEach((issue, index) => feed.item({
      title: issue.title,
      description: issue.description, 
      url: url,
      author: issue.author,
      date: issue.date,
      guid: issue.guid
    })
  )

  return feed.xml()

But can be detected on validator.w3.org/feed. My code is also written in accordance with the demo given on README. Here is my RSS content.

<?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[mrcodehang]]></title>
        <description><![CDATA[mrcodehang/blog-comment's issue]]></description>
        <link>https://github.com/mrcodehang/blog-comment/issues</link>
        <generator>RSS for Node</generator>
        <lastBuildDate>Fri, 12 May 2017 08:49:06 GMT</lastBuildDate>
        <atom:link href="https://rss.mrcodex.com/https%3A%2F%2Fgithub.com%2Fmrcodehang%2Fblog-comment%2Fissues/feed" rel="self" type="application/rss+xml" />
        <item>
            <title><![CDATA[以通俗的方式理解关键渲染路径]]></title>
            <description><![CDATA[<p><a href="https://blog.mrcodex.com/learn-the-critical-render-path-is-easy/">https://blog.mrcodex.com/learn-the-critical-render-path-is-easy/</a></p>
]]></description>
            <link>https://github.com/mrcodehang/blog-comment/issues</link>
            <guid isPermaLink="false">2017-04-07T18:27:32Z</guid>
            <dc:creator><![CDATA[mrcodehang]]></dc:creator>
            <pubDate>Fri, 07 Apr 2017 18:27:32 GMT</pubDate>
        </item>
        <item>
            <title><![CDATA[React的10种设计模式]]></title>
            <description><![CDATA[<p><a href="https://blog.mrcodex.com/react-ten-design-pattern/">https://blog.mrcodex.com/react-ten-design-pattern/</a></p>
]]></description>
            <link>https://github.com/mrcodehang/blog-comment/issues</link>
            <guid isPermaLink="false">2017-04-06T17:18:35Z</guid>
            <dc:creator><![CDATA[mrcodehang]]></dc:creator>
            <pubDate>Thu, 06 Apr 2017 17:18:35 GMT</pubDate>
        </item>
        <item>
            <title><![CDATA[成为一名认证"老司机"]]></title>
            <description><![CDATA[<p><a href="https://blog.mrcodex.com/become-a-authenticate-old-driver/">https://blog.mrcodex.com/become-a-authenticate-old-driver/</a></p>
]]></description>
            <link>https://github.com/mrcodehang/blog-comment/issues</link>
            <guid isPermaLink="false">2017-04-06T17:11:22Z</guid>
            <dc:creator><![CDATA[mrcodehang]]></dc:creator>
            <pubDate>Thu, 06 Apr 2017 17:11:22 GMT</pubDate>
        </item>
        <item>
            <title><![CDATA[JS函数式浅析]]></title>
            <description><![CDATA[<p><a href="https://blog.mrcodex.com/javascript-functional-programming-analysis/">https://blog.mrcodex.com/javascript-functional-programming-analysis/</a></p>
]]></description>
            <link>https://github.com/mrcodehang/blog-comment/issues</link>
            <guid isPermaLink="false">2017-04-11T04:08:48Z</guid>
            <dc:creator><![CDATA[mrcodehang]]></dc:creator>
            <pubDate>Thu, 06 Apr 2017 17:10:09 GMT</pubDate>
        </item>
        <item>
            <title><![CDATA[find-github-star 开发历程~]]></title>
            <description><![CDATA[<p><a href="https://blog.mrcodex.com/find-github-star-developer-road/">https://blog.mrcodex.com/find-github-star-developer-road/</a></p>
]]></description>
            <link>https://github.com/mrcodehang/blog-comment/issues</link>
            <guid isPermaLink="false">2017-04-06T16:53:58Z</guid>
            <dc:creator><![CDATA[mrcodehang]]></dc:creator>
            <pubDate>Thu, 06 Apr 2017 16:52:13 GMT</pubDate>
        </item>
        <item>
            <title><![CDATA[find-github-star 开发历程~]]></title>
            <description><![CDATA[<p><a href="https://blog.mrcodex.com/find-github-star-developer-road/">https://blog.mrcodex.com/find-github-star-developer-road/</a></p>
]]></description>
            <link>https://github.com/mrcodehang/blog-comment/issues</link>
            <guid isPermaLink="false">2017-04-06T16:51:46Z</guid>
            <dc:creator><![CDATA[mrcodehang]]></dc:creator>
            <pubDate>Thu, 06 Apr 2017 16:51:46 GMT</pubDate>
        </item>
    </channel>
</rss>

how to add media:content?

There doesn't seem to be a way to add media:content

<media:content url="https://thedailyshitter.com/content/images/2020/03/money-business-material-cash-bank-currency-629802-pxhere.com-2-.jpg" medium="image"/>

Error: ENOENT: no such file or directory, stat 'path-to-file'

Hi,

I am getting this error, running the sample from the readme:

fs.js:940
binding.stat(pathModule._makeLong(path));
^

Error: ENOENT: no such file or directory, stat 'path-to-file'
at Object.fs.statSync (fs.js:940:11)
at getSize (/Users/esteban/Desktop/feed/node_modules/rss/lib/index.js:28:15)
at /Users/esteban/Desktop/feed/node_modules/rss/lib/index.js:89:61
at Array.forEach (native)
at generateXML (/Users/esteban/Desktop/feed/node_modules/rss/lib/index.js:63:16)
at RSS.xml (/Users/esteban/Desktop/feed/node_modules/rss/lib/index.js:185:17)
at Object. (/Users/esteban/Desktop/feed/rss.js:72:16)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)

Node Version 8.0.0, "rss": "^1.2.2", OpSystem: Sierra OS.

Error line: var xml = feed.xml();

Any ideas?

Thanks,

Esteban

readme.md - managingEditor/author/webMaster should be email addresses

https://validator.w3.org/feed/docs/rss2.html specifies

managingEditor - Email address for person responsible for editorial content.
webMaster - Email address for person responsible for technical issues relating to channel.
author - Email address of the author of the item. ( https://validator.w3.org/feed/docs/rss2.html#ltauthorgtSubelementOfLtitemgt )

A list of valid formats for email addresses is included here https://validator.w3.org/feed/docs/error/InvalidContact.html

Therefore I'd say the examples should be changed, as well as the documentation of the fields so as to specify that you should enter an email address.


I learned this by using the w3org rss feed validator https://validator.w3.org/feed


Ah, this is also a more general version of #30

1.2.0 released?

Hi there, npm is reporting a version 1.2.0 published yesterday: 1.2.0': '2015-10-14T01:52:13.044Z, however the package.json file still says 1.1.1 in master & there is no tag in the repo, so it's not possible for services like david-dm to tell us what has changed.

Is this missing or is 1.2.0 a mistake?

Feed doesn’t validate in itunes - itunes:category should have a self closing tag

Thanks for this library, it’s great.

However, according to the Apple docs, for a feed to validate on itunes podcasts the itunes:category tag should be self closing:

<itunes:category text="History" />

But node-rss produces:

<itunes:category text="History"> </itunes:category>

So the feed doesn’t validate on itunes.

Is there a way to specify the feed options so as to get the self closing tag version?

Updated - Here is the config I am using:

{'itunes:category': [
{_attr: {
text: ‘History'
}}
]}

RSS item link not outputting

Using the following code, I am not getting the link elements outputted in the RSS xml. I have confirmed that all of the object variables have data in them. Let me know what needs to be changed to output the link for items.

if(format=='rss'){
var feed = new rss({
title: 'Local Headlines for ' + mkt.name,
feed_url: 'http://www.newsqast.net/news/' + mkt.id + '.rss',
site_url: 'http://www.newsqast.net',
image_url: 'http://www.newsqast.net/images/nqicon.png',
author: 'NewsQast'
});
for (var m = 0; m < mkt.items.length; m++) {
feed.items.push({
title: mkt.items[m].channel.item.title,
description: mkt.items[m].channel.item.description,
url: mkt.items[m].channel.item.link,
date: mkt.items[m].channel.item.pubDate
});
}
res.send(feed.xml());
}

Remove any script tags from generated feed xml

Hey! 👋

In my opinion node-rss should remove all script (e.g. iframe) tags from a generated feed, because some rss validators show the following warnings/recommendations:

content:encoded should not contain iframe tag
description should not contain iframe tag

These warnings occur if you add custom_elements like

item.custom_elements.push({
  'content:encoded': {
    _cdata: "<iframe width="560" height="315" src="..." frameborder="0" allowfullscreen></iframe>"
  }
});

Refs https://validator.w3.org/feed/docs/warning/SecurityRisk.html

As this is a rule, it might be helpful for everybody. Let me know if you think that the caller should remove script tags by himself.

Add more fields to an item

Hi,

Love your lib. I'm needing to include more fields to each item. I have two options:

a) Make a fork, add the fields, and the logic to process them and send the pull request.

b) Make a fork, Build a way to iterate over the keys of the fields added, making the model of each item extensible.

Do you agree with these pull requests? With one? With both?

camel casing

some have _ some are camel. some of the main attributes are camel case, some are not. can we switch all to camel for cleanliness and sanity?

lib/posts.js
  251:4   error  Identifier 'feed_url' is not in camel case  camelcase
  252:4   error  Identifier 'site_url' is not in camel case  camelcase

Strings are not conforming to the RSS spec for valid chars.

The RSS spec specifies exactly which characters are considered valid in RSS:

#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]

At present, this library doesn't handle ensuring that the strings it outputs conform to the spec. This means that the RSS feeds that are generated can easily become broken. We're having this problem in Ghost, when users copy & paste data from elsewhere - things like form feed and other control characters are completely invisible, but cause the RSS feed to become invalid & unusable.

There is some interesting information around about fixing this sort of problem:

http://stackoverflow.com/questions/397250/unicode-regex-invalid-xml-characters
http://stackoverflow.com/questions/2670037/how-to-remove-invalid-utf-8-characters-from-a-javascript-string

And here's an example regex that I have been trying out for fixing the issue:

/(?![\u0009\u000a\u000d\u0020-\uD7FF\uE000-\uFFFD])./g

Here it is in action:

https://regex101.com/r/pQ7aB6/1

I have a branch with this implemented in Ghost, and it seems to work ok: ErisDS/Ghost@7acb3f9

This seems to work well, the only question is whether the regex is a bit too naive / slow / memory intensive for use in a library like node-rss?

I'd be happy to PR a fix to node-rss, but interested to get some feedback on the regex and whether a different approach might be better.

Create the RSS feed without a CDATA and without CDATA

@dylang,
Currently the modules support to generate the rss feed with cdata .
Example : title, description (both : 1. channel -> title , 2. channel ->item -> title).
But possible to generate with data for inside the channel and item tag's ?

<?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[Test]]></title> <description><![CDATA[test desc]]></description> <link>http://github.com/dylang/node-rss</link> <generator>hello</generator> <lastBuildDate>Mon, 16 Jul 2018 08:43:51 GMT</lastBuildDate> <pubDate>Sun, 20 May 2012 04:00:00 GMT</pubDate> <copyright><![CDATA[2018]]></copyright> <language><![CDATA[en-gb]]></language> <category><![CDATA[test]]></category> <item> <title><![CDATA[item title]]></title> <description><![CDATA[use this for the content. It can include html.]]></description> <link>http://example.com/article4?this&amp;that</link> <guid isPermaLink="false">1123</guid> <content:encoded><![CDATA[This is the long content. <b>This & That</b>]]></content:encoded> </item> </channel> </rss>

supports media:content

Is there already a way to use output media:content instead of the enclosure tags for the images?

Thanks

Generated XML does not validade as RSS

Hi!

I'm getting a validation error on a feed generated by this package.

According to the RSS spec, the element <channel> does not have an <author> attribute. Only <item> does (as of RSS 2.0) , and it's optional.

Can you confirm this?

No support for `content:encoded`

I was hoping to use this module to create a feed which includes HTML content. The module consuming this feed expects to find the full content inside a <content:encoded> tag. This seems to be in line with the spec but node-rss doesn't seem to support this and when I attempt to use custom elements it encodes the html.

Could you please consider adding support for <content:encoded> - maybe a new option to item()?

adding xmlns:webfeeds='...' attribute to rss tag

Hello, how can I add an additional xmlns:content attribute to the parent <rss> tag?

Example:

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:webfeeds="http://webfeeds.org/rss/1.0">

pubDate should not use .toGMTString()

  1. The function is officially deprecated
  2. There doesn't seem to be an "official" format of the pubDate field, and if there is, it's not widely supported / adopted. Some providers require pubDate be formatted according to rfc 2822.

Ideally, this library would let you specify a function for manipulating or setting the pubDate field.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.