Merge pull request 'Ajouter render pour routes principales' (#29) from feature/render-routes into main

Reviewed-on: #29
This commit is contained in:
Victor Lacasse-Beaudoin 2023-03-24 19:09:48 -05:00
commit 643100f325
11 changed files with 92 additions and 11 deletions

3
public/css/general.css Normal file
View file

@ -0,0 +1,3 @@
h1 {
text-align: center;
}

View file

@ -1,3 +0,0 @@
h1 {
text-align: center;
}

View file

@ -0,0 +1,14 @@
{{ define "a-propos-html" }}
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>AGECEM | À propos</title>
{{ template "general-html" }}
</head>
<body>
{{ template "header-html" }}
<h1>À propos</h1>
</body>
</html>
{{ end }}

View file

@ -0,0 +1,14 @@
{{ define "actualite-html" }}
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>AGECEM | Actualité</title>
{{ template "general-html" }}
</head>
<body>
{{ template "header-html" }}
<h1>Actualité</h1>
</body>
</html>
{{ end }}

View file

@ -0,0 +1,14 @@
{{ define "documentation-html" }}
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>AGECEM | Documentation</title>
{{ template "general-html" }}
</head>
<body>
{{ template "header-html" }}
<h1>Documentation</h1>
</body>
</html>
{{ end }}

View file

@ -0,0 +1,14 @@
{{ define "formulaires-html" }}
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>AGECEM | Formulaires</title>
{{ template "general-html" }}
</head>
<body>
{{ template "header-html" }}
<h1>Formulaires</h1>
</body>
</html>
{{ end }}

View file

@ -0,0 +1,3 @@
{{ define "general-html" }}
<link rel="stylesheet" href="static/general.css">
{{ end }}

View file

@ -1,4 +1,4 @@
{{ define "header" }} {{ define "header-html" }}
<ul> <ul>
<li><a href="/">index</a></li> <li><a href="/">index</a></li>

View file

@ -4,10 +4,11 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>AGECEM</title> <title>AGECEM</title>
{{ template "general-html" }}
<link rel="stylesheet" href="static/index.css"> <link rel="stylesheet" href="static/index.css">
</head> </head>
<body> <body>
{{ template "header" }} {{ template "header-html" }}
<h1>Association Générale Étudiante du Cégep Édouard-Montpetit</h1> <h1>Association Générale Étudiante du Cégep Édouard-Montpetit</h1>
</body> </body>
</html> </html>

View file

@ -0,0 +1,14 @@
{{ define "vie-etudiante-html" }}
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>AGECEM | Vie étudiante</title>
{{ template "general-html" }}
</head>
<body>
{{ template "header-html" }}
<h1>Vie étudiante</h1>
</body>
</html>
{{ end }}

View file

@ -46,6 +46,8 @@ func Execute() {
// Static Routes // Static Routes
e.GET("/static/general.css", handleStaticCSSGeneral)
e.GET("/static/index.css", handleStaticCSSIndex) e.GET("/static/index.css", handleStaticCSSIndex)
// HTML Routes // HTML Routes
@ -90,11 +92,11 @@ func handleIndex(c echo.Context) error {
} }
func handleAPropos(c echo.Context) error { func handleAPropos(c echo.Context) error {
return c.String(http.StatusOK, "À Propos") return c.Render(http.StatusOK, "a-propos-html", nil)
} }
func handleActualite(c echo.Context) error { func handleActualite(c echo.Context) error {
return c.String(http.StatusOK, "Actualité") return c.Render(http.StatusOK, "actualite-html", nil)
} }
func handleActualiteArticle(c echo.Context) error { func handleActualiteArticle(c echo.Context) error {
@ -102,24 +104,29 @@ func handleActualiteArticle(c echo.Context) error {
return c.String(http.StatusOK, fmt.Sprintf("Article: %s", article)) return c.String(http.StatusOK, fmt.Sprintf("Article: %s", article))
} }
func handleVieEtudiante(c echo.Context) error { func handleVieEtudiante(c echo.Context) error {
return c.String(http.StatusOK, "Vie Étudiante") return c.Render(http.StatusOK, "vie-etudiante-html", nil)
} }
func handleVieEtudianteOrganisme(c echo.Context) error { func handleVieEtudianteOrganisme(c echo.Context) error {
organisme := c.Param("organisme") organisme := c.Param("organisme")
return c.String(http.StatusOK, fmt.Sprintf("Organisme: %s", organisme)) return c.String(http.StatusOK, fmt.Sprintf("Organisme: %s", organisme))
} }
func handleDocumentation(c echo.Context) error { func handleDocumentation(c echo.Context) error {
return c.String(http.StatusOK, "Documentation") return c.Render(http.StatusOK, "documentation-html", nil)
} }
func handleFormulaires(c echo.Context) error { func handleFormulaires(c echo.Context) error {
return c.String(http.StatusOK, "Formulaires") return c.Render(http.StatusOK, "formulaires-html", nil)
} }
// CSS Handlers // CSS Handlers
func handleStaticCSSIndex(c echo.Context) error { func handleStaticCSSIndex(c echo.Context) error {
// TODO Ajouter gestion d'erreurs // TODO Ajouter gestion d'erreurs
// TODO Ajouter support pour fichiers SCSS
data, _ := embedFS.ReadFile("css/index.css") data, _ := embedFS.ReadFile("css/index.css")
return c.Blob(http.StatusOK, "text/css", data) return c.Blob(http.StatusOK, "text/css", data)
} }
func handleStaticCSSGeneral(c echo.Context) error {
// TODO Ajouter gestion d'erreurs
data, _ := embedFS.ReadFile("css/general.css")
return c.Blob(http.StatusOK, "text/css", data)
}