From adbb673045a4c11953d954beaa8a7231f4f6f871 Mon Sep 17 00:00:00 2001 From: kmitresse Date: Wed, 12 Jun 2024 18:38:45 +0200 Subject: [PATCH] feat: devweb - update index.html to index.jsp --- .../project/web/servlet/IndexServlet.java | 3 +- .../src/main/webapp/WEB-INF/pages/index.jsp | 37 ++++--- .../webapp/WEB-INF/tags/components/navbar.tag | 2 +- .../src/main/webapp/WEB-INF/translations.json | 18 ++-- S2/DevWeb/Projet/src/main/webapp/index.html | 96 +------------------ .../src/main/webapp/static/js/rewriteUrl.js | 11 +++ 6 files changed, 51 insertions(+), 116 deletions(-) create mode 100644 S2/DevWeb/Projet/src/main/webapp/static/js/rewriteUrl.js diff --git a/S2/DevWeb/Projet/src/main/java/uppa/project/web/servlet/IndexServlet.java b/S2/DevWeb/Projet/src/main/java/uppa/project/web/servlet/IndexServlet.java index 6019f79..f815765 100644 --- a/S2/DevWeb/Projet/src/main/java/uppa/project/web/servlet/IndexServlet.java +++ b/S2/DevWeb/Projet/src/main/java/uppa/project/web/servlet/IndexServlet.java @@ -14,7 +14,7 @@ import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import uppa.project.web.translation.Translator; -@WebServlet(name = "indexServlet", value = "/index") +@WebServlet(name = "indexServlet", value = {"/index"}) public class IndexServlet extends HttpServlet { public void init() { @@ -33,7 +33,6 @@ public class IndexServlet extends HttpServlet { request.getSession().setAttribute("language", "FR"); request.getSession().setAttribute("translator", Translator.generateTranslator(request.getSession(), request.getServletContext())); } - request.setAttribute("current", "index"); request.getRequestDispatcher("/WEB-INF/pages/index.jsp").forward(request, response); } diff --git a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/index.jsp b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/index.jsp index 694e958..a80f2a2 100644 --- a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/index.jsp +++ b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/index.jsp @@ -1,23 +1,30 @@ <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@ page import="uppa.project.Global" %> - +<%@ page import="uppa.project.web.translation.Translator" %> +<%@ page import="java.text.MessageFormat" %> <%@taglib prefix="layout" tagdir="/WEB-INF/tags/layouts" %> <%@taglib prefix="component" tagdir="/WEB-INF/tags/components" %> <%@taglib prefix="form" tagdir="/WEB-INF/tags/forms" %> +<% Translator translator =(Translator)session.getAttribute("translator");%> - -

Plongez dans l'excitation de ${Global.APP_NAME}!

-

- Défiez votre réactivité et dominez le jeu avec des amis dans cette course effrénée aux cartes ! - Rejoignez maintenant pour vivre l'adrénaline. -

+ + + + + +

${MessageFormat.format(translator.translate('index_main_sentence'), Global.APP_NAME)}

+

+ ${MessageFormat.format(translator.translate('index_description'), Global.APP_NAME)} +

+ + +
+
+
-
- S'inscrire - - Se connecter - -
- - \ No newline at end of file diff --git a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/tags/components/navbar.tag b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/tags/components/navbar.tag index 61d3017..7755d01 100644 --- a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/tags/components/navbar.tag +++ b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/tags/components/navbar.tag @@ -13,7 +13,7 @@ <% } else { %> - + Logo diff --git a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/translations.json b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/translations.json index 7591f95..43d8001 100644 --- a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/translations.json +++ b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/translations.json @@ -1,11 +1,11 @@ { - "index_main" : { - "EN" : "Dive into the excitement of CardRush!", - "FR" : "Plongez dans l'excitation de CardRush!" + "index_main_sentence" : { + "EN": "Dive into the excitement of {0}!", + "FR" : "Plongez dans l''excitation de {0}!" }, "index_description" : { - "EN": "Challenge your reactivity and dominate the game with friends in this fast-paced card race! Join now to experience the adrenaline.", - "FR": "Défiez votre réactivité et dominez le jeu avec des amis dans cette course effrénée aux cartes ! Rejoignez maintenant pour vivre l'adrénaline." + "EN": "Challenge your reactivity and dominate the game with friends in this fast-paced card race! Join now to experience the adrenaline of {0}.", + "FR": "Défiez votre réactivité et dominez le jeu avec des amis dans cette course effrénée aux cartes ! Rejoignez maintenant pour vivre l''adrénaline de {0}." }, "navbar_login" : { "EN": "Login", @@ -23,6 +23,10 @@ "EN": "Profile", "FR": "Profil" }, + "footer" : { + "EN": "{0} by Kevin Mitressé & Lucàs Vabre. UPPA M1-TI 2024", + "FR": "{0} par Kevin Mitressé & Lucàs Vabre. UPPA M1-TI 2024" + }, "user_username" : { "EN": "Username", "FR": "Nom d'utilisateur" @@ -484,8 +488,8 @@ "FR": "Salle de jeu" }, "game_room_players_list" : { - "EN": "Players list in the game", - "FR": "Liste des joueurs dans la partie" + "EN": "List of participants", + "FR": "Liste des participants" }, "game_room_connected_users_list" : { "EN": "List of connected users", diff --git a/S2/DevWeb/Projet/src/main/webapp/index.html b/S2/DevWeb/Projet/src/main/webapp/index.html index d3d7497..31bbe0f 100644 --- a/S2/DevWeb/Projet/src/main/webapp/index.html +++ b/S2/DevWeb/Projet/src/main/webapp/index.html @@ -1,97 +1,11 @@ - Card Rush - - - - - - - - + - - - - - - -
-
-
-

Plongez dans l'excitation de CardRush!

-

Défiez votre réactivité et dominez le jeu avec des amis dans cette course effrénée aux cartes ! Rejoignez maintenant pour vivre l'adrénaline.

- - -
-
-
- - diff --git a/S2/DevWeb/Projet/src/main/webapp/static/js/rewriteUrl.js b/S2/DevWeb/Projet/src/main/webapp/static/js/rewriteUrl.js new file mode 100644 index 0000000..cdd0ff0 --- /dev/null +++ b/S2/DevWeb/Projet/src/main/webapp/static/js/rewriteUrl.js @@ -0,0 +1,11 @@ + +function updateUrl(url) { + // Mettre à jour l'URL sans recharger la page + history.replaceState(null, null, url); +} +let contextPath = window.location.href.substring(0, window.location.href.lastIndexOf("/") + 1); +console.log(contextPath); + +// Mettre à jour l'URL initiale au chargement de la page +updateUrl(contextPath); +