v1.18.x
barisusakli 9 years ago
parent 5ff5a01c4f
commit 25f3a31ff1

@ -34,5 +34,6 @@
"teaserPost": "last-reply",
"allowPrivateGroups": 1,
"unreadCutoff": 2,
"bookmarkThreshold": 5
"bookmarkThreshold": 5,
"topicsPerList": 20
}

@ -1,14 +1,11 @@
"use strict";
var async = require('async');
var nconf = require('nconf');
var validator = require('validator');
var categories = require('../categories');
var meta = require('../meta');
var plugins = require('../plugins');
var helpers = require('./helpers');
var categoriesController = {};
@ -51,8 +48,12 @@ categoriesController.list = function(req, res, next) {
categories.flattenCategories(allCategories, categoryData);
categories.getRecentTopicReplies(allCategories, req.uid, next);
},
function (next) {
}
], function(err) {
if (err) {
return next(err);
}
var data = {
title: '[[pages:categories]]',
categories: categoryData
@ -72,13 +73,7 @@ categoriesController.list = function(req, res, next) {
}
});
plugins.fireHook('filter:categories.build', {req: req, res: res, templateData: data}, next);
}
], function(err, data) {
if (err) {
return next(err);
}
res.render('categories', data.templateData);
res.render('categories', data);
});
};

@ -9,7 +9,6 @@ var privileges = require('../privileges');
var user = require('../user');
var categories = require('../categories');
var meta = require('../meta');
var plugins = require('../plugins');
var pagination = require('../pagination');
var helpers = require('./helpers');
var utils = require('../../public/src/utils');
@ -143,8 +142,12 @@ categoryController.get = function(req, res, callback) {
categories.getRecentTopicReplies(allCategories, req.uid, function(err) {
next(err, categoryData);
});
},
function (categoryData, next) {
}
], function (err, categoryData) {
if (err) {
return callback(err);
}
categoryData.privileges = userPrivileges;
categoryData.showSelect = categoryData.privileges.editable;
@ -195,13 +198,7 @@ categoryController.get = function(req, res, callback) {
res.locals.linkTags.push(rel);
});
plugins.fireHook('filter:category.build', {req: req, res: res, templateData: categoryData}, next);
}
], function (err, data) {
if (err) {
return callback(err);
}
res.render('category', data.templateData);
res.render('category', categoryData);
});
};

@ -1,14 +1,15 @@
"use strict";
var async = require('async'),
nconf = require('nconf'),
validator = require('validator'),
meta = require('../meta'),
groups = require('../groups'),
user = require('../user'),
helpers = require('./helpers'),
plugins = require('../plugins'),
groupsController = {};
var async = require('async');
var nconf = require('nconf');
var validator = require('validator');
var meta = require('../meta');
var groups = require('../groups');
var user = require('../user');
var helpers = require('./helpers');
var groupsController = {};
groupsController.list = function(req, res, next) {
var sort = req.query.sort || 'alpha';
@ -83,22 +84,20 @@ groupsController.details = function(req, res, callback) {
},
isAdmin: async.apply(user.isAdministrator, req.uid)
}, next);
},
function (results, next) {
}
], function(err, results) {
if (err) {
return callback(err);
}
if (!results.group) {
return callback();
}
results.title = '[[pages:group, ' + results.group.displayName + ']]';
results.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:groups]]', url: '/groups' }, {text: results.group.displayName}]);
results.allowPrivateGroups = parseInt(meta.config.allowPrivateGroups, 10) === 1;
plugins.fireHook('filter:group.build', {req: req, res: res, templateData: results}, next);
}
], function(err, results) {
if (err) {
return callback(err);
}
res.render('groups/details', results.templateData);
res.render('groups/details', results);
});
};

@ -134,8 +134,11 @@ Controllers.register = function(req, res, next) {
},
function(next) {
plugins.fireHook('filter:parse.post', {postData: {content: meta.config.termsOfUse || ''}}, next);
},
function(tos, next) {
}
], function(err, termsOfUse) {
if (err) {
return next(err);
}
var loginStrategies = require('../routes/authentication').getLoginStrategies();
var data = {
'register_window:spansize': loginStrategies.length ? 'col-md-6' : 'col-md-12',
@ -147,19 +150,13 @@ Controllers.register = function(req, res, next) {
data.minimumUsernameLength = parseInt(meta.config.minimumUsernameLength, 10);
data.maximumUsernameLength = parseInt(meta.config.maximumUsernameLength, 10);
data.minimumPasswordLength = parseInt(meta.config.minimumPasswordLength, 10);
data.termsOfUse = tos.postData.content;
data.termsOfUse = termsOfUse.postData.content;
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[register:register]]'}]);
data.regFormEntry = [];
data.error = req.flash('error')[0];
data.title = '[[pages:register]]';
plugins.fireHook('filter:register.build', {req: req, res: res, templateData: data}, next);
}
], function(err, data) {
if (err) {
return next(err);
}
res.render('register', data.templateData);
res.render('register', data);
});
};

@ -1,15 +1,15 @@
'use strict';
var nconf = require('nconf'),
topics = require('../topics'),
plugins = require('../plugins'),
meta = require('../meta'),
helpers = require('./helpers');
var nconf = require('nconf');
var topics = require('../topics');
var meta = require('../meta');
var helpers = require('./helpers');
var popularController = {};
var anonCache = {}, lastUpdateTime = 0;
var anonCache = {};
var lastUpdateTime = 0;
var terms = {
daily: 'day',
@ -48,7 +48,8 @@ popularController.get = function(req, res, next) {
topics: topics,
'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1,
rssFeedUrl: nconf.get('relative_path') + '/popular/' + (req.params.term || 'daily') + '.rss',
title: '[[pages:popular-' + term + ']]'
title: '[[pages:popular-' + term + ']]',
term: term
};
if (req.path.startsWith('/api/popular') || req.path.startsWith('/popular')) {
@ -66,12 +67,7 @@ popularController.get = function(req, res, next) {
lastUpdateTime = Date.now();
}
plugins.fireHook('filter:popular.build', {req: req, res: res, term: term, templateData: data}, function(err, data) {
if (err) {
return next(err);
}
res.render('popular', data.templateData);
});
res.render('popular', data);
});
};

@ -2,11 +2,10 @@
'use strict';
var nconf = require('nconf');
var async = require('async');
var topics = require('../topics');
var meta = require('../meta');
var helpers = require('./helpers');
var plugins = require('../plugins');
var recentController = {};
@ -14,11 +13,11 @@ recentController.get = function(req, res, next) {
var stop = (parseInt(meta.config.topicsPerList, 10) || 20) - 1;
async.waterfall([
function (next) {
topics.getTopicsFromSet('topics:recent', req.uid, 0, stop, next);
},
function (data, next) {
topics.getTopicsFromSet('topics:recent', req.uid, 0, stop, function(err, data) {
if (err) {
return next(err);
}
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
data.rssFeedUrl = nconf.get('relative_path') + '/recent.rss';
data.title = '[[pages:recent]]';
@ -26,13 +25,7 @@ recentController.get = function(req, res, next) {
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[recent:title]]'}]);
}
plugins.fireHook('filter:recent.build', {req: req, res: res, templateData: data}, next);
}
], function(err, data) {
if (err) {
return next(err);
}
res.render('recent', data.templateData);
res.render('recent', data);
});
};

@ -1,14 +1,14 @@
'use strict';
var async = require('async'),
var async = require('async');
meta = require('../meta'),
plugins = require('../plugins'),
search = require('../search'),
categories = require('../categories'),
pagination = require('../pagination'),
helpers = require('./helpers');
var meta = require('../meta');
var plugins = require('../plugins');
var search = require('../search');
var categories = require('../categories');
var pagination = require('../pagination');
var helpers = require('./helpers');
var searchController = {};
@ -61,12 +61,7 @@ searchController.search = function(req, res, next) {
searchData.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:search]]'}]);
searchData.expandSearch = !req.params.term;
plugins.fireHook('filter:search.build', {data: data, results: searchData}, function(err, data) {
if (err) {
return next(err);
}
res.render('search', data.results);
});
res.render('search', searchData);
});
};

@ -288,12 +288,7 @@ topicsController.get = function(req, res, callback) {
});
}
plugins.fireHook('filter:topic.build', {req: req, res: res, templateData: data}, function(err, data) {
if (err) {
return callback(err);
}
res.render('topic', data.templateData);
});
res.render('topic', data);
});
};

@ -8,7 +8,6 @@ var privileges = require('../privileges');
var user = require('../user');
var topics = require('../topics');
var helpers = require('./helpers');
var plugins = require('../plugins');
var unreadController = {};
@ -42,8 +41,12 @@ unreadController.get = function(req, res, next) {
},
function(cids, next) {
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'link', 'color', 'bgColor'], next);
},
function(categories, next) {
}
], function(err, categories) {
if (err) {
return next(err);
}
categories = categories.filter(function(category) {
return category && !category.link;
});
@ -75,14 +78,7 @@ unreadController.get = function(req, res, next) {
return filter && filter.selected;
})[0];
plugins.fireHook('filter:unread.build', {req: req, res: res, templateData: results.unreadTopics}, next);
}
], function(err, data) {
if (err) {
return next(err);
}
res.render('unread', data.templateData);
res.render('unread', results.unreadTopics);
});
};

@ -5,7 +5,6 @@ var user = require('../user');
var meta = require('../meta');
var pagination = require('../pagination');
var plugins = require('../plugins');
var db = require('../database');
var helpers = require('./helpers');
@ -165,26 +164,20 @@ usersController.getUsersAndCount = function(set, uid, start, stop, callback) {
};
function render(req, res, data, next) {
plugins.fireHook('filter:users.build', {req: req, res: res, templateData: data }, function(err, data) {
if (err) {
return next(err);
}
var registrationType = meta.config.registrationType;
data.templateData.maximumInvites = meta.config.maximumInvites;
data.templateData.inviteOnly = registrationType === 'invite-only' || registrationType === 'admin-invite-only';
data.templateData.adminInviteOnly = registrationType === 'admin-invite-only';
data.templateData['reputation:disabled'] = parseInt(meta.config['reputation:disabled'], 10) === 1;
data.maximumInvites = meta.config.maximumInvites;
data.inviteOnly = registrationType === 'invite-only' || registrationType === 'admin-invite-only';
data.adminInviteOnly = registrationType === 'admin-invite-only';
data['reputation:disabled'] = parseInt(meta.config['reputation:disabled'], 10) === 1;
user.getInvitesNumber(req.uid, function(err, num) {
if (err) {
return next(err);
}
data.templateData.invites = num;
res.render('users', data.templateData);
});
data.invites = num;
res.render('users', data);
});
}

@ -1,6 +1,8 @@
'use strict';
var nconf = require('nconf');
var plugins = require('../plugins');
var translator = require('../../public/src/modules/translator');
module.exports = function(middleware) {
@ -9,22 +11,29 @@ module.exports = function(middleware) {
// res.render post-processing, modified from here: https://gist.github.com/mrlannigan/5051687
var render = res.render;
res.render = function(template, options, fn) {
var self = this,
req = this.req,
defaultFn = function(err, str){
var self = this;
var req = this.req;
var defaultFn = function(err, str) {
if (err) {
return next(err);
}
self.send(str);
};
options = options || {};
options = options || {};
if ('function' === typeof options) {
fn = options;
options = {};
}
plugins.fireHook('filter:' + template + '.build', {req: req, res: res, templateData: options}, function(err, data) {
if (err) {
return next(err);
}
options = data.templateData;
options.loggedIn = !!req.uid;
options.relative_path = nconf.get('relative_path');
options.template = {name: template};
@ -82,6 +91,7 @@ module.exports = function(middleware) {
fn(err, str);
}
});
});
};
next();

@ -62,12 +62,7 @@ function getAvailable(callback) {
return item;
});
// DEPRECATION: backwards compatibility for filter:header.build, will be removed soon.
plugins.fireHook('filter:header.build', {navigation: []}, function(err, data) {
core = core.concat(data.navigation);
plugins.fireHook('filter:navigation.available', core, callback);
});
}
module.exports = admin;

@ -1,10 +1,8 @@
'use strict';
var async = require('async'),
db = require('../database'),
privileges = require('../privileges');
var async = require('async');
var privileges = require('../privileges');
module.exports = function(Topics) {

Loading…
Cancel
Save