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

Enables more fields on items besides default and more namespaces in XML RSS Header #6

Closed
wants to merge 7 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 1, 2012

Feature 1: Enables to add your custom fields on every item, since only default ones where parsed and included. Originally you can add just the following fields:

  title
  description
  url
  guid
  categories
  author
  date

To add more fields, just define them in the item creation, like this:

  feed.item({
              title:  'item 1',
              description: 'description 1',
              url: 'http://example.com/article1',
              date: 'May 24, 2012 04:00:00 GMT',
              'myClass:otherField': 'f06057b8b5877e75e7333074cc057e4d'
          });

Feature 2: Enables to add more namespace definitions into the XML RSS Header using the function xmlAddAttr (attrKey, attrValue). For example:

feed.xmlAddAttr('xmlns:myClass', 'http://www.example.com/myClass');

renders to:

<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" xmlns:myClass="http://www.example.com/myClass" version="2.0">

Running the tests

Step in the root of this module and run:

$ nodeunit test

You should get:

$ nodeunit test

test
✔ empty feed
✔ easy test
✔ easy test without image_url
✔ easy test without image_url with extra fields on items
✔ easy test without image_url with extra fields on items and an extra XML RSS Header

OK: 10 assertions (15ms)

(If you don't have nodeunit, do like below)

$ [sudo] npm install -g nodeunit

Regards!

Herman Junge

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants