added parsing of image_url and test

This commit is contained in:
langmi
2012-03-04 18:00:38 +01:00
parent c219a1efdd
commit 01a2027053
3 changed files with 60 additions and 11 deletions

View File

@@ -48,13 +48,17 @@ function ifTruePush(bool, array, data) {
function generateXML (data){
// todo: xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
var channel = [
{ title: { _cdata: data.title } },
{ description: { _cdata: data.description || data.title } },
{ link: data.site_url || 'http://github.com/dylan/node-rss' },
{ generator: 'NodeJS RSS Module' },
{ lastBuildDate: new Date().toGMTString() }
];
var channel = [];
channel.push({ title: { _cdata: data.title } });
channel.push({ description: { _cdata: data.description || data.title } });
channel.push({ link: data.site_url || 'http://github.com/dylan/node-rss' });
// image_url set?
if (data.image_url) {
channel.push({ image: [ {url: data.image_url}, {title: data.title}, {link: data.site_url} ] });
}
channel.push({ generator: 'NodeJS RSS Module' });
channel.push({ lastBuildDate: new Date().toGMTString() });
ifTruePush(data.feed_url, channel, { 'atom:link': { _attr: { href: data.feed_url, rel: 'self', type: 'application/rss+xml' } } });
// { updated: new Date().toGMTString() }