|
|
|
@ -13,91 +13,83 @@ var accountHelpers = require('./helpers');
|
|
|
|
|
|
|
|
|
|
var postsController = {};
|
|
|
|
|
|
|
|
|
|
postsController.getBookmarks = function (req, res, next) {
|
|
|
|
|
var data = {
|
|
|
|
|
template: 'account/bookmarks',
|
|
|
|
|
var templateToData = {
|
|
|
|
|
'account/bookmarks': {
|
|
|
|
|
set: 'bookmarks',
|
|
|
|
|
type: 'posts',
|
|
|
|
|
noItemsFoundKey: '[[topic:bookmarks.has_no_bookmarks]]',
|
|
|
|
|
method: posts.getPostSummariesFromSet,
|
|
|
|
|
crumb: '[[user:bookmarks]]'
|
|
|
|
|
};
|
|
|
|
|
getFromUserSet(data, req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getPosts = function (req, res, next) {
|
|
|
|
|
var data = {
|
|
|
|
|
template: 'account/posts',
|
|
|
|
|
},
|
|
|
|
|
'account/posts': {
|
|
|
|
|
set: 'posts',
|
|
|
|
|
type: 'posts',
|
|
|
|
|
noItemsFoundKey: '[[user:has_no_posts]]',
|
|
|
|
|
method: posts.getPostSummariesFromSet,
|
|
|
|
|
crumb: '[[global:posts]]'
|
|
|
|
|
};
|
|
|
|
|
getFromUserSet(data, req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getUpVotedPosts = function (req, res, next) {
|
|
|
|
|
var data = {
|
|
|
|
|
template: 'account/upvoted',
|
|
|
|
|
},
|
|
|
|
|
'account/upvoted': {
|
|
|
|
|
set: 'upvote',
|
|
|
|
|
type: 'posts',
|
|
|
|
|
noItemsFoundKey: '[[user:has_no_upvoted_posts]]',
|
|
|
|
|
method: posts.getPostSummariesFromSet,
|
|
|
|
|
crumb: '[[global:upvoted]]'
|
|
|
|
|
};
|
|
|
|
|
getFromUserSet(data, req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getDownVotedPosts = function (req, res, next) {
|
|
|
|
|
var data = {
|
|
|
|
|
template: 'account/downvoted',
|
|
|
|
|
},
|
|
|
|
|
'account/downvoted': {
|
|
|
|
|
set: 'downvote',
|
|
|
|
|
type: 'posts',
|
|
|
|
|
noItemsFoundKey: '[[user:has_no_downvoted_posts]]',
|
|
|
|
|
method: posts.getPostSummariesFromSet,
|
|
|
|
|
crumb: '[[global:downvoted]]'
|
|
|
|
|
};
|
|
|
|
|
getFromUserSet(data, req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getBestPosts = function (req, res, next) {
|
|
|
|
|
var data = {
|
|
|
|
|
template: 'account/best',
|
|
|
|
|
},
|
|
|
|
|
'account/best': {
|
|
|
|
|
set: 'posts:votes',
|
|
|
|
|
type: 'posts',
|
|
|
|
|
noItemsFoundKey: '[[user:has_no_voted_posts]]',
|
|
|
|
|
method: posts.getPostSummariesFromSet,
|
|
|
|
|
crumb: '[[global:best]]'
|
|
|
|
|
};
|
|
|
|
|
getFromUserSet(data, req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getWatchedTopics = function (req, res, next) {
|
|
|
|
|
var data = {
|
|
|
|
|
template: 'account/watched',
|
|
|
|
|
},
|
|
|
|
|
'account/watched': {
|
|
|
|
|
set: 'followed_tids',
|
|
|
|
|
type: 'topics',
|
|
|
|
|
noItemsFoundKey: '[[user:has_no_watched_topics]]',
|
|
|
|
|
method: topics.getTopicsFromSet,
|
|
|
|
|
crumb: '[[user:watched]]'
|
|
|
|
|
};
|
|
|
|
|
getFromUserSet(data, req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getTopics = function (req, res, next) {
|
|
|
|
|
var data = {
|
|
|
|
|
template: 'account/topics',
|
|
|
|
|
},
|
|
|
|
|
'account/topics': {
|
|
|
|
|
set: 'topics',
|
|
|
|
|
type: 'topics',
|
|
|
|
|
noItemsFoundKey: '[[user:has_no_topics]]',
|
|
|
|
|
method: topics.getTopicsFromSet,
|
|
|
|
|
crumb: '[[global:topics]]'
|
|
|
|
|
};
|
|
|
|
|
getFromUserSet(data, req, res, next);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getBookmarks = function (req, res, next) {
|
|
|
|
|
getFromUserSet('account/bookmarks', req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getPosts = function (req, res, next) {
|
|
|
|
|
getFromUserSet('account/posts', req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getUpVotedPosts = function (req, res, next) {
|
|
|
|
|
getFromUserSet('account/upvoted', req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getDownVotedPosts = function (req, res, next) {
|
|
|
|
|
getFromUserSet('account/downvoted', req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getBestPosts = function (req, res, next) {
|
|
|
|
|
getFromUserSet('account/best', req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getWatchedTopics = function (req, res, next) {
|
|
|
|
|
getFromUserSet('account/watched', req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postsController.getTopics = function (req, res, next) {
|
|
|
|
|
getFromUserSet('account/topics', req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function getFromUserSet(data, req, res, callback) {
|
|
|
|
|
function getFromUserSet(template, req, res, callback) {
|
|
|
|
|
var data = templateToData[template];
|
|
|
|
|
data.template = template;
|
|
|
|
|
data.method = data.type === 'posts' ? posts.getPostSummariesFromSet : topics.getTopicsFromSet;
|
|
|
|
|
var userData;
|
|
|
|
|
var itemsPerPage;
|
|
|
|
|
var page = Math.max(1, parseInt(req.query.page, 10) || 1);
|
|
|
|
|