From ecfdee7a1a08ef2c3f1a79330da8b58655d002bb Mon Sep 17 00:00:00 2001 From: Adrien Date: Thu, 15 Oct 2026 11:35:58 +0200 Subject: [PATCH] =?UTF-8?q?Vid=C3=A9o=20et=20commentaires=20s'affiche=20av?= =?UTF-8?q?ec=20le=20param=C3=A8tre=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/dao/CommentDao.java | 3 + src/main/java/servlet/VideoServlet.java | 51 +++++- src/main/webapp/WEB-INF/home.jsp | 4 +- src/main/webapp/WEB-INF/video.jsp | 25 ++- src/main/webapp/assets/css/style.css | 219 ++++++++++++++++-------- 5 files changed, 207 insertions(+), 95 deletions(-) diff --git a/src/main/java/dao/CommentDao.java b/src/main/java/dao/CommentDao.java index 8325322..3d3f9b2 100644 --- a/src/main/java/dao/CommentDao.java +++ b/src/main/java/dao/CommentDao.java @@ -242,6 +242,7 @@ public class CommentDao extends Dao { comment.setId(rs.getInt(("Id_Comment"))); comment.setContent(rs.getString("content")); comment.setStatutComment(rs.getInt("status_comment")); + comment.setDatePublish(rs.getDate("date_publish")); Post post = new Post(); post.setId(rs.getInt("Id_Post")); @@ -251,6 +252,8 @@ public class CommentDao extends Dao { author.setId((rs.getInt(("Id_User")))); author.setUsername(rs.getString("username")); author.setStatut((rs.getString("status_user"))); + + comment.setAuthor(author); comments.add(comment); } diff --git a/src/main/java/servlet/VideoServlet.java b/src/main/java/servlet/VideoServlet.java index 7ec6150..8345a15 100644 --- a/src/main/java/servlet/VideoServlet.java +++ b/src/main/java/servlet/VideoServlet.java @@ -1,6 +1,8 @@ package servlet; +import beans.Comment; import beans.Post; +import dao.CommentDao; import dao.DaoFactory; import dao.PostDao; import jakarta.servlet.ServletException; @@ -9,7 +11,9 @@ import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @@ -17,15 +21,50 @@ import java.util.List; */ @WebServlet(name = "Video", urlPatterns = {"/video"}) public class VideoServlet extends HttpServlet { - + private static final String VIEW = "/WEB-INF/video.jsp"; - + @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PostDao postDao = DaoFactory.getPostDao(); - List posts = postDao.list(); - request.setAttribute("posts", posts); + + // Récupère l'id du Post en paramètre + String idParam = request.getParameter("id"); + + if (idParam == null) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "ID de vidéo introuvable"); + return; + } + + Long postId; + // Change le String en Long + try { + postId = Long.parseLong(idParam); + } catch (NumberFormatException e) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST); + return; + } + + Post post = postDao.find(postId); + + request.setAttribute("post", post); + + // COMMENTAIRES + CommentDao commentDao = DaoFactory.getCommentDao(); + + // Change le String en int + int postIdInt; + try { + postIdInt = Integer.parseInt(idParam); + } catch (NumberFormatException e) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST); + return; + } + List commentsList = commentDao.listPerPost(postIdInt); + request.setAttribute("comments", commentsList); + + this.getServletContext().getRequestDispatcher(VIEW).forward(request, response); } -} \ No newline at end of file +} diff --git a/src/main/webapp/WEB-INF/home.jsp b/src/main/webapp/WEB-INF/home.jsp index 48563b2..6df8b46 100644 --- a/src/main/webapp/WEB-INF/home.jsp +++ b/src/main/webapp/WEB-INF/home.jsp @@ -46,7 +46,7 @@ @@ -75,7 +75,7 @@ diff --git a/src/main/webapp/WEB-INF/video.jsp b/src/main/webapp/WEB-INF/video.jsp index e009783..64921bc 100644 --- a/src/main/webapp/WEB-INF/video.jsp +++ b/src/main/webapp/WEB-INF/video.jsp @@ -4,6 +4,7 @@ Author : Adrien --%> <%@ taglib prefix="c" uri="jakarta.tags.core" %> +<%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %> <%@page contentType="text/html" pageEncoding="UTF-8"%> @@ -18,24 +19,22 @@
- +
-
360 flip par Jean-Guy
-

13 Octobre 2026

+
${post.title} par @${post.author.username}
+ +

Publié le

thumbs up -

340

+

${post.score}

thumbs down

-

- Dans cette vidéo, je te montre comment réussir ton premier kickflip. On commence par la position des pieds, puis le mouvement de cheville et enfin l'atterrissage. - Regarde les ralentis pour bien comprendre le timing. N'oublie pas de protéger tes genoux et de commencer sur une surface plane. -

+

${post.description}

@@ -47,13 +46,13 @@
- -
+ +
Profile picture
-

Amina Benali

-

13 Octobre 2026

-

"Reception propre comme jamais vue, c’est ça la différence entre un trick qui passe et un trick propre."

+

${thisComment.author.username}

+

Publié le

+

${thisComment.content}

Signaler

diff --git a/src/main/webapp/assets/css/style.css b/src/main/webapp/assets/css/style.css index 9cc3207..4698c94 100644 --- a/src/main/webapp/assets/css/style.css +++ b/src/main/webapp/assets/css/style.css @@ -349,118 +349,164 @@ a, button, input[type="submit"], input[type="button"] { /*------------------- JSP REGISTER / LOGIN ------------ */ -.textRegister, .textLogin{ - color: white; - font-family: 'Permanent Marker', cursive; - font-size: 20px; +/*------------------- JSP VIDEO ------------ */ +.main-video { + display: flex; + justify-content: center; + width: 100%; + padding: 40px 20px; + box-sizing: border-box; } -.mainRegister, .mainLogin, .mainProfile{ - margin: 20px 70px 20px 70px; +.main-video .video { + flex: 0 1 900px; + width: 100%; + max-width: 900px; + box-sizing: border-box; } -.register-container, .login-container, .addPost-container { - background-color: black; - padding: 50px; - border-radius: 24px; +.main-video .video-player { + width: 100%; + aspect-ratio: 16 / 9; +} + +.main-video .video-player iframe { + display: block; + width: 100%; + height: 100%; + border: none; +} + +.title { display: flex; justify-content: space-between; align-items: center; - gap: 40px; - margin: 20px 70px; + width: 100%; } -.imgRegister, .imgLogin { - width: 40%; - height: auto; +.title > div:first-child { + text-align: left; } -.formRegister, .formLogin, .formAddPost{ +.title > div:last-child { + display: flex; + align-items: center; + gap: 10px; +} - color: white; - flex: 1; +.title > div:last-child img { + width: 36px; + height: 36px; } -.noLabel{ - width: 187px; - height: 62px; - background-color: #00f3fb; - border-radius: 50px; - box-shadow: 0px 6px 4px 6px rgba(0, 243, 251, 0.25), 0px -6px 4px 0px rgba(0, 243, 251, 0.25), 6px 0px 4px 0px rgba(0, 243, 251, 0.25), -6px 0px 4px 0px rgba(0, 243, 251, 0.25); - display: flex; - flex-direction: row; - font-size: 25px; - font-family: 'Permanent Marker', cursive; - margin-top: 20px; +.title > div:last-child p { + font-size: 22px; + font-weight: bold; +} +.title h5, +.title p { + margin: 5px 0; } -.labelRegister, .labelLogin, .labelAddPost{ - display:inline-block; - width: 250px; - margin-bottom: 10px; +.title img { + width: 24px; + height: 24px; + object-fit: contain; } -.mandatory { - color: #FB3FA6; +.main-video .video > p { + font-weight: bold; + margin-top: 15px; } -.error{ - color: #FB3FA6; +.comments { + background-color: black; + width: 66%; + margin: 20px auto; + box-sizing: border-box; + border-radius: 12px; + border: 2px solid #ff9ed0; + box-shadow: + 0 0 8px #ff9ed0, + 0 0 18px #e84393, + 0 0 35px #e84393, + 0 0 55px rgba(232, 67, 147, 0.8); } -/*------------------- JSP LOGIN ------------ */ +.comments h2 { + font-size: 40px; +} -.success{ - color:#DBFA19 +.comment-form { + display: flex; + align-items: flex-start; + gap: 15px; + width: 100%; + max-width: 800px; + margin: 25px auto; } -/*------------------- JSP Profile ------------ */ -.profile-videos-container { - display: grid; - grid-template-columns: repeat(2, 1fr); - gap: 20px; +.comment-avatar { + width: 55px; + height: 55px; + border-radius: 50%; + object-fit: cover; + flex-shrink: 0; +} +.comment-input { + position: relative; + flex: 1; + min-width: 0; } -.userVideos{ - margin: 50px; +.comment-input textarea { + display: block; + width: 100%; + box-sizing: border-box; + padding: 15px; + resize: vertical; + + border: 2px solid #ff9ed0; + border-radius: 12px; + background: #1e1e2f; + color: white; + font: inherit; } -.emptyMessage{ - color: #FB3FA6; +.comment-input textarea:focus { + outline: none; } -.button-container-profile{ - display: flex; - align-items: center; - justify-content: center; - gap: 20px; +.comment-input .yellowButton { + position: absolute; + right: 10px; + bottom: 10px; + cursor: pointer; } -.watchButton{ - padding: 12px 24px; - background-color: #DBFA19; - color: #222; - font-family: 'Permanent Marker', cursive; - text-decoration: none; - font-weight: bold; - font-size: 25px; - border-radius: 45px; - border: 2px solid #fff176; - box-shadow: - 0 0 5px #ffeb3b, - 0 0 10px #ffd500, - 0 0 20px rgba(255, 213, 0, 0.7); +.grey { + color: grey; +} +.user-comment { + display: flex; + gap: 15px; + margin: 25px auto; + max-width: 800px; + color: white; } -.deleteButton{ - padding: 12px 24px; - background-color: #FA3FA6; - color: #222; - font-family: 'Permanent Marker', cursive; - text-decoration: none; +.user-comment div { + border: 2px solid #ff9ed0; + border-radius: 12px; + background: #1e1e2f; + padding: 15px; +} + +.user-comment p { + margin: 0; font-weight: bold; font-size: 25px; border-radius: 45px; @@ -473,4 +519,29 @@ a, button, input[type="submit"], input[type="button"] { 0 0 10px rgba(232, 67, 147, 0.8); } +.user-comments { + display: flex; + gap: 15px; + margin: 25px auto; + max-width: 800px; + color: white; +} + +.user-comments div { + border: 2px solid #ff9ed0; + border-radius: 12px; + background: #1e1e2f; + padding: 15px; +} +.user-comments p { + margin: 0; + font-weight: bold; + font-size: 25px; + border-radius: 45px; + cursor: url('../img/cursor.png'), pointer; +} + +#message { + margin: 10px 0; +} -- GitLab