Merge remote-tracking branch 'origin/master' into 0.7.0

v1.18.x
barisusakli 10 years ago
commit e16cfa396b

@ -34,8 +34,6 @@ define('forum/topic/posts', [
var posts = data.posts;
socket.emit('topics.getPageCount', ajaxify.variables.get('topic_id'), function(err, newPageCount) {
pagination.recreatePaginationLinks(newPageCount);
if (pagination.currentPage === pagination.pageCount) {
createNewPosts(data);
} else if(data.posts && data.posts.length && parseInt(data.posts[0].uid, 10) === parseInt(app.uid, 10)) {

@ -22,7 +22,8 @@ categoriesController.recent = function(req, res, next) {
}
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
data['rssFeedUrl'] = nconf.get('relative_path') + '/recent.rss';
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[recent:title]]'}]);
res.render('recent', data);
});
};
@ -52,7 +53,9 @@ categoriesController.popular = function(req, res, next) {
var data = {
topics: topics,
'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1
'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1,
rssFeedUrl: nconf.get('relative_path') + '/popular.rss',
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[global:header.popular]]'}])
};
if (uid === 0) {
@ -72,6 +75,7 @@ categoriesController.unread = function(req, res, next) {
return next(err);
}
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[unread:title]]'}]);
res.render('unread', data);
});
};
@ -188,7 +192,7 @@ categoriesController.get = function(req, res, next) {
url: nconf.get('relative_path') + '/category/' + categoryData.slug
}
];
helpers.buildBreadcrumbs(categoryData.parentCid, function(err, crumbs) {
helpers.buildCategoryBreadcrumbs(categoryData.parentCid, function(err, crumbs) {
if (err) {
return next(err);
}
@ -255,6 +259,7 @@ categoriesController.get = function(req, res, next) {
data.currentPage = page;
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
data['rssFeedUrl'] = nconf.get('relative_path') + '/category/' + data.cid + '.rss';
pagination.create(data.currentPage, data.pageCount, data);

@ -38,7 +38,7 @@ helpers.notAllowed = function(req, res, error) {
}
};
helpers.buildBreadcrumbs = function(cid, callback) {
helpers.buildCategoryBreadcrumbs = function(cid, callback) {
var breadcrumbs = [];
async.whilst(function() {
@ -62,15 +62,33 @@ helpers.buildBreadcrumbs = function(cid, callback) {
return callback(err);
}
translator.translate('[[global:home]]', meta.config.defaultLang || 'en_GB', function(translated) {
breadcrumbs.unshift({
text: translated,
text: '[[global:home]]',
url: nconf.get('relative_path') + '/'
});
callback(null, breadcrumbs);
});
};
helpers.buildBreadcrumbs = function(crumbs) {
var breadcrumbs = [
{
text: '[[global:home]]',
url: nconf.get('relative_path') + '/'
}
];
crumbs.forEach(function(crumb) {
if (crumb) {
if (crumb.url) {
crumb.url = nconf.get('relative_path') + crumb.url;
}
breadcrumbs.push(crumb);
}
});
return breadcrumbs;
};
module.exports = helpers;

@ -105,9 +105,18 @@ Controllers.home = function(req, res, next) {
};
Controllers.reset = function(req, res, next) {
res.render(req.params.code ? 'reset_code' : 'reset', {
reset_code: req.params.code ? req.params.code : null
if (req.params.code) {
res.render('reset_code', {
reset_code: req.params.code ? req.params.code : null,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]', url: '/reset'}, {text: '[[reset_password:update_password]]'}])
});
} else {
res.render('reset', {
reset_code: req.params.code ? req.params.code : null,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]'}])
});
}
};
Controllers.login = function(req, res, next) {
@ -120,6 +129,7 @@ Controllers.login = function(req, res, next) {
data.showResetLink = emailersPresent;
data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1;
data.allowRegistration = parseInt(meta.config.allowRegistration, 10) === 1;
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:login]]'}]);
data.error = req.flash('error')[0];
res.render('login', data);
@ -151,6 +161,7 @@ Controllers.register = function(req, res, next) {
data.maximumUsernameLength = meta.config.maximumUsernameLength;
data.minimumPasswordLength = meta.config.minimumPasswordLength;
data.termsOfUse = meta.config.termsOfUse;
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[register:register]]'}]);
data.regFormEntry = [];
data.error = req.flash('error')[0];
@ -200,7 +211,8 @@ Controllers.outgoing = function(req, res, next) {
var url = req.query.url,
data = {
url: url,
title: meta.config.title
title: meta.config.title,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[notifications:outgoing_link]]'}])
};
if (url) {

@ -12,7 +12,7 @@ searchController.search = function(req, res, next) {
if (!plugins.hasListeners('filter:search.query')) {
return helpers.notFound(req, res);
}
var breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:search]]'}]);
if (!req.params.term) {
return res.render('search', {
time: 0,
@ -20,7 +20,8 @@ searchController.search = function(req, res, next) {
posts: [],
topics: [],
users: [],
tags: []
tags: [],
breadcrumbs: breadcrumbs
});
}
@ -38,6 +39,7 @@ searchController.search = function(req, res, next) {
return next(err);
}
results.breadcrumbs = breadcrumbs;
res.render('search', results);
});
};

@ -5,7 +5,8 @@ var tagsController = {},
nconf = require('nconf'),
validator = require('validator'),
meta = require('../meta'),
topics = require('../topics');
topics = require('../topics'),
helpers = require('./helpers');
tagsController.getTag = function(req, res, next) {
var tag = validator.escape(req.params.tag);
@ -41,8 +42,13 @@ tagsController.getTag = function(req, res, next) {
content: nconf.get('url') + '/tags/' + tag
}
];
res.render('tag', {topics: topics, tag: tag, nextStart: end + 1});
var data = {
topics: topics,
tag: tag,
nextStart: end + 1,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]', url: '/tags'}, {text: tag}])
};
res.render('tag', data);
});
});
};
@ -52,8 +58,12 @@ tagsController.getTags = function(req, res, next) {
if (err) {
return next(err);
}
res.render('tags', {tags: tags, nextStart: 100});
var data = {
tags: tags,
nextStart: 100,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]'}])
};
res.render('tags', data);
});
};

@ -139,7 +139,7 @@ topicsController.get = function(req, res, next) {
}
];
helpers.buildBreadcrumbs(topicData.category.parentCid, function(err, crumbs) {
helpers.buildCategoryBreadcrumbs(topicData.category.parentCid, function(err, crumbs) {
if (err) {
return next(err);
}
@ -255,6 +255,7 @@ topicsController.get = function(req, res, next) {
data['reputation:disabled'] = parseInt(meta.config['reputation:disabled'], 10) === 1;
data['downvote:disabled'] = parseInt(meta.config['downvote:disabled'], 10) === 1;
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
data['rssFeedUrl'] = nconf.get('relative_path') + '/topic/' + data.tid + '.rss';
topics.increaseViewCount(tid);

@ -152,23 +152,37 @@ var async = require('async'),
if (err || now - parseInt(score, 10) < 300000) {
return callback(err);
}
db.sortedSetAdd('users:online', now, uid, callback);
db.sortedSetAdd('users:online', now, uid, function(err) {
if (err) {
return callback(err);
}
plugins.fireHook('action:user.online', {uid: uid, timestamp: now});
});
});
};
User.setUserField = function(uid, field, value, callback) {
plugins.fireHook('action:user.set', {field: field, value: value, type: 'set'});
db.setObjectField('user:' + uid, field, value, callback);
db.setObjectField('user:' + uid, field, value, function(err) {
if (err) {
return callback(err)
}
plugins.fireHook('action:user.set', {uid: uid, field: field, value: value, type: 'set'});
callback();
});
};
User.setUserFields = function(uid, data, callback) {
db.setObject('user:' + uid, data, function(err) {
if (err) {
return callback(err);
}
for (var field in data) {
if (data.hasOwnProperty(field)) {
plugins.fireHook('action:user.set', {field: field, value: data[field], type: 'set'});
plugins.fireHook('action:user.set', {uid: uid, field: field, value: data[field], type: 'set'});
}
}
db.setObject('user:' + uid, data, callback);
callback();
});
};
User.incrementUserFieldBy = function(uid, field, value, callback) {
@ -177,7 +191,7 @@ var async = require('async'),
if (err) {
return callback(err);
}
plugins.fireHook('action:user.set', {field: field, value: value, type: 'increment'});
plugins.fireHook('action:user.set', {uid: uid, field: field, value: value, type: 'increment'});
callback(null, value);
});
@ -189,7 +203,7 @@ var async = require('async'),
if (err) {
return callback(err);
}
plugins.fireHook('action:user.set', {field: field, value: value, type: 'decrement'});
plugins.fireHook('action:user.set', {uid: uid, field: field, value: value, type: 'decrement'});
callback(null, value);
});

@ -178,19 +178,21 @@ module.exports = function(User) {
}
function sortUsers(userData, sortBy) {
userData.sort(function(user1, user2) {
if (sortBy === 'joindate' || sortBy === 'postcount') {
return user2[sortBy] - user1[sortBy];
userData.sort(function(u1, u2) {
return u2[sortBy] - u1[sortBy];
});
} else {
if(user1[sortBy] < user2[sortBy]) {
userData.sort(function(u1, u2) {
if(u1[sortBy] < u2[sortBy]) {
return -1;
} else if(user1[sortBy] > user2[sortBy]) {
} else if(u1[sortBy] > u2[sortBy]) {
return 1;
}
return 0;
}
});
}
}
function searchByIP(ip, callback) {
var start = process.hrtime();

@ -174,7 +174,7 @@ describe('User', function() {
describe('.delete()', function() {
var uid;
before(function(done) {
User.create({username: 'userToDelete', password: '123456', email: 'delete@me.com'}, function(err, newUid) {
User.create({username: 'usertodelete', password: '123456', email: 'delete@me.com'}, function(err, newUid) {
assert.ifError(err);
uid = newUid;
done();
@ -184,7 +184,7 @@ describe('User', function() {
it('should delete a user account', function(done) {
User.delete(uid, function(err) {
assert.ifError(err);
User.exists('userToDelete', function(err, exists) {
User.exists('usertodelete', function(err, exists) {
assert.ifError(err);
assert.equal(exists, false);
done();

Loading…
Cancel
Save