added popular rss feed

This commit is contained in:
Baris Soner Usakli
2014-01-31 11:16:23 -05:00
parent 347d402f48
commit c042d4253b
2 changed files with 61 additions and 13 deletions

View File

@@ -832,31 +832,34 @@ module.exports.server = server;
});
app.get('/recent.rss', function(req, res) {
var rssPath = path.join(__dirname, '../', 'feeds/recent.rss'),
loadFeed = function () {
fs.readFile(rssPath, function (err, data) {
if (err) {
res.type('text').send(404, "Unable to locate an rss feed at this location.");
} else {
res.type('xml').set('Content-Length', data.length).send(data);
}
});
};
var rssPath = path.join(__dirname, '../', 'feeds/recent.rss');
if (!fs.existsSync(rssPath)) {
feed.updateRecent(function (err) {
if (err) {
res.redirect('/404');
} else {
loadFeed();
feed.loadFeed(rssPath, res);
}
});
} else {
loadFeed();
feed.loadFeed(rssPath, res);
}
});
app.get('/popular.rss', function(req, res) {
var rssPath = path.join(__dirname, '../', 'feeds/popular.rss');
feed.updatePopular(function (err) {
if (err) {
res.redirect('/404');
} else {
feed.loadFeed(rssPath, res);
}
});
});
app.get('/recent/:term?', function (req, res) {
// TODO consolidate with /recent route as well -> that can be combined into this area. See "Basic Routes" near top.
app.build_header({