|
|
@ -58,13 +58,18 @@ var path = require('path'),
|
|
|
|
app.get('/home', function (req, res) {
|
|
|
|
app.get('/home', function (req, res) {
|
|
|
|
var uid = (req.user) ? req.user.uid : 0;
|
|
|
|
var uid = (req.user) ? req.user.uid : 0;
|
|
|
|
categories.getAllCategories(uid, function (err, data) {
|
|
|
|
categories.getAllCategories(uid, function (err, data) {
|
|
|
|
// Remove disabled categories
|
|
|
|
|
|
|
|
data.categories = data.categories.filter(function (category) {
|
|
|
|
data.categories = data.categories.filter(function (category) {
|
|
|
|
return (!category.disabled || parseInt(category.disabled, 10) === 0);
|
|
|
|
return (!category.disabled || parseInt(category.disabled, 10) === 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Retrieve category information for /
|
|
|
|
function canSee(category, next) {
|
|
|
|
function iterator(category, callback) {
|
|
|
|
categoryTools.privileges(category.cid, ((req.user) ? req.user.uid || 0 : 0), function(err, privileges) {
|
|
|
|
|
|
|
|
next(!err && privileges.read);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getRecentReplies(category, callback) {
|
|
|
|
categories.getRecentReplies(category.cid, uid, parseInt(category.numRecentReplies, 10), function (err, posts) {
|
|
|
|
categories.getRecentReplies(category.cid, uid, parseInt(category.numRecentReplies, 10), function (err, posts) {
|
|
|
|
category.posts = posts;
|
|
|
|
category.posts = posts;
|
|
|
|
category.post_count = posts.length > 2 ? 2 : posts.length; // this was a hack to make metro work back in the day, post_count should just = length
|
|
|
|
category.post_count = posts.length > 2 ? 2 : posts.length; // this was a hack to make metro work back in the day, post_count should just = length
|
|
|
@ -72,46 +77,50 @@ var path = require('path'),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async.each(data.categories, iterator, function (err) {
|
|
|
|
async.filter(data.categories, canSee, function(visibleCategories) {
|
|
|
|
// Assemble the MOTD
|
|
|
|
data.categories = visibleCategories;
|
|
|
|
var motdString,
|
|
|
|
|
|
|
|
assemble = function() {
|
|
|
|
async.each(data.categories, getRecentReplies, function (err) {
|
|
|
|
data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none';
|
|
|
|
|
|
|
|
data.motd_class += (meta.config.motd && meta.config.motd.length > 0 ? '' : ' default');
|
|
|
|
var motdString,
|
|
|
|
data.motd_class += meta.config.motd_class ? ' ' + meta.config.motd_class : '';
|
|
|
|
assemble = function() {
|
|
|
|
|
|
|
|
data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none';
|
|
|
|
data.motd = require('marked')(motdString);
|
|
|
|
data.motd_class += (meta.config.motd && meta.config.motd.length > 0 ? '' : ' default');
|
|
|
|
res.json(data);
|
|
|
|
data.motd_class += meta.config.motd_class ? ' ' + meta.config.motd_class : '';
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!meta.config.motd) {
|
|
|
|
data.motd = require('marked')(motdString);
|
|
|
|
// Construct default MOTD
|
|
|
|
res.json(data);
|
|
|
|
translator.translate('\n\n# NodeBB <small><span>v' + pkg.version + '</span></small>\n\n<h5>[[global:motd.welcome]]</h5>\
|
|
|
|
};
|
|
|
|
<div class="btn-group">\
|
|
|
|
|
|
|
|
<a target="_blank" href="https://www.nodebb.org" class="btn btn-link btn-md">\
|
|
|
|
if (!meta.config.motd) {
|
|
|
|
<i class="fa fa-comment"></i>\
|
|
|
|
translator.translate('\n\n# NodeBB <small><span>v' + pkg.version + '</span></small>\n\n<h5>[[global:motd.welcome]]</h5>\
|
|
|
|
<span> [[global:motd.get]]</span>\
|
|
|
|
<div class="btn-group">\
|
|
|
|
</a>\
|
|
|
|
<a target="_blank" href="https://www.nodebb.org" class="btn btn-link btn-md">\
|
|
|
|
<a target="_blank" href="https://github.com/designcreateplay/NodeBB" class="btn btn-link btn-md">\
|
|
|
|
<i class="fa fa-comment"></i>\
|
|
|
|
<i class="fa fa-github"></i>\
|
|
|
|
<span> [[global:motd.get]]</span>\
|
|
|
|
<span> [[global:motd.fork]]</span>\
|
|
|
|
</a>\
|
|
|
|
</a>\
|
|
|
|
<a target="_blank" href="https://github.com/designcreateplay/NodeBB" class="btn btn-link btn-md">\
|
|
|
|
<a target="_blank" href="https://facebook.com/NodeBB" class="btn btn-link btn-md">\
|
|
|
|
<i class="fa fa-github"></i>\
|
|
|
|
<i class="fa fa-facebook"></i>\
|
|
|
|
<span> [[global:motd.fork]]</span>\
|
|
|
|
<span> [[global:motd.like]]</span>\
|
|
|
|
</a>\
|
|
|
|
</a>\
|
|
|
|
<a target="_blank" href="https://facebook.com/NodeBB" class="btn btn-link btn-md">\
|
|
|
|
<a target="_blank" href="https://twitter.com/NodeBB" class="btn btn-link btn-md">\
|
|
|
|
<i class="fa fa-facebook"></i>\
|
|
|
|
<i class="fa fa-twitter"></i>\
|
|
|
|
<span> [[global:motd.like]]</span>\
|
|
|
|
<span> [[global:motd.follow]]</span>\
|
|
|
|
</a>\
|
|
|
|
</a>\
|
|
|
|
<a target="_blank" href="https://twitter.com/NodeBB" class="btn btn-link btn-md">\
|
|
|
|
</div>\
|
|
|
|
<i class="fa fa-twitter"></i>\
|
|
|
|
', function(motd) {
|
|
|
|
<span> [[global:motd.follow]]</span>\
|
|
|
|
motdString = motd;
|
|
|
|
</a>\
|
|
|
|
|
|
|
|
</div>\
|
|
|
|
|
|
|
|
', function(motd) {
|
|
|
|
|
|
|
|
motdString = motd;
|
|
|
|
|
|
|
|
assemble();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
motdString = meta.config.motd;
|
|
|
|
assemble();
|
|
|
|
assemble();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
});
|
|
|
|
motdString = meta.config.motd;
|
|
|
|
|
|
|
|
assemble();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|