mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-07 15:29:32 +02:00
totally derped commit
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
Feed.updateTopic = function(tid, cid) {
|
||||
Feed.updateTopic = function(tid, callback) {
|
||||
if (process.env.NODE_ENV === 'development') winston.info('[rss] Updating RSS feeds for topic ' + tid);
|
||||
|
||||
topics.getTopicWithPosts(tid, 0, 0, -1, function(err, topicData) {
|
||||
@@ -57,11 +57,12 @@
|
||||
}
|
||||
|
||||
Feed.saveFeed('feeds/topics/' + tid + '.rss', feed);
|
||||
if (callback) callback();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
Feed.updateCategory = function(cid) {
|
||||
Feed.updateCategory = function(cid, callback) {
|
||||
if (process.env.NODE_ENV === 'development') winston.info('[rss] Updating RSS feeds for category ' + cid);
|
||||
categories.getCategoryById(cid, 0, function(err, categoryData) {
|
||||
if (err) return winston.error('Could not update RSS feed for category ' + cid, err.stack);
|
||||
@@ -90,6 +91,7 @@
|
||||
}
|
||||
|
||||
Feed.saveFeed('feeds/categories/' + cid + '.rss', feed);
|
||||
if (callback) callback();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -314,7 +314,7 @@ var RDB = require('./redis.js'),
|
||||
topics.getTopicField(tid, 'cid', function(err, cid) {
|
||||
RDB.handle(err);
|
||||
|
||||
feed.updateTopic(tid, cid);
|
||||
feed.updateTopic(tid);
|
||||
|
||||
RDB.zadd('categories:recent_posts:cid:' + cid, timestamp, pid);
|
||||
RDB.zadd('categories:' + cid + ':tid', timestamp, tid);
|
||||
|
||||
@@ -21,7 +21,8 @@ var express = require('express'),
|
||||
installRoute = require('./routes/install.js'),
|
||||
testBed = require('./routes/testbed.js'),
|
||||
auth = require('./routes/authentication.js'),
|
||||
meta = require('./meta.js');
|
||||
meta = require('./meta.js'),
|
||||
feed = require('./feed');
|
||||
|
||||
(function(app) {
|
||||
var templates = null;
|
||||
@@ -212,15 +213,25 @@ var express = require('express'),
|
||||
|
||||
var tid = req.params.topic_id;
|
||||
if (tid.match(/^\d+\.rss$/)) {
|
||||
fs.readFile(path.join(__dirname, '../', 'feeds/topics', tid), function (err, data) {
|
||||
if (err) {
|
||||
res.type('text').send(404, "Unable to locate an rss feed at this location.");
|
||||
return;
|
||||
}
|
||||
tid = tid.slice(0, -4);
|
||||
var rssPath = path.join(__dirname, '../', 'feeds/topics', tid + '.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.");
|
||||
return;
|
||||
}
|
||||
|
||||
res.type('xml').set('Content-Length', data.length).send(data);
|
||||
});
|
||||
return;
|
||||
res.type('xml').set('Content-Length', data.length).send(data);
|
||||
});
|
||||
return;
|
||||
};
|
||||
|
||||
if (!fs.existsSync(rssPath)) {
|
||||
feed.updateTopic(tid, function() {
|
||||
loadFeed();
|
||||
});
|
||||
} else loadFeed();
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
|
||||
Reference in New Issue
Block a user