larvalabs / pullup

A website you join via pull request.
http://pullup.io
MIT License
319 stars 240 forks source link

Refactor user profile views, controllers, and routes #398

Closed rickhanlonii closed 8 years ago

rickhanlonii commented 8 years ago

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 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