v1.18.x
Barış Soner Uşaklı 7 years ago
parent 6778cce265
commit d5d6748c71

@ -67,9 +67,9 @@
"nodebb-plugin-spam-be-gone": "0.5.1",
"nodebb-rewards-essentials": "0.0.9",
"nodebb-theme-lavender": "4.1.1",
"nodebb-theme-persona": "6.1.5",
"nodebb-theme-persona": "6.1.6",
"nodebb-theme-slick": "1.1.1",
"nodebb-theme-vanilla": "7.1.3",
"nodebb-theme-vanilla": "7.1.4",
"nodebb-widget-essentials": "3.0.7",
"nodemailer": "4.3.0",
"passport": "^0.4.0",

@ -50,6 +50,7 @@
"account/bookmarks": "%1's Bookmarked Posts",
"account/settings": "User Settings",
"account/watched": "Topics watched by %1",
"account/ignored": "Topics ignored by %1",
"account/upvoted": "Posts upvoted by %1",
"account/downvoted": "Posts downvoted by %1",
"account/best": "Best posts made by %1",

@ -27,6 +27,7 @@
"reputation": "Reputation",
"bookmarks":"Bookmarks",
"watched": "Watched",
"ignored": "Ignored",
"followers": "Followers",
"following": "Following",
"aboutme": "About me",
@ -92,6 +93,7 @@
"has_no_posts": "This user hasn't posted anything yet.",
"has_no_topics": "This user hasn't posted any topics yet.",
"has_no_watched_topics": "This user hasn't watched any topics yet.",
"has_no_ignored_topics": "This user hasn't ignored any topics yet.",
"has_no_upvoted_posts": "This user hasn't upvoted any posts yet.",
"has_no_downvoted_posts": "This user hasn't downvoted any posts yet.",
"has_no_voted_posts": "This user has no voted posts",

@ -11,7 +11,7 @@ var pagination = require('../../pagination');
var helpers = require('../helpers');
var accountHelpers = require('./helpers');
var postsController = {};
var postsController = module.exports;
var templateToData = {
'account/bookmarks': {
@ -50,6 +50,12 @@ var templateToData = {
noItemsFoundKey: '[[user:has_no_watched_topics]]',
crumb: '[[user:watched]]',
},
'account/ignored': {
set: 'ignored_tids',
type: 'topics',
noItemsFoundKey: '[[user:has_no_ignored_topics]]',
crumb: '[[user:ignored]]',
},
'account/topics': {
set: 'topics',
type: 'topics',
@ -82,6 +88,10 @@ postsController.getWatchedTopics = function (req, res, next) {
getFromUserSet('account/watched', req, res, next);
};
postsController.getIgnoredTopics = function (req, res, next) {
getFromUserSet('account/ignored', req, res, next);
};
postsController.getTopics = function (req, res, next) {
getFromUserSet('account/topics', req, res, next);
};
@ -93,6 +103,7 @@ function getFromUserSet(template, req, res, callback) {
var userData;
var itemsPerPage;
var page = Math.max(1, parseInt(req.query.page, 10) || 1);
async.waterfall([
function (next) {
async.parallel({
@ -130,23 +141,20 @@ function getFromUserSet(template, req, res, callback) {
},
}, next);
},
], function (err, results) {
if (err) {
return callback(err);
}
userData[data.type] = results.data[data.type];
userData.nextStart = results.data.nextStart;
function (results) {
userData[data.type] = results.data[data.type];
userData.nextStart = results.data.nextStart;
var pageCount = Math.ceil(results.itemCount / itemsPerPage);
userData.pagination = pagination.create(page, pageCount);
var pageCount = Math.ceil(results.itemCount / itemsPerPage);
userData.pagination = pagination.create(page, pageCount);
userData.noItemsFoundKey = data.noItemsFoundKey;
userData.title = '[[pages:' + data.template + ', ' + userData.username + ']]';
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: data.crumb }]);
userData.noItemsFoundKey = data.noItemsFoundKey;
userData.title = '[[pages:' + data.template + ', ' + userData.username + ']]';
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: data.crumb }]);
res.render(data.template, userData);
});
res.render(data.template, userData);
},
], callback);
}
module.exports = postsController;

@ -19,6 +19,7 @@ module.exports = function (app, middleware, controllers) {
setupPageRoute(app, '/user/:userslug/bookmarks', middleware, accountMiddlewares, controllers.accounts.posts.getBookmarks);
setupPageRoute(app, '/user/:userslug/watched', middleware, accountMiddlewares, controllers.accounts.posts.getWatchedTopics);
setupPageRoute(app, '/user/:userslug/ignored', middleware, accountMiddlewares, controllers.accounts.posts.getIgnoredTopics);
setupPageRoute(app, '/user/:userslug/upvoted', middleware, accountMiddlewares, controllers.accounts.posts.getUpVotedPosts);
setupPageRoute(app, '/user/:userslug/downvoted', middleware, accountMiddlewares, controllers.accounts.posts.getDownVotedPosts);
setupPageRoute(app, '/user/:userslug/edit', middleware, accountMiddlewares, controllers.accounts.edit.get);

@ -945,6 +945,15 @@ describe('Controllers', function () {
});
});
it('should load /user/foo/ignored', function (done) {
request(nconf.get('url') + '/api/user/foo/ignored', { jar: jar }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
done();
});
});
it('should load /user/foo/topics', function (done) {
request(nconf.get('url') + '/api/user/foo/topics', function (err, res, body) {
assert.ifError(err);

Loading…
Cancel
Save