|
|
@ -832,31 +832,34 @@ module.exports.server = server;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
app.get('/recent.rss', function(req, res) {
|
|
|
|
app.get('/recent.rss', function(req, res) {
|
|
|
|
var rssPath = path.join(__dirname, '../', 'feeds/recent.rss'),
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!fs.existsSync(rssPath)) {
|
|
|
|
if (!fs.existsSync(rssPath)) {
|
|
|
|
feed.updateRecent(function (err) {
|
|
|
|
feed.updateRecent(function (err) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
res.redirect('/404');
|
|
|
|
res.redirect('/404');
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
loadFeed();
|
|
|
|
feed.loadFeed(rssPath, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} 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) {
|
|
|
|
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.
|
|
|
|
// TODO consolidate with /recent route as well -> that can be combined into this area. See "Basic Routes" near top.
|
|
|
|
app.build_header({
|
|
|
|
app.build_header({
|
|
|
|