- if a user is logged in, the header shows:
- the user's username
- a HOME Link to
/resources
- a profile Link
- make GET request to
/profile
- make GET request to
- a search bar
- make a GET request to
/search
- make a GET request to
- a logout button
- makes a POST request to
/logout
- makes a POST request to
GET /
- if user is logged in:
- redirect to
/resources
- redirect to
- if user is not logged in:
- redirect to
/login
- redirect to
GET /resources
- if user is logged in:
- return HTML with
- the site header
- a list (or table) of resources the user has created, each list item containing:
- Title link to
/resources/:id
- The resource URL
- redirect to
- Description
- Tags
- Like
- unlike button
- make a DELETE request to
/delete
- Title link to
- (stretch) a side bar contains all the tags user had
- each tag link make a GET request to
/resources/:tagid
- each tag link make a GET request to
- if user is not logged in:
- redirect to
/login
- redirect to
GET /resources/new
- if user is logged in:
- return HTML with
- the site header
- a form which contains:
- a Title
- a text input field for the URL
- an optional Description
- Tags
- mark it as Like for the given user
- a submit button
- makes a POST request to
/resources
- makes a POST request to
- if user is not logged in:
- redirects to the /login page
GET /resources/:id
- if user is logged in:
- return HTML with
- the site header
- Title
- URL
- Description
- Tag
- Comments input form
- Comments Submit button
- make a POST request to
/resources/:id
- make a POST request to
- Like button
- like
- make a POST request to
/like
- make a POST request to
- unlike
- make a DELETE request to
/delete
- make a DELETE request to
- like
- Rating input form
- if user is not logged in:
- redirect to
/login
- redirect to
- if resources id not exist:
- returns HTML with a relevant error message
GET /resources/:id/profile
- if user is logged in:
- return HTML with
- the site header
- edit Username
- edit email
- edit password
- a Submit button
- make a POST request to
/resources/:id/profile
- make a POST request to
- if user is not logged in:
- redirect to
/login
- redirect to
- if resources id not exist:
- returns HTML with a relevant error message
PUT /resources/:id/profile
- if user is logged in:
- update username/ email/ password
- if user is not logged in:
- redirect to
/login
- redirect to
POST /resources
- if user is logged in:
- create a new row in resource table
- create a new row in tag table
- create a new row in like table
- redirect to
/resources
- if user is not logged in:
- redirect to
/login
- redirect to
PUT /resources/:id
- if user is logged in:
- update the comment
- update rating
- update like
- make a POST request to
/resources
- make a POST request to
- if user is not logged in:
- redirect to
/login
- redirect to
POST /like
- if user is logged in:
- create a new row in like table
- if user is not logged in:
- redirect to
/login
- redirect to
DELETE /delete
- if user is logged in:
- delete a row in like table
- if user is not logged in:
- redirect to
/login
- redirect to
GET /search
- if user is logged in:
- show the search result
- if user is not logged in:
- redirect to
/login
(stretch)GET /resources/:tagid
- redirect to
- if user is logged in:
- show all the resources belong to that tag
- if user is not logged in:
- redirect to
/login
(stretch)PUT /resources/:tagid
- redirect to
- if user is logged in:
- update resources belong to tag
- if user is not logged in:
- redirect to
/login
- redirect to
GET /login
- if user is logged in:
- redirects to
/resources
- redirects to
- if user is not logged in:
- returns HTML with:
- a login form which contains:
- input fields for email and password
- submit button that
- makes a POST request to
/login
- makes a POST request to
- a register form which contains:
- input fields for email and password
- a register button
- makes a POST request to
/register
- makes a POST request to
POST /login
- if email and password params match an existing user:
- sets a cookie
- redirects to
/resources
- if email and password params don’t match an existing user:
- returns HTML with a relevant error message
POST /register
- if email or password are empty:
- returns HTML with a relevant error message
- if email already exists:
- returns HTML with a relevant error message
- otherwise:
- creates a new user
- encrypts the new user’s password with
bcrypt
- sets a cookie
- redirects to
/resources
POST /logout
- deletes cookie
- redirects to
/login