Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified navbar #4

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/com/codeup/adlister/controllers/CounterServlet.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.codeup.adlister.controllers;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "controllers.EditProfileServlet", urlPatterns = "/edit-profile")
public class EditProfileServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (request.getSession().getAttribute("user") == null) {
response.sendRedirect("/login");
return;
}
request.getRequestDispatcher("/WEB-INF/editProfile.jsp")
.forward(request, response);
}
}

This file was deleted.

16 changes: 16 additions & 0 deletions src/main/webapp/WEB-INF/editProfile.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<jsp:include page="/WEB-INF/partials/head.jsp">
<jsp:param name="title" value="Your Profile" />
</jsp:include>
</head>
<body>
<jsp:include page="/WEB-INF/partials/userNavbar.jsp" />

<div class="container">
<h1>Edit your profile below ${sessionScope.user.username}!</h1>
</div>

</body>
</html>
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/partials/head.jsp
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<title>${param.title}</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
1 change: 0 additions & 1 deletion src/main/webapp/WEB-INF/partials/navbar.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="/login">Login</a></li>
<li><a href="/logout">Logout</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
Expand Down
12 changes: 12 additions & 0 deletions src/main/webapp/WEB-INF/partials/userNavbar.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href="/ads">Adlister</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="/ads/create">Create New Ad!</a></li>
<li><a href="/logout">Logout</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
29 changes: 26 additions & 3 deletions src/main/webapp/WEB-INF/profile.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,34 @@
</jsp:include>
</head>
<body>
<jsp:include page="/WEB-INF/partials/navbar.jsp" />
<jsp:include page="/WEB-INF/partials/userNavbar.jsp" />

<div class="container">
<h1>Welcome, ${sessionScope.user.username}!</h1>
<div class="card" style="width: 18rem;">
<img src="https://cdn.vectorstock.com/i/1000x1000/15/40/blank-profile-picture-image-holder-with-a-crown-vector-42411540.webp" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><h2>Welcome, ${sessionScope.user.username}!</h2></h5>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item"><h4>${sessionScope.user.email}!</h4></li>
</ul>
<div class="card-body">
<a href="/edit-profile" class="card-link">Edit Profile</a>
<a href="/ads">Your Ads!</a>
</div>
</div>

<%-- <div class="container">--%>
<%-- <h1>Welcome, ${sessionScope.user.username}!</h1>--%>
<%-- </div>--%>

</body>
</html>


<%--//TODO The profile page should display the username and email of the logged-in user and a list of links to all the ads a user has created in the AdLister.&ndash;%&gt;--%>

<%--//TODO When a user logs in the user should be redirected to their profile page.--%>
<%--done--%>

<%--//TODO The profile view should only be accessible to users that are logged in.--%>
<%--done--%>