diff --git a/.meteor/packages b/.meteor/packages index fc10111..55920a8 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -25,3 +25,4 @@ npm-container nemo64:bootstrap atoy40:accounts-cas +raix:rssfeed diff --git a/.meteor/versions b/.meteor/versions index e4d4fd8..428b0a9 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -56,6 +56,7 @@ npm-container@1.0.0 observe-sequence@1.0.6 ordered-dict@1.0.3 percolatestudio:synced-cron@1.0.0 +raix:rssfeed@0.0.5 random@1.0.3 reactive-dict@1.1.0 reactive-var@1.0.5 diff --git a/client/views/posts/post_page.js b/client/views/posts/post_page.js index 37cb476..add88a5 100644 --- a/client/views/posts/post_page.js +++ b/client/views/posts/post_page.js @@ -58,7 +58,7 @@ Template.postPage.helpers({ } else if (post.status == "responded") { return { title: "Responded", - description: "This petition has recieved an official response." + description: "This petition has received an official response." }; } else { if (post.votes >= post.minimumVotes) { diff --git a/collections/posts.js b/collections/posts.js index d1a9eb3..c7e78e6 100644 --- a/collections/posts.js +++ b/collections/posts.js @@ -50,6 +50,38 @@ var validatePost = function validatePost (postAttributes) { }; Meteor.methods({ + updateRSS: function() { + RssFeed.publish('petitions', function(query) { + var self = this; // need to store a reference to this so we can add items in the forEach loop later + + self.setValue('title', self.cdata('RPI Petitions')); + self.setValue('description', self.cdata('Create and sign petitions. Receive official responses from the Student Senate.')); + self.setValue('link', 'https://petitions.union.rpi.edu'); + self.setValue('lastBuildDate', new Date()); + self.setValue('pubDate', new Date()); + self.setValue('ttl', 60); + + Posts.find(query ? query : {}, {sort: {submitted: -1}, limit: 20}).forEach(function(post) { + var info = undefined; + if (post.response) { + info = "Received a Response"; + } else if (post.votes >= post.minimumVotes) { + info = "Reached Vote Threshold"; + } + + date = new Date(); + date.setTime(post.submitted); + + self.addItem({ + title: (info === undefined) ? post.title : (post.title + " (" + post.info + ")"), + description: post.description, + link: "https://petitions.union.rpi.edu/petitions/" + post._id, + pubDate: date + }); + }); + }); + }, + post: function(postAttributes) { validatePost(postAttributes); @@ -70,6 +102,7 @@ Meteor.methods({ var postId = Posts.insert(post); Singleton.update({}, {$inc: {postsCount: 1}}); + Metor.call('updateRSS'); return postId; }, @@ -104,6 +137,7 @@ Meteor.methods({ "\n\nThanks, \nRPI Web Technologies Group" }); } + Meteor.call('updateRSS'); } }, @@ -124,6 +158,7 @@ Meteor.methods({ $pull: {upvoters: user._id}, $inc: {votes: -1} }); + Meteor.call('updateRSS'); } }, @@ -198,13 +233,15 @@ Meteor.methods({ from: "sgnoreply@rit.edu", subject: "PawPrints - A petition you signed has received a response", text: "Hello, \n\n" + - "Petition \"" + post.title + "\" by " + oldPost.author + " has recieved a response: \n\n" + + "Petition \"" + post.title + "\" by " + oldPost.author + " has received a response: \n\n" + Meteor.settings.public.root_url + "/petitions/" + oldPost._id + "\n\nThanks, \nRIT Student Government" }); } + + Meteor.call('updateRSS'); }, - + delete: function (postId) { var user = Meteor.user(); @@ -215,6 +252,6 @@ Meteor.methods({ Posts.remove(postId); Singleton.update({}, {$inc: {postsCount: -1}}); - + Meteor.call('updateRSS'); } -}); \ No newline at end of file +}); diff --git a/server/startup.js b/server/startup.js index ecc8659..3b59935 100644 --- a/server/startup.js +++ b/server/startup.js @@ -1,4 +1,5 @@ Meteor.startup(function () { Singleton.update({}, {$set: { version: "v1.2.2.3" }}); + Meteor.call('updateRSS'); process.env.MAIL_URL = Meteor.settings.MAIL_URL; });