2015-07-18 11:44:53 +09:00
|
|
|
RSS = Npm.require('rss');
|
2015-04-22 07:50:11 +09:00
|
|
|
|
2015-07-18 11:44:53 +09:00
|
|
|
getMeta = function(url) {
|
2015-04-22 07:50:11 +09:00
|
|
|
var siteUrl = Settings.get('siteUrl', Meteor.absoluteUrl());
|
|
|
|
return {
|
|
|
|
title: Settings.get('title'),
|
|
|
|
description: Settings.get('tagline'),
|
|
|
|
feed_url: siteUrl+url,
|
|
|
|
site_url: siteUrl,
|
2015-07-18 11:44:53 +09:00
|
|
|
image_url: siteUrl+'img/favicon.png'
|
2015-04-22 07:50:11 +09:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
servePostRSS = function(view, url) {
|
|
|
|
var feed = new RSS(getMeta(url));
|
|
|
|
|
|
|
|
var params = Posts.getSubParams({view: view, limit: 20});
|
|
|
|
delete params['options']['sort']['sticky'];
|
|
|
|
|
|
|
|
Posts.find(params.find, params.options).forEach(function(post) {
|
2015-07-18 11:44:53 +09:00
|
|
|
|
2015-04-22 07:50:11 +09:00
|
|
|
var description = !!post.body ? post.body+'</br></br>' : '';
|
2015-07-18 12:12:55 +09:00
|
|
|
var feedItem = {
|
|
|
|
title: post.title,
|
|
|
|
description: description + '<a href="' + post.getPageUrl(true) + '">Discuss</a>',
|
|
|
|
author: post.author,
|
|
|
|
date: post.postedAt,
|
|
|
|
guid: post._id,
|
|
|
|
url: Settings.get("outsideLinksPointTo", "link") === "link" ? Posts.getLink(post) : Posts.getPageUrl(post, true)
|
2015-07-18 11:44:53 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
if (post.thumbnailUrl) {
|
|
|
|
// add http: if missing
|
|
|
|
if (post.thumbnailUrl.substring(0, 5) !== "http:" && post.thumbnailUrl.substring(0, 6) !== "https:") {
|
|
|
|
post.thumbnailUrl = "http:"+post.thumbnailUrl;
|
|
|
|
}
|
2015-07-18 12:12:55 +09:00
|
|
|
feedItem.custom_elements = [{"imageUrl": post.thumbnailUrl}, {"content": post.thumbnailUrl}];
|
2015-07-18 11:44:53 +09:00
|
|
|
}
|
|
|
|
|
2015-07-18 12:12:55 +09:00
|
|
|
feed.item(feedItem);
|
2015-04-22 07:50:11 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
return feed.xml();
|
|
|
|
};
|
|
|
|
|
|
|
|
serveCommentRSS = function() {
|
|
|
|
var feed = new RSS(getMeta(Router.path('rss_comments')));
|
|
|
|
|
|
|
|
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="'+Telescope.utils.getPostCommentUrl(post._id, comment._id)+'">Discuss</a>',
|
|
|
|
author: comment.author,
|
|
|
|
date: comment.postedAt,
|
2015-06-19 11:52:57 +09:00
|
|
|
url: comment.getPageUrl(true),
|
2015-04-22 07:50:11 +09:00
|
|
|
guid: comment._id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return feed.xml();
|
|
|
|
};
|