Comparing version 0.1.4 to 0.2.0
129
lib/feed.js
@@ -26,3 +26,4 @@ var xml = require('xml'); | ||
description: options.description, | ||
date: options.date | ||
date: options.date, | ||
image: options.image | ||
}; | ||
@@ -57,2 +58,4 @@ | ||
// Atom 1.0 [application/atom+xml] | ||
// | ||
// - Reference: http://www.atomenabled.org/developers/syndication/ | ||
// ============================================================================ | ||
@@ -62,44 +65,97 @@ | ||
var items = [], | ||
container = []; | ||
container = [], | ||
feed = [], | ||
var entries = options.items; | ||
var categories = options.categories; | ||
var author = options.author; | ||
entries = options.items, | ||
categories = options.categories, | ||
author = options.author, | ||
d = new Date(); | ||
var doctype = '<?xml version="1.0" encoding="utf-8"?>\n'; | ||
var d = new Date(); | ||
container.push({ feed: [] }); | ||
container[0].feed.push({ _attr: { xmlns: 'http://www.w3.org/2005/Atom' }}); | ||
container.push({ feed: feed }); | ||
feed.push({ _attr: { xmlns: 'http://www.w3.org/2005/Atom' }}); | ||
/************************************************************************** | ||
* "feed" node: REQUIRED elements | ||
*************************************************************************/ | ||
feed.push({ title: options.title }); | ||
feed.push({ id: options.link }); | ||
feed.push({ updated: RFC3339(d) }); // Auto-magic :) | ||
container[0].feed.push({ title: options.title }); | ||
container[0].feed.push({ subtitle: options.description }); | ||
container[0].feed.push({ id: options.link }); | ||
container[0].feed.push({ updated: RFC3339(d) }); | ||
/************************************************************************** | ||
* "feed" node: recommended elements | ||
*************************************************************************/ | ||
if(author) | ||
feed.push({ author: [ | ||
{ name: author.name }, | ||
{ email: author.email }, | ||
{ uri: author.link } | ||
]}); | ||
container[0].feed.push({ author: [ | ||
{ name: author.name }, | ||
{ email: author.email }, | ||
{ uri: author.link } | ||
]}); | ||
// link (relative link to feed) - will be added in a future version | ||
/************************************************************************** | ||
* "feed" node: optional elements | ||
*************************************************************************/ | ||
if(options.description) | ||
feed.push({ subtitle: options.description }); | ||
if(options.image) | ||
container[0].feed.push({ logo: options.image }); | ||
feed.push({ logo: options.image }); | ||
if(options.copyright) | ||
container[0].feed.push({ rights: options.copyright }); | ||
feed.push({ rights: options.copyright }); | ||
container[0].feed.push({ generator: generatorName }); | ||
feed.push({ generator: generatorName }); | ||
// Categories | ||
// Looping through categories (if any set!) | ||
for(var key in categories) { | ||
container[0].feed.push({ category: [{ _attr: { term: categories[key]}}] }); | ||
feed.push({ category: [{ _attr: { term: categories[key]}}] }); | ||
} | ||
// contributor | ||
// icon | ||
/************************************************************************** | ||
* "entry" nodes | ||
*************************************************************************/ | ||
for(key in entries) { | ||
container[0].feed.push({ entry: [ | ||
// | ||
// entry: required elements | ||
// | ||
var entry = [ | ||
{ title: { _cdata: entries[key].title }}, | ||
{ id: entries[key].link }, | ||
{ updated: RFC3339(entries[key].date) }, | ||
{ summary: { _cdata: entries[key].description }} | ||
]}); | ||
{ updated: RFC3339(entries[key].date) } | ||
]; | ||
// | ||
// entry: recommended elements | ||
// | ||
if(entries[key].description) | ||
entry.push({ summary: { _cdata: entries[key].description }}); | ||
// author | ||
// content | ||
// link - relative link to article | ||
// | ||
// entry: optional elements | ||
// | ||
// category | ||
// contributor | ||
// published | ||
// source | ||
// rights | ||
feed.push({ entry: entry }); | ||
} | ||
@@ -112,2 +168,4 @@ | ||
// Real Simple Syndication 2.0 (RSS 2.0) | ||
// | ||
// - Reference: http://feed2.w3.org/docs/rss2.html | ||
// ============================================================================ | ||
@@ -122,2 +180,3 @@ function rss_2_0(options) { | ||
var author = options.author; | ||
var d = new Date(); | ||
@@ -131,6 +190,7 @@ var doctype = '<?xml version="1.0" encoding="utf-8"?>\n'; | ||
// Required RSS 2.0 channel elements | ||
channel.push({ title: options.title }); | ||
channel.push({ description: options.description }); | ||
channel.push({ link: options.link }); | ||
channel.push({ author: author.email + ' (' + author.name + ')' }); | ||
channel.push({ title: options.title }); | ||
channel.push({ description: options.description }); | ||
channel.push({ link: options.link }); | ||
channel.push({ author: author.email + ' (' + author.name + ')' }); | ||
channel.push({ lastBuildDate: d.toUTCString() }) | ||
@@ -152,3 +212,3 @@ if(options.image) | ||
for(var key in items) { | ||
channel.push({ item: [ | ||
var item = [ | ||
{ title: { _cdata: items[key].title }}, | ||
@@ -158,3 +218,8 @@ { link: items[key].link }, | ||
{ description: { _cdata: items[key].description }} | ||
]}); | ||
]; | ||
if(items[key].image) | ||
item.push({ enclosure: [{ _attr: { url: items[key].image } }] }); | ||
channel.push({ item: item }); | ||
} | ||
@@ -161,0 +226,0 @@ |
{ | ||
"name": "feed", | ||
"version": "0.1.4", | ||
"description": "Feed is the simplest content syndication wrapper, letting you generate Atom 1.0 and RSS 2.0 feeds in no time!", | ||
"homepage": "https://github.com/jpmonette/feed", | ||
"version": "0.2.0", | ||
"description": "Feed is a RSS and Atom feed generator for Node.js, making content syndication simple, intuitive and performant!", | ||
"homepage": "http://projets.jpmonette.net/en/feed", | ||
"author": "Jean-Philippe Monette <contact@jpmonette.net>", | ||
@@ -32,2 +32,5 @@ | ||
"os" :[], | ||
"cpu" : [], | ||
"repository": { | ||
@@ -34,0 +37,0 @@ "type": "git", |
# Feed for Node.js | ||
**Feed for Node.js** is the simplest content syndication wrapper, letting you generate Atom 1.0 and RSS 2.0 feeds in no time! | ||
[Feed](http://projets.jpmonette.net/en/feed) is a *RSS 2.0* and *Atom 1.0* generator for **Node.js**, making content syndication simple, intuitive and performant! | ||
@@ -15,2 +15,3 @@ ## Installation | ||
* Support for Atom 1.0 and RSS 2.0 | ||
* Lightweight - Only 1 dependency! | ||
@@ -51,3 +52,4 @@ ## Quick Start | ||
description: posts[key].description, | ||
date: posts[key].date | ||
date: posts[key].date, | ||
image: posts[key].image | ||
}); | ||
@@ -71,4 +73,17 @@ } | ||
## Additional information | ||
## More Information | ||
This module is still a work in progress. If you have any suggestion, feel free to send me a message or a pull request :)! | ||
* [Feed for Node.js](http://projets.jpmonette.net/en/feed) (English) | ||
* [Feed pour Node.js](http://projets.jpmonette.net/feed) (French) | ||
* Follow [@jpmonette](https://twitter.com/jpmonette) on Twitter for updates | ||
* Read my personal blog [Blogue de Jean-Philippe Monette](http://blogue.jpmonette.net/) to learn more about what I do! | ||
## License | ||
Copyright (C) 2013, Jean-Philippe Monette <contact@jpmonette.net> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
10738
5
0
178
86
2