From cb9b51e8a5e050677783fd54da20358392e8adfd Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 11 Sep 2015 23:57:46 -0400 Subject: [PATCH] closes #3475 --- src/controllers/accounts.js | 19 +++++++++++++------ src/controllers/categories.js | 3 +++ src/controllers/groups.js | 9 +++++++++ src/controllers/popular.js | 5 ++++- src/controllers/recent.js | 4 +++- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/controllers/accounts.js b/src/controllers/accounts.js index c3537f578a..2aa1bfcfe5 100644 --- a/src/controllers/accounts.js +++ b/src/controllers/accounts.js @@ -175,9 +175,11 @@ accountsController.getAccount = function(req, res, next) { userData.posts = results.posts.posts.filter(function (p) { return p && parseInt(p.deleted, 10) !== 1; }); + userData.aboutme = results.aboutme; userData.nextStart = results.posts.nextStart; userData.isFollowing = results.isFollowing; + userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username}]); if (!userData.profileviews) { userData.profileviews = 1; @@ -224,25 +226,26 @@ function getFollow(tpl, name, req, res, callback) { userData.users = users; userData.nextStart = 50; userData.title = '[[pages:' + tpl + ', ' + userData.username + ']]'; + userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:' + name + ']]'}]); res.render(tpl, userData); }); } accountsController.getFavourites = function(req, res, next) { - getFromUserSet('account/favourites', 'favourites', posts.getPostSummariesFromSet, 'posts', req, res, next); + getFromUserSet('account/favourites', 'favourites', '[[user:favourites]]', posts.getPostSummariesFromSet, 'posts', req, res, next); }; accountsController.getPosts = function(req, res, next) { - getFromUserSet('account/posts', 'posts', posts.getPostSummariesFromSet, 'posts', req, res, next); + getFromUserSet('account/posts', 'posts', '[[global:posts]]', posts.getPostSummariesFromSet, 'posts', req, res, next); }; accountsController.getWatchedTopics = function(req, res, next) { - getFromUserSet('account/watched', 'followed_tids', topics.getTopicsFromSet, 'topics', req, res, next); + getFromUserSet('account/watched', 'followed_tids', '[[user:watched]]',topics.getTopicsFromSet, 'topics', req, res, next); }; accountsController.getTopics = function(req, res, next) { - getFromUserSet('account/topics', 'topics', topics.getTopicsFromSet, 'topics', req, res, next); + getFromUserSet('account/topics', 'topics', '[[global:topics]]', topics.getTopicsFromSet, 'topics', req, res, next); }; accountsController.getGroups = function(req, res, next) { @@ -259,12 +262,13 @@ accountsController.getGroups = function(req, res, next) { userData.groups = groupsData[0]; userData.groups.forEach(groups.escapeGroupData); userData.title = '[[pages:account/groups, ' + userData.username + ']]'; + userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[global:header.groups]]'}]); res.render('account/groups', userData); }); }); }; -function getFromUserSet(tpl, set, method, type, req, res, next) { +function getFromUserSet(tpl, set, crumb, method, type, req, res, next) { async.parallel({ settings: function(next) { user.getSettings(req.uid, next); @@ -310,6 +314,7 @@ function getFromUserSet(tpl, set, method, type, req, res, next) { userData.pagination = pagination.create(page, pageCount); userData.title = '[[pages:' + tpl + ', ' + userData.username + ']]'; + userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: crumb}]); res.render(tpl, userData); }); @@ -371,6 +376,7 @@ accountsController.accountEdit = function(req, res, callback) { userData.hasPassword = !!password; userData.title = '[[pages:account/edit, ' + userData.username + ']]'; + userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:edit]]'}]); res.render('account/edit', userData); }); }; @@ -457,6 +463,7 @@ accountsController.accountSettings = function(req, res, callback) { userData.disableCustomUserSkins = parseInt(meta.config.disableCustomUserSkins, 10) === 1; userData.title = '[[pages:account/settings]]'; + userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:settings]]'}]); res.render('account/settings', userData); }); @@ -587,7 +594,7 @@ accountsController.getChats = function(req, res, callback) { messages: data.messages, allowed: data.allowed, title: '[[pages:chat, ' + data.toUser.username + ']]', - breadcrumbs: helpers.buildBreadcrumbs([{text: '[[pages:chats]]', url: nconf.get('relative_path') + '/chats'}, {text: data.toUser.username}]) + breadcrumbs: helpers.buildBreadcrumbs([{text: '[[pages:chats]]', url: '/chats'}, {text: data.toUser.username}]) }); }); }); diff --git a/src/controllers/categories.js b/src/controllers/categories.js index b770598311..438e970c99 100644 --- a/src/controllers/categories.js +++ b/src/controllers/categories.js @@ -66,6 +66,9 @@ categoriesController.list = function(req, res, next) { } data.title = '[[pages:categories]]'; + if (req.path.startsWith('/api/categories') || req.path.startsWith('/categories')) { + data.breadcrumbs = helpers.buildBreadcrumbs([{text: data.title}]); + } plugins.fireHook('filter:categories.build', {req: req, res: res, templateData: data}, function(err, data) { if (err) { diff --git a/src/controllers/groups.js b/src/controllers/groups.js index 2d4f97bc89..72150cdf79 100644 --- a/src/controllers/groups.js +++ b/src/controllers/groups.js @@ -17,6 +17,7 @@ groupsController.list = function(req, res, next) { return next(err); } data.title = '[[pages:groups]]'; + data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:groups]]'}]); res.render('groups/list', data); }); }; @@ -90,6 +91,7 @@ groupsController.details = function(req, res, callback) { } results.title = '[[pages:group, ' + results.group.displayName + ']]'; + results.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:groups]]', url: '/groups' }, {text: results.group.slug}]); res.render('groups/details', results); }); }); @@ -108,10 +110,17 @@ groupsController.members = function(req, res, next) { return next(err); } + var breadcrumbs = helpers.buildBreadcrumbs([ + {text: '[[pages:groups]]', url: '/groups' }, + {text: req.params.slug, url: '/groups/' + req.params.slug}, + {text: '[[groups:details.members]]'} + ]); + res.render('groups/members', { users: users, nextStart: 50, loadmore_display: users.length > 50 ? 'block' : 'hide', + breadcrumbs: breadcrumbs }); }); }; diff --git a/src/controllers/popular.js b/src/controllers/popular.js index 9a39af45f6..6f80254f47 100644 --- a/src/controllers/popular.js +++ b/src/controllers/popular.js @@ -36,10 +36,13 @@ 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', - breadcrumbs: helpers.buildBreadcrumbs([{text: '[[global:header.popular]]'}]), title: '[[pages:popular-' + term + ']]' }; + if (req.path.startsWith('/api/popular') || req.path.startsWith('/popular')) { + data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:header.popular]]'}]); + } + if (!req.uid) { anonCache[term] = data; lastUpdateTime = Date.now(); diff --git a/src/controllers/recent.js b/src/controllers/recent.js index a7f0cfca8a..93cd2a9d09 100644 --- a/src/controllers/recent.js +++ b/src/controllers/recent.js @@ -20,8 +20,10 @@ recentController.get = 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]]'}]); data.title = '[[pages:recent]]'; + if (req.path.startsWith('/api/recent') || req.path.startsWith('/recent')) { + data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[recent:title]]'}]); + } plugins.fireHook('filter:recent.build', {req: req, res: res, templateData: data}, function(err, data) { if (err) {