Example #1
0
        .exec( function(err, posts) {
          if (err) {
            res.status(500).end();
            console.warn('Failed to get posts for RSS feed ', err.stack);
            return;
          }

          var baseUrl = app.locals.baseUrl;

          var feed = new RSS({
            title: config.name,
            description: config.rss.description || '',
            feed_url: baseUrl + '/rss.xml',
            site_url: baseUrl,
            image_url: baseUrl + (config.rss.img || '/favicon.ico'),
            author: config.rss.author || config.name
          });

          for (var i=0; i<posts.length; i++) {
            var post = posts[i];
            feed.item({
              title:  post.title,
              description: post.body,
              url: baseUrl + '/post/' + post.slug,
              date: post.date
            });
          }

          res.setHeader('Content-Type', 'application/xml');
          res.end(feed.xml());
        });
Example #2
0
	ACS.Posts.query(qParams, function(data) {
		var xml = {};

		if (data && data.posts && data.posts.length) {
			var feed = new RSS({
				title : 'Toddler play',
				description : '<img alt="Toddler play" src="http://storage.cloud.appcelerator.com/O1PXfPqYupDDbuJMDvBNVOkXaMphOYCZ/photos/80/1d/51e5590d77b5c90ad734d654/carely_icon%402x_original.png" height="57" width="57"><b>Toddler play</b><p>Discover and share activities for your toddler:</p><ul><li>Follow one of the many activity lists: from finger puppets to creative crafts to outdoor activities</li><li>See photos of exciting activities and get inspired to try something new</li><li>Ask how-to questions and get helpful tips</li><li>Connect with friends and share your own activities</li></ul>',
				feed_url : req.originalUrl,
				site_url : 'http://care.ly/feature/toddlers/',
				image_url : 'http://storage.cloud.appcelerator.com/O1PXfPqYupDDbuJMDvBNVOkXaMphOYCZ/photos/80/1d/51e5590d77b5c90ad734d654/carely_icon%402x_original.png',
				docs : 'http://care.ly/feature/toddlers/',
				author : 'Toodler play',
				managingEditor : 'Toodler play',
				webMaster : 'Toodler play',
				copyright : '2013 Carely',
				language : 'en',
				categories : ['Category 1', 'Category 2', 'Category 3'],
				pubDate : 'May 20, 2012 04:00:00 GMT',
				ttl : '60'
			});

			for (var i = 0, v = data.posts.length; i < v; i++) {
				
				var feed_item = postsHelper.convertToRssItem(data.posts[i]);
				if(feed_item && feed_item.title){
					feed.item(feed_item);
				}
			}

			xml = feed.xml();
		}
		
		res.contentType('rss');
		res.send(xml);
	});
Example #3
0
exports.feed = function (req, res) {
    'use strict';
    var feed = new RSS({
        title: 'Why So Curious ?',
        description: 'The web is my scene, HTML5/CSS3 are my sound engineers, JS is my guitar, the web standards are my tablature and last but not least you might be my audience ;)',
        feed_url: 'http://thomasbelin.fr/feed',
        site_url: 'http://thomasbelin.fr',
        image_url: 'http://thomasbelin.fr/favicon.png',
        author: 'Thomas Belin'
    });

    /* loop over data and add to feed */
    for (var i = 0; i < req.posts.length; i++) {
        var post = req.posts[i];
        feed.item({
            title:  post.title,
            description: post.body,
            url: 'http://thomasbelin.fr/posts/' + post.slug, // link to the item
            author: 'Thomas Belin', // optional - defaults to feed author property
            date: post.pubdate // any format that js Date can parse.
        });
    }

    var xml = feed.xml();

    res.setHeader("Content-Type", "text/xml; charset=utf-8");
    res.send(xml);
};
Example #4
0
		googleResponse.on('close', function () {
			var data = JSON.parse(json);
			var feed = new rss({
				title: data['title'],
				feed_url: 'https://plus.google.com/u/0/' + userId + '/posts',
				site_url: 'https://plus.google.com',
				image_url: 'https://ssl.gstatic.com/s2/oz/images/faviconr.ico'
//				author: 'Dylan Greene'
			});
			for (var i in data['items']) {
				var item = data['items'][i];
				var obj = item['object'];
				var addLinks = '';
				if (obj['attachments']) {
					for (var j in obj['attachments']) {
						var url = obj['attachments'][j]['url'];
						addLinks += ' \u003ca href="' + url + '" \u003e' + url + '\u003c/a\u003e';
					}
				}
				feed.item({
					title:  item['title'],
					description: obj['content'] + addLinks,
					url: obj['url'],
					guid: item['id'],
					author: item['actor']['displayName'],
					date: item['published']
				});
			}
			response.end(feed.xml());
		});
Example #5
0
 posts.forEach((post) => {
     feed.item({
         title: post.title,
         url: siteDomain + '/' + post.url,
         description: post.rssSummary
     });
 });
Example #6
0
// Processes raw EAN RSS items and populates huamnized 'feed' RSS object.
function humanize_article(site, article){
    //Random number used to index into TWITTERPHRASES
	var randomNum = Math.floor((Math.random()*TWITTERPHRASES.length));
	var text = TWITTERPHRASES[randomNum];

    // Values to replace {deal} {location fields} in raw TWITTERPHRASES for an RSS item.
    var phraseValues = {
        location:article.title,
        deal:article.description,
        currency:"US$",
        duration: "a night"       
    };

    // Replaces {deal} {location} fields in TWITTERPHRASES. Polishes it to 'human' form.
    for (var idx in PHRASE_FIELDS)
    	text = text.replace(PHRASE_FIELDS[idx], phraseValues[idx]);
	
    // Appends to processed RSS.
    feed.item({
        title: article.title,
        description: text,
        url: article.link,
        author: site.author
    })
}
Example #7
0
File: rss.js Project: shipci/memo
  fs.readdir(rssDir, function (err, files) {
    files.sort(function (a, b) {
      return a > b ? -1 : 1;
    });

    for (var i = 0, l = files.length; i < l; i++) {
      var file = files[i];
      if (file.match(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})_(.*)/)) {
        var date = new Date();
        date.setTime(Date.UTC(RegExp.$1, RegExp.$2 - 1, RegExp.$3, RegExp.$4, RegExp.$5, RegExp.$6));

        var title = RegExp.$7 || '(No title)';
        var memo = path.join(rssDir, fs.readlinkSync(path.join(rssDir, file)));
        var url =  'http://' + req.headers.host + '/#/memos' + memo.replace(memoDir, '');
        var description = marked(fs.readFileSync(memo).toString());

        feed.item({
          title: title,
          description: description,
          url: url,
          author: rssConfig.author,
          date: date
        });

        if (feed.items.length >= 10) {
          break;
        }
      }
    }

    res.set('Content-Type', 'application/xml');
    // res.type('rss');
    res.send(feed.xml());
  });
Example #8
0
                    posts.forEach(function (post) {
                        var deferred = when.defer(),
                            item = {
                                title: post.title,
                                guid: post.uuid,
                                url: config.urlFor('post', {post: post, permalinks: permalinks}, true),
                                date: post.published_at,
                                categories: _.pluck(post.tags, 'name'),
                                author: post.author ? post.author.name : null
                            },
                            content = post.html;

                        //set img src to absolute url
                        content = content.replace(/src=["|'|\s]?([\w\/\?\$\.\+\-;%:@&=,_]+)["|'|\s]?/gi, function (match, p1) {
                            /*jslint unparam:true*/
                            p1 = url.resolve(siteUrl, p1);
                            return "src='" + p1 + "' ";
                        });
                        //set a href to absolute url
                        content = content.replace(/href=["|'|\s]?([\w\/\?\$\.\+\-;%:@&=,_]+)["|'|\s]?/gi, function (match, p1) {
                            /*jslint unparam:true*/
                            p1 = url.resolve(siteUrl, p1);
                            return "href='" + p1 + "' ";
                        });
                        item.description = content;
                        feed.item(item);
                        deferred.resolve();
                        feedItems.push(deferred.promise);
                    });
Example #9
0
 article.starredArticles(function (err, data) {
   var host = req.headers.host;
   var options = {
     title: host + " -  favourites",
     description: 'The favourite articles of '+host,
     feed_url: host+'/rss.xml',
     site_url: 'http://'+host,
     author: 'BirdReader',
     language: 'en'
   };
   var feed = new RSS();
   for(var i in data) {
     var article = data[i];
     var item = {
       title : article.title,
       description: article.description,
       url: article.link,
       guid: article._id,
       author: article.feedName,
       date: article.pubDate
     }
     feed.item(item);
   }
   res.setHeader('Content-Type', 'application/rss+xml');
   res.send(feed.xml());
 });
Example #10
0
Glog.prototype.render_rss = function(options, articles, cb) {

    var feed = new rss({
        title    : options.blog_title,
        feed_url : (options.base_url || '') + '/rss.xml',
        site_url : (options.base_url || ''),
        author   : options.author
        }),
        len = articles.length, i;

   for(i=0;i<len;i++) {
    	//encode the URL in case of special chars 
		var xurl = '/'+encodeURIComponent(articles[i].url);
		xurl = xurl.replace('%2F',"/").replace('%2F',"/"); //but dont encode the slashes in the date!
		
        feed.item({
            title : articles[i].title,
            description : articles[i].body,
            url         : articles[i].url,
            author      : articles[i].author,
            date        : articles[i].date
        });
    }

    this.pages['rss'] = feed.xml();

    cb();

};
Example #11
0
                        post.url().then(function (postUrl) {
                            var item = {
                                    title:  _.escape(post.title),
                                    guid: post.uuid,
                                    url: siteUrl + postUrl,
                                    date: post.published_at,
                                    categories: _.pluck(post.tags, 'name')
                                },
                                content = post.html;

                            //set img src to absolute url
                            content = content.replace(/src=["|'|\s]?([\w\/\?\$\.\+\-;%:@&=,_]+)["|'|\s]?/gi, function (match, p1) {
                                /*jslint unparam:true*/
                                p1 = url.resolve(siteUrl, p1);
                                return "src='" + p1 + "' ";
                            });
                            //set a href to absolute url
                            content = content.replace(/href=["|'|\s]?([\w\/\?\$\.\+\-;%:@&=,_]+)["|'|\s]?/gi, function (match, p1) {
                                /*jslint unparam:true*/
                                p1 = url.resolve(siteUrl, p1);
                                return "href='" + p1 + "' ";
                            });
                            item.description = content;
                            feed.item(item);
                            deferred.resolve();
                        });
Example #12
0
                    posts.forEach(function (post) {
                        var item = {
                                title: post.title,
                                guid: post.uuid,
                                url: config.urlFor('post', {post: post, permalinks: permalinks}, true),
                                date: post.published_at,
                                categories: _.pluck(post.tags, 'name'),
                                author: post.author ? post.author.name : null
                            },
                            htmlContent = cheerio.load(post.html, {decodeEntities: false});

                        // convert relative resource urls to absolute
                        ['href', 'src'].forEach(function (attributeName) {
                            htmlContent('[' + attributeName + ']').each(function (ix, el) {
                                el = htmlContent(el);

                                var attributeValue = el.attr(attributeName);
                                attributeValue = url.resolve(siteUrl, attributeValue);

                                el.attr(attributeName, attributeValue);
                            });
                        });

                        item.description = htmlContent.html();
                        feed.item(item);
                    });
    .exec(function(err, posts) {
      if (err) throw err;
      var feed = new RSS({
        title: 'Planet Node JS',
        description: 'A node.js planet (blog aggregator)',
        feed_url: 'http://planetnodejs.com/feed',

        author: 'PlanetNodejs'
      });
      for (var i = 0; i < posts.length; i++) {
        
        feed.item({
          title:          posts[i].title,
          description:    posts[i].content,
          link:           posts[i].link,

          author: {
              name:       posts[i].author,
          },
          pubdate: posts[i].displayDate
        });
      };
      cb(feed.xml());
      console.log('RSS feed built');
    });
Example #14
0
function buildRSS(forceUpdate) {
  const episodes = util.getEpisodes();
  const latestUnixTime = util.getLatestUnixTime(episodes);
  const outPath = './docs/rss.xml';
  const templatePath = './src/template/rss.json';

  if (!forceUpdate) {
    if (!util.isNeedUpdate(outPath, [templatePath, latestUnixTime])) {
      return;
    }
  }

  const rssJSON = fs.readFileSync('./src/template/rss.json', {encode: 'utf8'});
  const rss = JSON.parse(rssJSON);
  const feed = new RSS(rss);

  for (let i = 0; i < episodes.length; i++) {
    const episode = episodes[i];
    const url = rss.site_url + '/' + episode.ep;
    feed.item({
      title: episode.ep + '. ' + episode.title,
      description: episode.text,
      url: url,
      guid: url,
      date: episode.date,
      enclosure: {url: episode.audio, type: 'audio/mpeg', size: episode.size},
      custom_elements: [
        {'itunes:duration': episode.time}
      ]
    });
  }

  fs.writeFileSync(outPath, feed.xml('  '), {encode: 'utf8'});
  console.log('rss.xml');
}
Example #15
0
Plankton.prototype.publishFeed = function(destDir, posts) {
    var feed = new RSS({
        title: defaults.BLOG_TITLE,
        description: defaults.BLOG_DESCRIPTION,
        feed_url: defaults.BLOG_URL + '/' + constants.FEED_FILE_NAME,
        site_url: defaults.BLOG_URL
    });

    for(var index in posts) {
        var post = posts[index];
        if(post[constants.FILETYPE_PROPERTY] != constants.MARKDOWN_EXTENSION) continue;

        feed.item({
            title:  post[constants.TITLE_PROPERTY],
            description: post[constants.BODY_PROPERTY],
            url: defaults.BLOG_URL + post[constants.PERMALINK_PROPERTY],
            author: post[constants.AUTHOR_PROPERTY],
            date: moment(post[constants.DATE_PROPERTY]).format()
        });
    }

    var xml = feed.xml();

    var feedXMLPath = path.join(destDir, constants.FEED_FILE_NAME);

    fs.writeFile(feedXMLPath, xml, function(err) {
        if(err) return console.error(err);
        console.log('Published site feed in ' + constants.FEED_FILE_NAME);
    });
}
Example #16
0
function createFeed(options, MESSAGES, items) {
  util.log("Create new feed");
  var desc = util.format(MESSAGES['feedDescription'], options.chatRoom) 
           + util.format(' [%s (%s)]', options.appName, options.appVersion);
  var feed = new RSS({
    title : MESSAGES['feedTitle'],
    description : desc,
    feed_url : options.feedUrl,
    site_url : options.siteUrl
  });

  for ( var i = items.length - 1; i >= 0; i--) {
    var item = items[i];
    
    var description = item.msg + ' [' + item.sender + ']'; 
    
    var title = description;
    if (title.length > MAX_PREVIEW_IN_TITLE - 3) {
      title = title.substring(0, MAX_PREVIEW_IN_TITLE - 3) + '...';
    }
    feed.item({
      author : item.sender,
      title : title,
      description : description,
      date : item.date,
      guid : item.id,
      url: options.siteUrl + '#' + item.id
    });
  }

  return feed.xml();
}
Example #17
0
    function (err, qres) {
      if (err) return next(err);
     
      var feed = new rss({
          title: req.host,
          description: 'блог одного программиста',
          feed_url: 'http://' + req.host + '/rss/main.rss',
          site_url: 'http://' + req.host,
          image_url: 'http://' + req.host + '/img/cocainum.jpg',
          author: 'Ilya Rogojin',
          pubDate: dateformat(new Date(), "fullDate"),
          ttl: '600'
      });

      for (i in qres) {
        feed.item({
          title:  qres[i].header,
          description: qres[i].text.replace(/(\<img\ [^>]*src=\")(\/images)/g,'$1http://' + req.host + '$2'),
          url: 'http://' + req.host + '/post/' + qres[i].blog_id + '/',
          date: qres[i].post_date
        });
      }

      res.end(feed.xml());
    });
Example #18
0
		categories.getCategoryById(cid, 0, function (err, categoryData) {
			if (err) return callback(new Error('category-invalid'));

			var feed = new rss({
				title: categoryData.category_name,
				description: categoryData.category_description,
				feed_url: Feed.defaults.baseUrl + '/categories/' + cid + '.rss',
				site_url: nconf.get('url') + 'category/' + categoryData.category_id,
				ttl: Feed.defaults.ttl
			}),
				topics = categoryData.topics,
				title, topicData, dateStamp;

			// Add pubDate if category has topics
			if (categoryData.topics.length > 0) feed.pubDate = new Date(parseInt(categoryData.topics[0].lastposttime, 10)).toUTCString();

			for (var i = 0, ii = topics.length; i < ii; i++) {
				topicData = topics[i];
				dateStamp = new Date(parseInt(topicData.lastposttime, 10)).toUTCString();
				title = topics[i].title;

				feed.item({
					title: title,
					url: nconf.get('url') + 'topic/' + topicData.slug,
					author: topicData.username,
					date: dateStamp
				});
			}

			Feed.saveFeed('feeds/categories/' + cid + '.rss', feed, function (err) {
				if (callback) callback();
			});
		});
Example #19
0
    build_feed: ['fetch_items', function(callback, results) {
      console.log("%s: Building feed", results.config.name);
      var meta = results.fetch_feed.meta,
          feedOut = new RSS({
            // author: 'Dylan Greene',
            title: meta.title,
            description: meta.description,
            site_url: meta.link,
            feed_url: results.config.url,
            // image_url: 'http://example.com/icon.png',
          });

      // Loop over each article in the source feed.
      for (var i = 0; i < results.fetch_feed.articles.length; i++) {
        // The HTML in fetch_items should be at the same index as but articles
        // that were skipped for some reason will have a false value so skip
        // over those here too.
        if (results.fetch_items[i]) {
          var article = results.fetch_feed.articles[i];
          feedOut.item({
            title: article.title,
            url: article.link,
            guid: article.guid,
            date: article.pubDate,
            description: results.fetch_items[i]
          });
        }
      }

      callback(null, feedOut);
    }]
Example #20
0
    generate: function (posts) {
        'use strict';
        var feed = new RSS({
                title: 'Why So Curious ?',
                description: 'The web is my scene, HTML5/CSS3 are my sound engineers, JS is my guitar, the web standards are my tablature and last but not least you might be my audience ;)',
                feed_url: 'http://thomasbelin.fr/feed',
                site_url: 'http://thomasbelin.fr',
                image_url: 'http://thomasbelin.fr/favicon.png',
                author: 'Thomas Belin'
            }),
            post,
            xml,
            i;

        /* loop over data and add to feed */
        for (i = 0; i < posts.length; i++) {
            post = posts[i];
            feed.item({
                title:  post.title,
                description: post.body,
                url: 'http://thomasbelin.fr/posts/' + post.slug, // link to the item
                author: 'Thomas Belin', // optional - defaults to feed author property
                date: post.pubdate // any format that js Date can parse.
            });
        }

        return feed.xml();
    }
Example #21
0
		topics.getTopicWithPosts(tid, 0, 0, -1, function(err, topicData) {
			if (err) return winston.error('Problem saving topic RSS feed', err.stack);

			var	feed = new rss({
					title: topicData.topic_name,
					description: topicData.main_posts[0].content,
					feed_url: Feed.defaults.baseUrl + '/topics/' + tid + '.rss',
					site_url: nconf.get('url') + 'topic/' + topicData.slug,
					image_url: topicData.main_posts[0].picture,
					author: topicData.main_posts[0].username,
					pubDate: new Date(parseInt(topicData.main_posts[0].timestamp, 10)).toUTCString(),
					ttl: Feed.defaults.ttl
				}),
				topic_posts = topicData.main_posts.concat(topicData.posts),
				title, postData, dateStamp;

			for (var i = 0, ii = topic_posts.length; i < ii; i++) {
				postData = topic_posts[i];
				dateStamp = new Date(parseInt(postData.edited === '0' ? postData.timestamp : postData.edited, 10)).toUTCString();
				title = 'Reply to ' + topicData.topic_name + ' on ' + dateStamp;

				feed.item({
					title: title,
					description: postData.content,
					url: nconf.get('url') + 'topic/' + topicData.slug + '#' + postData.pid,
					author: postData.username,
					date: dateStamp
				});
			}

			Feed.saveFeed('feeds/topics/' + tid + '.rss', feed, function(err) {
				if (callback) callback();
			});
		});
Example #22
0
            events.slice(startIndex, startIndex + 25).forEach(function(event) {
                var title;

                switch (event.type) {
                    case "push":
                        title = event.message;

                        if (title.length > 50) {
                            title = title.substring(0, 47) + "...";
                        }

                        title = event.repository + " - " + title;
                        break;
                    case "release":
                        title = event.repository + " Release: " + event.release;
                        break;
                }

                feed.item({
                    guid: "roncli.com:coding:" + event.type + ":" + event.id.toString(),
                    date: new Date(event.published),
                    categories: [event.type],
                    title: title,
                    description: event.message,
                    url: "http://roncli.com/coding",
                    author: "roncli@roncli.com (roncli)",
                    custom_elements: [
                        {"atom:updated": moment(new Date(event.published)).format()}
                    ]
                });
            });
Example #23
0
 authorsToPost.forEach(author => {
   feed.item({
     title: author.username,
     description: render(firstTweet(author)),
     url: `https://jsunderhood.ru/${author.authorId}/`,
     date: firstTweet(author).created_at,
   });
 });
Example #24
0
	postIndex.forEach(function (post) {
		feed.item({
			title: post.title,
			date: post.date,
			description: post.content,
			url: 'http://chipersoft.com'+post.url
		});
	});
Example #25
0
 codeHorrors.forEach(function (item) {
     feed.item({
         title: item.title,
         url: 'http://www.ohhhshit.com/show.html?id=' + item._id,
         author: item.name,
         date: item.creationDate
     });
 });
Example #26
0
 posts.forEach(function(post) {
     feed.item({
         title: post.title,
         description: post.body,
         url: settings.site_home + post.id + '/' + post.slug,
         date: post.created_on
     });
 });
Example #27
0
 blogArray.forEach(function(rssItem) {
   feed.item({
     title: rssItem.title,
     description: rssItem.description,
     url: rssItem.URL,
     date: rssItem.postedOnDate
   });
 });
Example #28
0
			popularData.topics.forEach(function(topicData) {
				feed.item({
					title: topicData.title,
					url: nconf.get('url') + '/topic/' + topicData.slug,
					author: topicData.username,
					date: new Date(parseInt(topicData.lastposttime, 10)).toUTCString()
				});
			});
Example #29
0
                    posts.forEach(function (post) {
                        var item = {
                                title: post.title,
                                guid: post.uuid,
                                url: config.urlFor('post', {post: post, permalinks: permalinks}, true),
                                date: post.published_at,
                                categories: _.pluck(post.tags, 'name'),
                                author: post.author ? post.author.name : null
                            },
                            htmlContent = cheerio.load(post.html, {decodeEntities: false});

                        if (post.image) {
                            htmlContent('p').first().before('<img src="' + post.image + '" />');
                            htmlContent('img').attr('alt', post.title);
                        }

                        // convert relative resource urls to absolute
                        ['href', 'src'].forEach(function (attributeName) {
                            htmlContent('[' + attributeName + ']').each(function (ix, el) {
                                var baseUrl,
                                    attributeValue,
                                    parsed;

                                el = htmlContent(el);

                                attributeValue = el.attr(attributeName);

                                // if URL is absolute move on to the next element
                                try {
                                    parsed = url.parse(attributeValue);

                                    if (parsed.protocol) {
                                        return;
                                    }
                                } catch (e) {
                                    return;
                                }

                                // compose an absolute URL

                                // if the relative URL begins with a '/' use the blog URL (including sub-directory)
                                // as the base URL, otherwise use the post's URL.
                                baseUrl = attributeValue[0] === '/' ? siteUrl : item.url;

                                // prevent double slashes
                                if (baseUrl.slice(-1) === '/' && attributeValue[0] === '/') {
                                    attributeValue = attributeValue.substr(1);
                                }

                                attributeValue = baseUrl + attributeValue;
                                el.attr(attributeName, attributeValue);
                            });
                        });

                        item.description = htmlContent.html();
                        feed.item(item);
                    });
Example #30
0
		diaries.forEach(function(item) {
			feed.item({
				title: item.title || item.bookname,
				description: item.content,
				url: 'http://tuer.me/diary/' + item.id,
				author: user.nick,
				date: item.created_at
			});
		});