2014-08-28 13:39:30 +09:00
|
|
|
var RSS = Npm.require('rss');
|
|
|
|
|
2014-11-17 21:14:56 +08:00
|
|
|
var getMeta = function(url) {
|
2014-12-09 10:23:16 +09:00
|
|
|
var siteUrl = getSetting('siteUrl', Meteor.absoluteUrl());
|
2014-09-24 17:51:21 +08:00
|
|
|
return {
|
2014-01-18 16:52:12 +09:00
|
|
|
title: getSetting('title'),
|
|
|
|
description: getSetting('tagline'),
|
2014-12-09 10:23:16 +09:00
|
|
|
feed_url: siteUrl+url,
|
|
|
|
site_url: siteUrl,
|
|
|
|
image_url: siteUrl+'img/favicon.png',
|
2014-09-24 17:51:21 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-11-18 09:45:33 +08:00
|
|
|
servePostRSS = function(view, url) {
|
|
|
|
var feed = new RSS(getMeta(url));
|
2014-09-24 17:51:21 +08:00
|
|
|
|
2014-11-17 21:14:56 +08:00
|
|
|
var params = getPostsParameters({view: view, limit: 20});
|
|
|
|
delete params['options']['sort']['sticky'];
|
|
|
|
|
|
|
|
Posts.find(params.find, params.options).forEach(function(post) {
|
2014-08-27 09:25:05 +09:00
|
|
|
var description = !!post.body ? post.body+'</br></br>' : '';
|
2014-01-18 16:52:12 +09:00
|
|
|
feed.item({
|
2014-05-16 09:19:35 +09:00
|
|
|
title: post.title,
|
2014-08-27 09:25:05 +09:00
|
|
|
description: description+'<a href="'+getPostUrl(post._id)+'">Discuss</a>',
|
2014-01-18 16:52:12 +09:00
|
|
|
author: post.author,
|
2014-07-03 14:26:05 +09:00
|
|
|
date: post.postedAt,
|
2014-08-04 11:22:43 +09:00
|
|
|
url: getPostLink(post),
|
2014-01-18 16:52:12 +09:00
|
|
|
guid: post._id
|
|
|
|
});
|
|
|
|
});
|
2014-09-24 17:51:21 +08:00
|
|
|
|
|
|
|
return feed.xml();
|
|
|
|
};
|
|
|
|
|
|
|
|
serveCommentRSS = function() {
|
2014-12-03 00:06:00 -08:00
|
|
|
var feed = new RSS(getMeta(Router.routes['rss_comments'].path()));
|
2014-09-24 17:51:21 +08:00
|
|
|
|
|
|
|
Comments.find({isDeleted: {$ne: true}}, {sort: {postedAt: -1}, limit: 20}).forEach(function(comment) {
|
|
|
|
post = Posts.findOne(comment.postId);
|
|
|
|
feed.item({
|
|
|
|
title: 'Comment on '+post.title,
|
|
|
|
description: comment.body+'</br></br>'+'<a href="'+getPostCommentUrl(post._id, comment._id)+'">Discuss</a>',
|
|
|
|
author: comment.author,
|
|
|
|
date: comment.postedAt,
|
|
|
|
url: getCommentUrl(comment._id),
|
|
|
|
guid: comment._id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-01-18 16:52:12 +09:00
|
|
|
return feed.xml();
|
2014-05-06 20:15:48 -07:00
|
|
|
};
|