diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-12-10 14:21:24 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-12-10 14:21:24 -0500 |
| commit | f9ece85045a9766ff6381ed26ef663aa718f2bca (patch) | |
| tree | 64fbceecb5c0826aa2d30cd496c4b9971d3b9204 | |
| parent | 188f63d9315499e46633a94eb42f108556b94414 (diff) | |
| parent | f7475059dadf25161471e8b3086d127a1d1545f9 (diff) | |
merge
| -rw-r--r-- | server/lib/views/index.js | 16 | ||||
| -rw-r--r-- | views/profile.ejs | 2 |
2 files changed, 14 insertions, 4 deletions
diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 6ceef7e..8c3e63d 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -171,15 +171,20 @@ var views = module.exports = { if ( ! isOwnProfile ) { criteria.privacy = false } - views_middleware.fetchProjects(criteria, null, null, done) + views_middleware.fetchProjects(criteria, null, null, function(err, projects){ + views_middleware.fetchUserProjectCount(criteria, function(projectCount){ + done(err, projects, projectCount) + }) + }) } - function done(err, projects){ + function done(err, projects, projectCount){ if (! user) { return res.redirect('/') } res.render('profile', { isOwnProfile: isOwnProfile, profile: user, projects: projects || [], + projectCount: projectCount, ogTitle: "VValls: Profile of " + user.displayName, ogUrl: "http://vvalls.com/profile/" + user.username + "/", ogImage: user.photo, @@ -240,5 +245,10 @@ var views_middleware = { }) next(err, projects) }) - } + }, + fetchUserProjectCount: function(criteria, next){ + Project.count(criteria, function(err, count){ + next(count || 0) + }) + }, } diff --git a/views/profile.ejs b/views/profile.ejs index 5043df6..a62652c 100644 --- a/views/profile.ejs +++ b/views/profile.ejs @@ -46,7 +46,7 @@ [[ if (projects.length) { ]] - <h1>[[- profile.username ]] has [[- projects.length ]] project[[- projects.length != 1 ? "s" : "" ]]</h1> + <h1>[[- profile.username ]] has [[- projectCount ]] project[[- projectCount != 1 ? "s" : "" ]]</h1> [[ include projects/list-projects ]] [[ } else { ]] |
