|
|
|
@ -52,8 +52,23 @@ var path = require('path'),
|
|
|
|
|
config.defaultLang = meta.config.defaultLang || 'en_GB';
|
|
|
|
|
config.environment = process.env.NODE_ENV;
|
|
|
|
|
|
|
|
|
|
if (!req.user) {
|
|
|
|
|
return res.json(200, config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(req.user) {
|
|
|
|
|
user.getSettings(req.user.uid, function(err, settings) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config.usePagination = settings.usePagination;
|
|
|
|
|
config.topicsPerPage = settings.topicsPerPage;
|
|
|
|
|
config.postsPerPage = settings.postsPerPage;
|
|
|
|
|
res.json(200, config);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.get('/home', function (req, res) {
|
|
|
|
|
var uid = (req.user) ? req.user.uid : 0;
|
|
|
|
@ -189,9 +204,13 @@ var path = require('path'),
|
|
|
|
|
return res.send(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var postsPerPage = parseInt(meta.config.postsPerPage ? meta.config.postsPerPage : 20, 10);
|
|
|
|
|
var start = (page - 1) * postsPerPage;
|
|
|
|
|
var end = start + postsPerPage - 1;
|
|
|
|
|
user.getSettings(uid, function(err, settings) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var start = (page - 1) * settings.postsPerPage;
|
|
|
|
|
var end = start + settings.postsPerPage - 1;
|
|
|
|
|
|
|
|
|
|
ThreadTools.privileges(req.params.id, uid, function(err, privileges) {
|
|
|
|
|
if (privileges.read) {
|
|
|
|
@ -218,6 +237,7 @@ var path = require('path'),
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.get('/category/:id/:slug?', function (req, res, next) {
|
|
|
|
|
var uid = (req.user) ? req.user.uid : 0;
|
|
|
|
@ -230,11 +250,14 @@ var path = require('path'),
|
|
|
|
|
return res.send(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var topicsPerPage = parseInt(meta.config.topicsPerPage ? meta.config.topicsPerPage : 20, 10);
|
|
|
|
|
var start = (page - 1) * topicsPerPage;
|
|
|
|
|
var end = start + topicsPerPage - 1;
|
|
|
|
|
user.getSettings(uid, function(err, settings) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var start = (page - 1) * settings.topicsPerPage;
|
|
|
|
|
var end = start + settings.topicsPerPage - 1;
|
|
|
|
|
|
|
|
|
|
// Category Whitelisting
|
|
|
|
|
categoryTools.privileges(req.params.id, uid, function(err, privileges) {
|
|
|
|
|
if (!err && privileges.read) {
|
|
|
|
|
categories.getCategoryById(req.params.id, start, end, uid, function (err, data) {
|
|
|
|
@ -256,6 +279,7 @@ var path = require('path'),
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.get('/recent/:term?', function (req, res, next) {
|
|
|
|
|
var uid = (req.user) ? req.user.uid : 0;
|
|
|
|
|