This PR makes various improvements to the user profile views, controllers, and routes.
Motivation
Currently the user profile page at the /news/user/:id is built with the same news/index.jade view as the homepage. It manages this with a big switch filteredUser. This requires any change to the user profile page to touch the homepage which makes it harder to make both user profile changes and homepage news changes.
Additionally, the user profile page itself (embedded in index.jade) is a single page view with tabs for news, comments, and contributions. This means we don't link directly to a user's comments or contributions, and the user profile controller has to fetch all the user news items, comments, and contributions for every profile request.
Details
This PR breaks the user profile page out of the index.jade, creating a profile.jade layout view containing the header information (picture, bio, website, etc), and three separate views for user news, comments, and contributions. This allows us to have these routes:
/news => homepage, displays paginated news
/user/:id => user profile index, displays submitted news by default
/user/:id/comments => user comments
/user/:id/contributions => user contributions
When each of these pages load, the individualized controller will only load the data needed to render that page. For example, the /news route will not load the user profile information, and the /user/:id route will not load the comment or contributions.
Notes
All links to /news/user/:id have been updated to /user/:id
We're 301 redirecting /news/user/:id to /user/:id
Each profile view has it's own controller with only the data it needs to render that view
Moved the contribution count from Ajax server-side
Gutted the filtered-user data element, newsIndex.js, and the ajaxController
Moved the news list to a partial imported from news/index.jade and profile/news.jade
Overview
This PR makes various improvements to the user profile views, controllers, and routes.
Motivation
Currently the user profile page at the
/news/user/:id
is built with the samenews/index.jade
view as the homepage. It manages this with a big switchfilteredUser
. This requires any change to the user profile page to touch the homepage which makes it harder to make both user profile changes and homepage news changes.Additionally, the user profile page itself (embedded in
index.jade
) is a single page view with tabs for news, comments, and contributions. This means we don't link directly to a user's comments or contributions, and the user profile controller has to fetch all the user news items, comments, and contributions for every profile request.Details
This PR breaks the user profile page out of the index.jade, creating a
profile.jade
layout view containing the header information (picture, bio, website, etc), and three separate views for user news, comments, and contributions. This allows us to have these routes:/news
=> homepage, displays paginated news/user/:id
=> user profile index, displays submitted news by default/user/:id/comments
=> user comments/user/:id/contributions
=> user contributionsWhen each of these pages load, the individualized controller will only load the data needed to render that page. For example, the
/news
route will not load the user profile information, and the/user/:id
route will not load the comment or contributions.Notes
/news/user/:id
have been updated to/user/:id
/news/user/:id
to/user/:id
filtered-user
data element,newsIndex.js
, and theajaxController
news/index.jade
andprofile/news.jade