mirror of
https://github.com/vale981/Vulcan
synced 2025-03-08 19:11:38 -05:00
RSS feed for top, best views & feed url bug fix
This commit is contained in:
parent
77d21ea139
commit
d89687b25e
2 changed files with 32 additions and 7 deletions
|
@ -8,7 +8,29 @@ Meteor.startup(function () {
|
|||
where: 'server',
|
||||
path: '/feed.xml',
|
||||
action: function() {
|
||||
this.response.write(servePostRSS());
|
||||
this.response.write(servePostRSS('new'));
|
||||
this.response.end();
|
||||
}
|
||||
});
|
||||
|
||||
// Top Post RSS
|
||||
|
||||
this.route('feed', {
|
||||
where: 'server',
|
||||
path: 'rss/posts/top.xml',
|
||||
action: function() {
|
||||
this.response.write(servePostRSS('top'));
|
||||
this.response.end();
|
||||
}
|
||||
});
|
||||
|
||||
// Best Post RSS
|
||||
|
||||
this.route('feed', {
|
||||
where: 'server',
|
||||
path: 'rss/posts/best.xml',
|
||||
action: function() {
|
||||
this.response.write(servePostRSS('best'));
|
||||
this.response.end();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
var RSS = Npm.require('rss');
|
||||
|
||||
var getMeta = function() {
|
||||
var getMeta = function(url) {
|
||||
return {
|
||||
title: getSetting('title'),
|
||||
description: getSetting('tagline'),
|
||||
feed_url: Meteor.absoluteUrl()+'feed.xml',
|
||||
feed_url: Meteor.absoluteUrl()+url,
|
||||
site_url: Meteor.absoluteUrl(),
|
||||
image_url: Meteor.absoluteUrl()+'img/favicon.png',
|
||||
};
|
||||
};
|
||||
|
||||
servePostRSS = function() {
|
||||
var feed = new RSS(getMeta());
|
||||
servePostRSS = function(view) {
|
||||
var feed = new RSS(getMeta('feed.xml'));
|
||||
|
||||
Posts.find(getPostsParameters({}).find, {sort: {postedAt: -1}, limit: 20}).forEach(function(post) {
|
||||
var params = getPostsParameters({view: view, limit: 20});
|
||||
delete params['options']['sort']['sticky'];
|
||||
|
||||
Posts.find(params.find, params.options).forEach(function(post) {
|
||||
var description = !!post.body ? post.body+'</br></br>' : '';
|
||||
feed.item({
|
||||
title: post.title,
|
||||
|
@ -29,7 +32,7 @@ servePostRSS = function() {
|
|||
};
|
||||
|
||||
serveCommentRSS = function() {
|
||||
var feed = new RSS(getMeta());
|
||||
var feed = new RSS(getMeta('rss/comments.xml'));
|
||||
|
||||
Comments.find({isDeleted: {$ne: true}}, {sort: {postedAt: -1}, limit: 20}).forEach(function(comment) {
|
||||
post = Posts.findOne(comment.postId);
|
||||
|
|
Loading…
Add table
Reference in a new issue