mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
comment rss
This commit is contained in:
parent
38c6bff810
commit
135dabc1a8
2 changed files with 41 additions and 8 deletions
|
@ -2,13 +2,24 @@ Meteor.startup(function () {
|
|||
|
||||
Router.map(function() {
|
||||
|
||||
// RSS
|
||||
// Post RSS
|
||||
|
||||
this.route('feed', {
|
||||
where: 'server',
|
||||
path: '/feed.xml',
|
||||
action: function() {
|
||||
this.response.write(serveRSS());
|
||||
this.response.write(servePostRSS());
|
||||
this.response.end();
|
||||
}
|
||||
});
|
||||
|
||||
// Comment RSS
|
||||
|
||||
this.route('rss_comments', {
|
||||
where: 'server',
|
||||
path: '/rss/comments.xml',
|
||||
action: function() {
|
||||
this.response.write(serveCommentRSS());
|
||||
this.response.end();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
var RSS = Npm.require('rss');
|
||||
|
||||
serveRSS = function() {
|
||||
var feed = new RSS({
|
||||
var getMeta = function() {
|
||||
return {
|
||||
title: getSetting('title'),
|
||||
description: getSetting('tagline'),
|
||||
feed_url: Meteor.absoluteUrl()+'feed.xml',
|
||||
site_url: Meteor.absoluteUrl(),
|
||||
image_url: Meteor.absoluteUrl()+'img/favicon.png',
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
servePostRSS = function() {
|
||||
var feed = new RSS(getMeta());
|
||||
|
||||
Posts.find({status: STATUS_APPROVED}, {sort: {postedAt: -1}, limit: 20}).forEach(function(post) {
|
||||
var description = !!post.body ? post.body+'</br></br>' : '';
|
||||
|
@ -23,3 +27,21 @@ serveRSS = function() {
|
|||
|
||||
return feed.xml();
|
||||
};
|
||||
|
||||
serveCommentRSS = function() {
|
||||
var feed = new RSS(getMeta());
|
||||
|
||||
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
|
||||
});
|
||||
});
|
||||
|
||||
return feed.xml();
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue