From 7d4a7477747616f850eccc14daa56a91714c32ea Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 27 Sep 2024 20:25:12 -0400 Subject: [PATCH] =?UTF-8?q?refactor:=20d=C3=A9placer=20fichiers=20go=20sou?= =?UTF-8?q?rce=20vers=20pkg/=20et=20cmd/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Déplacer public/ et templates/ vers ui/ et ui/public/ Bump projet à v3, API toujours v1 --- Dockerfile | 15 ++++---- Makefile | 6 +-- cmd.go => cmd/agecemorg/cmd.go | 36 ++++-------------- main.go => cmd/agecemorg/main.go | 0 docker-compose.yaml => compose.yaml | 0 go.mod | 2 +- client.go => pkg/agecemorg/client.go | 2 +- config.go => pkg/agecemorg/config.go | 2 +- entity.go => pkg/agecemorg/entity.go | 2 +- handler.go => pkg/agecemorg/handler.go | 5 +-- media.go => pkg/agecemorg/media.go | 2 +- request.go => pkg/agecemorg/request.go | 2 +- response.go => pkg/agecemorg/response.go | 2 +- routes.go => pkg/agecemorg/routes.go | 15 +++----- {version => pkg/agecemorg}/version.go | 4 +- templates/html/old/a-propos.html | 14 ------- templates/html/old/actualite.html | 14 ------- templates/templates.go | 18 --------- {templates/html => ui}/admin-upload.html | 0 {templates/html => ui}/admin.html | 0 {templates/html => ui}/documentation.html | 0 {templates/html => ui}/footer.html | 0 {templates/html => ui}/formulaires.html | 0 {templates/html => ui}/general.html | 0 {templates/html => ui}/header.html | 0 {templates/html => ui}/index.html | 0 {templates/html => ui}/proces-verbaux.html | 0 {public => ui/public}/css/admin-upload.css | 0 {public => ui/public}/css/admin.css | 0 {public => ui/public}/css/documentation.css | 0 {public => ui/public}/css/fonts.css | 0 {public => ui/public}/css/footer.css | 0 {public => ui/public}/css/general.css | 0 {public => ui/public}/css/header.css | 0 {public => ui/public}/css/index.css | 0 {public => ui/public}/css/proces-verbaux.css | 0 {public => ui/public}/css/snackbar.css | 0 {public => ui/public}/css/vie-etudiante.css | 0 {public => ui/public}/fonts/.gitkeep | 0 .../fonts/Poppins/poppins-black-italic.ttf | Bin .../fonts/Poppins/poppins-black-italic.woff | Bin .../fonts/Poppins/poppins-black-italic.woff2 | Bin .../public}/fonts/Poppins/poppins-black.ttf | Bin .../public}/fonts/Poppins/poppins-black.woff | Bin .../public}/fonts/Poppins/poppins-black.woff2 | Bin .../fonts/Poppins/poppins-bold-italic.ttf | Bin .../fonts/Poppins/poppins-bold-italic.woff | Bin .../fonts/Poppins/poppins-bold-italic.woff2 | Bin .../public}/fonts/Poppins/poppins-bold.ttf | Bin .../public}/fonts/Poppins/poppins-bold.woff | Bin .../public}/fonts/Poppins/poppins-bold.woff2 | Bin .../Poppins/poppins-extrabold-italic.ttf | Bin .../Poppins/poppins-extrabold-italic.woff | Bin .../Poppins/poppins-extrabold-italic.woff2 | Bin .../fonts/Poppins/poppins-extrabold.ttf | Bin .../fonts/Poppins/poppins-extrabold.woff | Bin .../fonts/Poppins/poppins-extrabold.woff2 | Bin .../Poppins/poppins-extralight-italic.ttf | Bin .../Poppins/poppins-extralight-italic.woff | Bin .../Poppins/poppins-extralight-italic.woff2 | Bin .../fonts/Poppins/poppins-extralight.ttf | Bin .../fonts/Poppins/poppins-extralight.woff | Bin .../fonts/Poppins/poppins-extralight.woff2 | Bin .../fonts/Poppins/poppins-light-italic.ttf | Bin .../fonts/Poppins/poppins-light-italic.woff | Bin .../fonts/Poppins/poppins-light-italic.woff2 | Bin .../public}/fonts/Poppins/poppins-light.ttf | Bin .../public}/fonts/Poppins/poppins-light.woff | Bin .../public}/fonts/Poppins/poppins-light.woff2 | Bin .../fonts/Poppins/poppins-medium-italic.ttf | Bin .../fonts/Poppins/poppins-medium-italic.woff | Bin .../fonts/Poppins/poppins-medium-italic.woff2 | Bin .../public}/fonts/Poppins/poppins-medium.ttf | Bin .../public}/fonts/Poppins/poppins-medium.woff | Bin .../fonts/Poppins/poppins-medium.woff2 | Bin .../fonts/Poppins/poppins-regular-italic.ttf | Bin .../fonts/Poppins/poppins-regular-italic.woff | Bin .../Poppins/poppins-regular-italic.woff2 | Bin .../public}/fonts/Poppins/poppins-regular.ttf | Bin .../fonts/Poppins/poppins-regular.woff | Bin .../fonts/Poppins/poppins-regular.woff2 | Bin .../fonts/Poppins/poppins-semibold-italic.ttf | Bin .../Poppins/poppins-semibold-italic.woff | Bin .../Poppins/poppins-semibold-italic.woff2 | Bin .../fonts/Poppins/poppins-semibold.ttf | Bin .../fonts/Poppins/poppins-semibold.woff | Bin .../fonts/Poppins/poppins-semibold.woff2 | Bin .../fonts/Poppins/poppins-thin-italic.ttf | Bin .../fonts/Poppins/poppins-thin-italic.woff | Bin .../fonts/Poppins/poppins-thin-italic.woff2 | Bin .../public}/fonts/Poppins/poppins-thin.ttf | Bin .../public}/fonts/Poppins/poppins-thin.woff | Bin .../public}/fonts/Poppins/poppins-thin.woff2 | Bin {public => ui/public}/icones/.gitkeep | 0 {public => ui/public}/icones/agecem-logo.svg | 0 .../public}/icones/facebook-icon.svg | 0 {public => ui/public}/icones/fermer.svg | 0 .../public}/icones/hamburger-menu.svg | 0 .../public}/icones/instagram-icon.svg | 0 {public => ui/public}/images/.gitkeep | 0 .../public}/images/header_agecem.png | Bin {public => ui/public}/js/header.js | 0 {public => ui/public}/js/index.js | 0 {public => ui/public}/public.go | 0 {templates/html => ui}/snackbar.html | 0 ui/ui.go | 34 +++++++++++++++++ {templates/html => ui}/vie-etudiante.html | 0 107 files changed, 68 insertions(+), 107 deletions(-) rename cmd.go => cmd/agecemorg/cmd.go (88%) rename main.go => cmd/agecemorg/main.go (100%) rename docker-compose.yaml => compose.yaml (100%) rename client.go => pkg/agecemorg/client.go (99%) rename config.go => pkg/agecemorg/config.go (98%) rename entity.go => pkg/agecemorg/entity.go (82%) rename handler.go => pkg/agecemorg/handler.go (99%) rename media.go => pkg/agecemorg/media.go (99%) rename request.go => pkg/agecemorg/request.go (99%) rename response.go => pkg/agecemorg/response.go (98%) rename routes.go => pkg/agecemorg/routes.go (96%) rename {version => pkg/agecemorg}/version.go (68%) delete mode 100644 templates/html/old/a-propos.html delete mode 100644 templates/html/old/actualite.html delete mode 100644 templates/templates.go rename {templates/html => ui}/admin-upload.html (100%) rename {templates/html => ui}/admin.html (100%) rename {templates/html => ui}/documentation.html (100%) rename {templates/html => ui}/footer.html (100%) rename {templates/html => ui}/formulaires.html (100%) rename {templates/html => ui}/general.html (100%) rename {templates/html => ui}/header.html (100%) rename {templates/html => ui}/index.html (100%) rename {templates/html => ui}/proces-verbaux.html (100%) rename {public => ui/public}/css/admin-upload.css (100%) rename {public => ui/public}/css/admin.css (100%) rename {public => ui/public}/css/documentation.css (100%) rename {public => ui/public}/css/fonts.css (100%) rename {public => ui/public}/css/footer.css (100%) rename {public => ui/public}/css/general.css (100%) rename {public => ui/public}/css/header.css (100%) rename {public => ui/public}/css/index.css (100%) rename {public => ui/public}/css/proces-verbaux.css (100%) rename {public => ui/public}/css/snackbar.css (100%) rename {public => ui/public}/css/vie-etudiante.css (100%) rename {public => ui/public}/fonts/.gitkeep (100%) rename {public => ui/public}/fonts/Poppins/poppins-black-italic.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-black-italic.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-black-italic.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-black.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-black.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-black.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-bold-italic.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-bold-italic.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-bold-italic.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-bold.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-bold.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-bold.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-extrabold-italic.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-extrabold-italic.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-extrabold-italic.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-extrabold.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-extrabold.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-extrabold.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-extralight-italic.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-extralight-italic.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-extralight-italic.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-extralight.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-extralight.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-extralight.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-light-italic.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-light-italic.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-light-italic.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-light.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-light.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-light.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-medium-italic.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-medium-italic.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-medium-italic.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-medium.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-medium.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-medium.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-regular-italic.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-regular-italic.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-regular-italic.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-regular.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-regular.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-regular.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-semibold-italic.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-semibold-italic.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-semibold-italic.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-semibold.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-semibold.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-semibold.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-thin-italic.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-thin-italic.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-thin-italic.woff2 (100%) rename {public => ui/public}/fonts/Poppins/poppins-thin.ttf (100%) rename {public => ui/public}/fonts/Poppins/poppins-thin.woff (100%) rename {public => ui/public}/fonts/Poppins/poppins-thin.woff2 (100%) rename {public => ui/public}/icones/.gitkeep (100%) rename {public => ui/public}/icones/agecem-logo.svg (100%) rename {public => ui/public}/icones/facebook-icon.svg (100%) rename {public => ui/public}/icones/fermer.svg (100%) rename {public => ui/public}/icones/hamburger-menu.svg (100%) rename {public => ui/public}/icones/instagram-icon.svg (100%) rename {public => ui/public}/images/.gitkeep (100%) rename {public => ui/public}/images/header_agecem.png (100%) rename {public => ui/public}/js/header.js (100%) rename {public => ui/public}/js/index.js (100%) rename {public => ui/public}/public.go (100%) rename {templates/html => ui}/snackbar.html (100%) create mode 100644 ui/ui.go rename {templates/html => ui}/vie-etudiante.html (100%) diff --git a/Dockerfile b/Dockerfile index 96db22d..389828c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,15 +6,14 @@ LABEL author="Victor Lacasse-Beaudoin " WORKDIR /go/src/app -COPY go.mod go.sum main.go client.go cmd.go config.go entity.go handler.go media.go request.go response.go routes.go ./ +COPY go.mod go.sum LICENSE ./ +ADD cmd/ cmd/ +ADD pkg/ pkg/ +ADD ui/ ui/ -ADD public/ public/ - -ADD templates/ templates/ - -ADD version/ version/ - -RUN CGO_ENABLED=0 go build -a -o agecem-org -ldflags="-X 'git.agecem.com/agecem/agecem-org/version.version=$agecem_org_version'" . +RUN CGO_ENABLED=0 go build -a -o agecem-org \ + -ldflags="-X 'git.agecem.com/agecem/agecem-org/pkg/agecemorg/version.version=$agecem_org_version'" \ + ./cmd/agecemorg/ # Alpine diff --git a/Makefile b/Makefile index 17d6206..c68b959 100644 --- a/Makefile +++ b/Makefile @@ -11,17 +11,17 @@ help: ## Show this help .PHONY: build build: ## Build agecem-org executable CGO_ENABLED=0 go build -a -o agecem-org \ - -ldflags="-X 'git.agecem.com/agecem/agecem-org/version.version=`git describe`'" . + -ldflags="-X 'git.agecem.com/agecem/agecem-org/pkg/agecemorg/version.version=`git describe`'" ./cmd/agecemorg/ .PHONY: install install: ## Using `go install`, install the agecem-org executable at ~/go/bin/haul CGO_ENABLED=0 go install -a \ - -ldflags="-X 'git.agecem.com/agecem/agecem-org/version.version=`git describe`'" . + -ldflags="-X 'git.agecem.com/agecem/agecem-org/pkg/agecemorg/version.version=`git describe`'" ./cmd/agecemorg/ .PHONY: run run: ## Run agecem-org from source with `go run` CGO_ENABLED=0 go run \ - -ldflags="-X 'git.agecem.com/agecem/agecem-org/version.version=`git describe`'" . + -ldflags="-X 'git.agecem.com/agecem/agecem-org/pkg/agecemorg/version.version=`git describe`'" ./cmd/agecemorg/ .PHONY: build-container build-container: ## Build agecem-org container image diff --git a/cmd.go b/cmd/agecemorg/cmd.go similarity index 88% rename from cmd.go rename to cmd/agecemorg/cmd.go index 646ad7a..9b275a0 100644 --- a/cmd.go +++ b/cmd/agecemorg/cmd.go @@ -4,20 +4,14 @@ Copyright © 2023-2024 AGECEM package main import ( - "embed" "encoding/json" "fmt" - "io" "log" "os" "strings" - "text/template" "codeberg.org/vlbeaudoin/serpents" - "git.agecem.com/agecem/agecem-org/public" - "git.agecem.com/agecem/agecem-org/templates" - "git.agecem.com/agecem/agecem-org/version" - "github.com/labstack/echo/v4" + "git.agecem.com/agecem/agecem-org/v3/pkg/agecemorg" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -27,7 +21,7 @@ var configCmd = &cobra.Command{ Use: "config", Short: "Print the config to stdout in indented JSON format", Run: func(cmd *cobra.Command, args []string) { - var cfg Config + var cfg agecemorg.Config if err := viper.Unmarshal(&cfg); err != nil { log.Fatal(err) @@ -41,7 +35,7 @@ func init() { rootCmd.AddCommand(configCmd) } -func printConfig(config Config) error { +func printConfig(config agecemorg.Config) error { buf, err := json.MarshalIndent(config, "", " ") if err != nil { return err @@ -102,27 +96,17 @@ func initConfig() { } } -type Template struct { - templates *template.Template -} - -var cfg Config - -var ( - publicFS embed.FS - templatesFS embed.FS -) - // serverCmd represents the server command var serverCmd = &cobra.Command{ Use: "server", Short: "Démarrer le serveur web", Run: func(cmd *cobra.Command, args []string) { + var cfg agecemorg.Config if err := viper.Unmarshal(&cfg); err != nil { log.Fatal(err) } - mediaClient, err := NewMediaClientFromViper() + mediaClient, err := agecemorg.NewMediaClientFromViper() switch err != nil { case true: log.Printf("NewMediaClientFromViper error: %s", err) @@ -135,14 +119,12 @@ var serverCmd = &cobra.Command{ } } - RunServer() + agecemorg.RunServer(cfg) }, } func init() { rootCmd.AddCommand(serverCmd) - publicFS = public.GetPublicFS() - templatesFS = templates.GetTemplatesFS() serpents.Int(serverCmd.Flags(), "server.port", "server-port", 8080, @@ -212,16 +194,12 @@ func init() { "Password for basic authentication for /admin routes") } -func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error { - return t.templates.ExecuteTemplate(w, name, data) -} - // versionCmd represents the version command var versionCmd = &cobra.Command{ Use: "version", Short: "Print version registered at build time", Run: func(cmd *cobra.Command, args []string) { - fmt.Println("agecem-org", version.Version()) + fmt.Println("agecem-org", agecemorg.Version()) }, } diff --git a/main.go b/cmd/agecemorg/main.go similarity index 100% rename from main.go rename to cmd/agecemorg/main.go diff --git a/docker-compose.yaml b/compose.yaml similarity index 100% rename from docker-compose.yaml rename to compose.yaml diff --git a/go.mod b/go.mod index 55a9915..e67162e 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module git.agecem.com/agecem/agecem-org +module git.agecem.com/agecem/agecem-org/v3 go 1.23.0 diff --git a/client.go b/pkg/agecemorg/client.go similarity index 99% rename from client.go rename to pkg/agecemorg/client.go index 94d073e..443a025 100644 --- a/client.go +++ b/pkg/agecemorg/client.go @@ -1,4 +1,4 @@ -package main +package agecemorg import ( "bytes" diff --git a/config.go b/pkg/agecemorg/config.go similarity index 98% rename from config.go rename to pkg/agecemorg/config.go index 4d80229..d39f2ac 100644 --- a/config.go +++ b/pkg/agecemorg/config.go @@ -1,4 +1,4 @@ -package main +package agecemorg /* Permet de contenir la configuration obtenue par cobra/viper diff --git a/entity.go b/pkg/agecemorg/entity.go similarity index 82% rename from entity.go rename to pkg/agecemorg/entity.go index bc34cf5..0fa21d3 100644 --- a/entity.go +++ b/pkg/agecemorg/entity.go @@ -1,4 +1,4 @@ -package main +package agecemorg type Bucket struct { Name string diff --git a/handler.go b/pkg/agecemorg/handler.go similarity index 99% rename from handler.go rename to pkg/agecemorg/handler.go index 55edb4d..26ce6fe 100644 --- a/handler.go +++ b/pkg/agecemorg/handler.go @@ -1,4 +1,4 @@ -package main +package agecemorg import ( "context" @@ -10,7 +10,6 @@ import ( "codeberg.org/vlbeaudoin/pave/v2" "codeberg.org/vlbeaudoin/voki/v3" - "git.agecem.com/agecem/agecem-org/version" "github.com/labstack/echo/v4" "github.com/minio/minio-go/v7" ) @@ -550,7 +549,7 @@ func (h *V1Handler) ReadSpec(c echo.Context) error { return c.JSON(response.StatusCode(), response) } - response.Data.Spec = fmt.Sprintf("# pave spec for agecem-org %s\n", version.Version()) + response.Data.Spec = fmt.Sprintf("# pave spec for agecem-org %s\n", Version()) for _, route := range h.Pave.SortedRouteStrings() { response.Data.Spec = fmt.Sprintf("%s%s", response.Data.Spec, route) diff --git a/media.go b/pkg/agecemorg/media.go similarity index 99% rename from media.go rename to pkg/agecemorg/media.go index f4a8335..907edd9 100644 --- a/media.go +++ b/pkg/agecemorg/media.go @@ -1,4 +1,4 @@ -package main +package agecemorg import ( "context" diff --git a/request.go b/pkg/agecemorg/request.go similarity index 99% rename from request.go rename to pkg/agecemorg/request.go index b6e9955..3c5a49d 100644 --- a/request.go +++ b/pkg/agecemorg/request.go @@ -3,7 +3,7 @@ File request.go contains the JSON request types for HTTP endpoints. Le fichier request.go contient les types de requêtes pour les endpoints HTTP. */ -package main +package agecemorg import ( "bytes" diff --git a/response.go b/pkg/agecemorg/response.go similarity index 98% rename from response.go rename to pkg/agecemorg/response.go index a5114f1..86612c1 100644 --- a/response.go +++ b/pkg/agecemorg/response.go @@ -3,7 +3,7 @@ File response.go contains the JSON and HTML response types for HTTP endpoints. Le fichier response.go contient les types de réponses JSON et HTML pour les endpoints HTTP. */ -package main +package agecemorg import ( "codeberg.org/vlbeaudoin/voki/v3" diff --git a/routes.go b/pkg/agecemorg/routes.go similarity index 96% rename from routes.go rename to pkg/agecemorg/routes.go index 886dc37..73c9f9b 100644 --- a/routes.go +++ b/pkg/agecemorg/routes.go @@ -1,32 +1,29 @@ -package main +package agecemorg import ( "crypto/subtle" "fmt" "log" "net/http" - "text/template" "codeberg.org/vlbeaudoin/pave/v2" + "git.agecem.com/agecem/agecem-org/v3/ui" + "git.agecem.com/agecem/agecem-org/v3/ui/public" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" ) -func RunServer() { +func RunServer(cfg Config) { e := echo.New() - t := &Template{ - templates: template.Must(template.ParseFS(templatesFS, "html/*.html")), - } - - e.Renderer = t + e.Renderer = ui.NewRenderer() e.Pre(middleware.RemoveTrailingSlash()) groupStatic := e.Group("/public/*") groupStatic.Use(middleware.StaticWithConfig(middleware.StaticConfig{ Root: "/", - Filesystem: http.FS(publicFS), + Filesystem: http.FS(public.GetPublicFS()), //TODO //Browse: true, })) diff --git a/version/version.go b/pkg/agecemorg/version.go similarity index 68% rename from version/version.go rename to pkg/agecemorg/version.go index bea4c89..1bd82eb 100644 --- a/version/version.go +++ b/pkg/agecemorg/version.go @@ -1,4 +1,4 @@ -package version +package agecemorg // Filled by build flag var version string @@ -8,7 +8,7 @@ Version returns the application version Example command to use the output of `git describe` for version number at build time: - $ go build -ldflags="-X 'git.agecem.com/agecem/agecem-org/version.version=`git describe`'" . + $ go build -ldflags="-X 'git.agecem.com/agecem/agecem-org/pkg/agecemorg/version.version=`git describe`'" . */ func Version() string { if version == "" { diff --git a/templates/html/old/a-propos.html b/templates/html/old/a-propos.html deleted file mode 100644 index 90c2774..0000000 --- a/templates/html/old/a-propos.html +++ /dev/null @@ -1,14 +0,0 @@ -{{ define "a-propos-html" }} - - - - - AGECEM | À propos - {{ template "general-html" }} - - - {{ template "header-html" }} -

À propos

- - -{{ end }} diff --git a/templates/html/old/actualite.html b/templates/html/old/actualite.html deleted file mode 100644 index b56cda4..0000000 --- a/templates/html/old/actualite.html +++ /dev/null @@ -1,14 +0,0 @@ -{{ define "actualite-html" }} - - - - - AGECEM | Actualité - {{ template "general-html" }} - - - {{ template "header-html" }} -

Actualité

- - -{{ end }} diff --git a/templates/templates.go b/templates/templates.go deleted file mode 100644 index 79f292c..0000000 --- a/templates/templates.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Package templates contient les fichiers html à templater par l'application. - -Le contenu sera embedded dans le fichier binaire, dans le but de bundle les -dépendances avec l'application, simplifiant son déploiement. - -Une copie du contenu peut être obtenue par un appel de GetTemplatesFS(). -*/ -package templates - -import "embed" - -//go:embed html/*.html -var templatesFS embed.FS - -func GetTemplatesFS() embed.FS { - return templatesFS -} diff --git a/templates/html/admin-upload.html b/ui/admin-upload.html similarity index 100% rename from templates/html/admin-upload.html rename to ui/admin-upload.html diff --git a/templates/html/admin.html b/ui/admin.html similarity index 100% rename from templates/html/admin.html rename to ui/admin.html diff --git a/templates/html/documentation.html b/ui/documentation.html similarity index 100% rename from templates/html/documentation.html rename to ui/documentation.html diff --git a/templates/html/footer.html b/ui/footer.html similarity index 100% rename from templates/html/footer.html rename to ui/footer.html diff --git a/templates/html/formulaires.html b/ui/formulaires.html similarity index 100% rename from templates/html/formulaires.html rename to ui/formulaires.html diff --git a/templates/html/general.html b/ui/general.html similarity index 100% rename from templates/html/general.html rename to ui/general.html diff --git a/templates/html/header.html b/ui/header.html similarity index 100% rename from templates/html/header.html rename to ui/header.html diff --git a/templates/html/index.html b/ui/index.html similarity index 100% rename from templates/html/index.html rename to ui/index.html diff --git a/templates/html/proces-verbaux.html b/ui/proces-verbaux.html similarity index 100% rename from templates/html/proces-verbaux.html rename to ui/proces-verbaux.html diff --git a/public/css/admin-upload.css b/ui/public/css/admin-upload.css similarity index 100% rename from public/css/admin-upload.css rename to ui/public/css/admin-upload.css diff --git a/public/css/admin.css b/ui/public/css/admin.css similarity index 100% rename from public/css/admin.css rename to ui/public/css/admin.css diff --git a/public/css/documentation.css b/ui/public/css/documentation.css similarity index 100% rename from public/css/documentation.css rename to ui/public/css/documentation.css diff --git a/public/css/fonts.css b/ui/public/css/fonts.css similarity index 100% rename from public/css/fonts.css rename to ui/public/css/fonts.css diff --git a/public/css/footer.css b/ui/public/css/footer.css similarity index 100% rename from public/css/footer.css rename to ui/public/css/footer.css diff --git a/public/css/general.css b/ui/public/css/general.css similarity index 100% rename from public/css/general.css rename to ui/public/css/general.css diff --git a/public/css/header.css b/ui/public/css/header.css similarity index 100% rename from public/css/header.css rename to ui/public/css/header.css diff --git a/public/css/index.css b/ui/public/css/index.css similarity index 100% rename from public/css/index.css rename to ui/public/css/index.css diff --git a/public/css/proces-verbaux.css b/ui/public/css/proces-verbaux.css similarity index 100% rename from public/css/proces-verbaux.css rename to ui/public/css/proces-verbaux.css diff --git a/public/css/snackbar.css b/ui/public/css/snackbar.css similarity index 100% rename from public/css/snackbar.css rename to ui/public/css/snackbar.css diff --git a/public/css/vie-etudiante.css b/ui/public/css/vie-etudiante.css similarity index 100% rename from public/css/vie-etudiante.css rename to ui/public/css/vie-etudiante.css diff --git a/public/fonts/.gitkeep b/ui/public/fonts/.gitkeep similarity index 100% rename from public/fonts/.gitkeep rename to ui/public/fonts/.gitkeep diff --git a/public/fonts/Poppins/poppins-black-italic.ttf b/ui/public/fonts/Poppins/poppins-black-italic.ttf similarity index 100% rename from public/fonts/Poppins/poppins-black-italic.ttf rename to ui/public/fonts/Poppins/poppins-black-italic.ttf diff --git a/public/fonts/Poppins/poppins-black-italic.woff b/ui/public/fonts/Poppins/poppins-black-italic.woff similarity index 100% rename from public/fonts/Poppins/poppins-black-italic.woff rename to ui/public/fonts/Poppins/poppins-black-italic.woff diff --git a/public/fonts/Poppins/poppins-black-italic.woff2 b/ui/public/fonts/Poppins/poppins-black-italic.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-black-italic.woff2 rename to ui/public/fonts/Poppins/poppins-black-italic.woff2 diff --git a/public/fonts/Poppins/poppins-black.ttf b/ui/public/fonts/Poppins/poppins-black.ttf similarity index 100% rename from public/fonts/Poppins/poppins-black.ttf rename to ui/public/fonts/Poppins/poppins-black.ttf diff --git a/public/fonts/Poppins/poppins-black.woff b/ui/public/fonts/Poppins/poppins-black.woff similarity index 100% rename from public/fonts/Poppins/poppins-black.woff rename to ui/public/fonts/Poppins/poppins-black.woff diff --git a/public/fonts/Poppins/poppins-black.woff2 b/ui/public/fonts/Poppins/poppins-black.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-black.woff2 rename to ui/public/fonts/Poppins/poppins-black.woff2 diff --git a/public/fonts/Poppins/poppins-bold-italic.ttf b/ui/public/fonts/Poppins/poppins-bold-italic.ttf similarity index 100% rename from public/fonts/Poppins/poppins-bold-italic.ttf rename to ui/public/fonts/Poppins/poppins-bold-italic.ttf diff --git a/public/fonts/Poppins/poppins-bold-italic.woff b/ui/public/fonts/Poppins/poppins-bold-italic.woff similarity index 100% rename from public/fonts/Poppins/poppins-bold-italic.woff rename to ui/public/fonts/Poppins/poppins-bold-italic.woff diff --git a/public/fonts/Poppins/poppins-bold-italic.woff2 b/ui/public/fonts/Poppins/poppins-bold-italic.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-bold-italic.woff2 rename to ui/public/fonts/Poppins/poppins-bold-italic.woff2 diff --git a/public/fonts/Poppins/poppins-bold.ttf b/ui/public/fonts/Poppins/poppins-bold.ttf similarity index 100% rename from public/fonts/Poppins/poppins-bold.ttf rename to ui/public/fonts/Poppins/poppins-bold.ttf diff --git a/public/fonts/Poppins/poppins-bold.woff b/ui/public/fonts/Poppins/poppins-bold.woff similarity index 100% rename from public/fonts/Poppins/poppins-bold.woff rename to ui/public/fonts/Poppins/poppins-bold.woff diff --git a/public/fonts/Poppins/poppins-bold.woff2 b/ui/public/fonts/Poppins/poppins-bold.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-bold.woff2 rename to ui/public/fonts/Poppins/poppins-bold.woff2 diff --git a/public/fonts/Poppins/poppins-extrabold-italic.ttf b/ui/public/fonts/Poppins/poppins-extrabold-italic.ttf similarity index 100% rename from public/fonts/Poppins/poppins-extrabold-italic.ttf rename to ui/public/fonts/Poppins/poppins-extrabold-italic.ttf diff --git a/public/fonts/Poppins/poppins-extrabold-italic.woff b/ui/public/fonts/Poppins/poppins-extrabold-italic.woff similarity index 100% rename from public/fonts/Poppins/poppins-extrabold-italic.woff rename to ui/public/fonts/Poppins/poppins-extrabold-italic.woff diff --git a/public/fonts/Poppins/poppins-extrabold-italic.woff2 b/ui/public/fonts/Poppins/poppins-extrabold-italic.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-extrabold-italic.woff2 rename to ui/public/fonts/Poppins/poppins-extrabold-italic.woff2 diff --git a/public/fonts/Poppins/poppins-extrabold.ttf b/ui/public/fonts/Poppins/poppins-extrabold.ttf similarity index 100% rename from public/fonts/Poppins/poppins-extrabold.ttf rename to ui/public/fonts/Poppins/poppins-extrabold.ttf diff --git a/public/fonts/Poppins/poppins-extrabold.woff b/ui/public/fonts/Poppins/poppins-extrabold.woff similarity index 100% rename from public/fonts/Poppins/poppins-extrabold.woff rename to ui/public/fonts/Poppins/poppins-extrabold.woff diff --git a/public/fonts/Poppins/poppins-extrabold.woff2 b/ui/public/fonts/Poppins/poppins-extrabold.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-extrabold.woff2 rename to ui/public/fonts/Poppins/poppins-extrabold.woff2 diff --git a/public/fonts/Poppins/poppins-extralight-italic.ttf b/ui/public/fonts/Poppins/poppins-extralight-italic.ttf similarity index 100% rename from public/fonts/Poppins/poppins-extralight-italic.ttf rename to ui/public/fonts/Poppins/poppins-extralight-italic.ttf diff --git a/public/fonts/Poppins/poppins-extralight-italic.woff b/ui/public/fonts/Poppins/poppins-extralight-italic.woff similarity index 100% rename from public/fonts/Poppins/poppins-extralight-italic.woff rename to ui/public/fonts/Poppins/poppins-extralight-italic.woff diff --git a/public/fonts/Poppins/poppins-extralight-italic.woff2 b/ui/public/fonts/Poppins/poppins-extralight-italic.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-extralight-italic.woff2 rename to ui/public/fonts/Poppins/poppins-extralight-italic.woff2 diff --git a/public/fonts/Poppins/poppins-extralight.ttf b/ui/public/fonts/Poppins/poppins-extralight.ttf similarity index 100% rename from public/fonts/Poppins/poppins-extralight.ttf rename to ui/public/fonts/Poppins/poppins-extralight.ttf diff --git a/public/fonts/Poppins/poppins-extralight.woff b/ui/public/fonts/Poppins/poppins-extralight.woff similarity index 100% rename from public/fonts/Poppins/poppins-extralight.woff rename to ui/public/fonts/Poppins/poppins-extralight.woff diff --git a/public/fonts/Poppins/poppins-extralight.woff2 b/ui/public/fonts/Poppins/poppins-extralight.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-extralight.woff2 rename to ui/public/fonts/Poppins/poppins-extralight.woff2 diff --git a/public/fonts/Poppins/poppins-light-italic.ttf b/ui/public/fonts/Poppins/poppins-light-italic.ttf similarity index 100% rename from public/fonts/Poppins/poppins-light-italic.ttf rename to ui/public/fonts/Poppins/poppins-light-italic.ttf diff --git a/public/fonts/Poppins/poppins-light-italic.woff b/ui/public/fonts/Poppins/poppins-light-italic.woff similarity index 100% rename from public/fonts/Poppins/poppins-light-italic.woff rename to ui/public/fonts/Poppins/poppins-light-italic.woff diff --git a/public/fonts/Poppins/poppins-light-italic.woff2 b/ui/public/fonts/Poppins/poppins-light-italic.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-light-italic.woff2 rename to ui/public/fonts/Poppins/poppins-light-italic.woff2 diff --git a/public/fonts/Poppins/poppins-light.ttf b/ui/public/fonts/Poppins/poppins-light.ttf similarity index 100% rename from public/fonts/Poppins/poppins-light.ttf rename to ui/public/fonts/Poppins/poppins-light.ttf diff --git a/public/fonts/Poppins/poppins-light.woff b/ui/public/fonts/Poppins/poppins-light.woff similarity index 100% rename from public/fonts/Poppins/poppins-light.woff rename to ui/public/fonts/Poppins/poppins-light.woff diff --git a/public/fonts/Poppins/poppins-light.woff2 b/ui/public/fonts/Poppins/poppins-light.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-light.woff2 rename to ui/public/fonts/Poppins/poppins-light.woff2 diff --git a/public/fonts/Poppins/poppins-medium-italic.ttf b/ui/public/fonts/Poppins/poppins-medium-italic.ttf similarity index 100% rename from public/fonts/Poppins/poppins-medium-italic.ttf rename to ui/public/fonts/Poppins/poppins-medium-italic.ttf diff --git a/public/fonts/Poppins/poppins-medium-italic.woff b/ui/public/fonts/Poppins/poppins-medium-italic.woff similarity index 100% rename from public/fonts/Poppins/poppins-medium-italic.woff rename to ui/public/fonts/Poppins/poppins-medium-italic.woff diff --git a/public/fonts/Poppins/poppins-medium-italic.woff2 b/ui/public/fonts/Poppins/poppins-medium-italic.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-medium-italic.woff2 rename to ui/public/fonts/Poppins/poppins-medium-italic.woff2 diff --git a/public/fonts/Poppins/poppins-medium.ttf b/ui/public/fonts/Poppins/poppins-medium.ttf similarity index 100% rename from public/fonts/Poppins/poppins-medium.ttf rename to ui/public/fonts/Poppins/poppins-medium.ttf diff --git a/public/fonts/Poppins/poppins-medium.woff b/ui/public/fonts/Poppins/poppins-medium.woff similarity index 100% rename from public/fonts/Poppins/poppins-medium.woff rename to ui/public/fonts/Poppins/poppins-medium.woff diff --git a/public/fonts/Poppins/poppins-medium.woff2 b/ui/public/fonts/Poppins/poppins-medium.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-medium.woff2 rename to ui/public/fonts/Poppins/poppins-medium.woff2 diff --git a/public/fonts/Poppins/poppins-regular-italic.ttf b/ui/public/fonts/Poppins/poppins-regular-italic.ttf similarity index 100% rename from public/fonts/Poppins/poppins-regular-italic.ttf rename to ui/public/fonts/Poppins/poppins-regular-italic.ttf diff --git a/public/fonts/Poppins/poppins-regular-italic.woff b/ui/public/fonts/Poppins/poppins-regular-italic.woff similarity index 100% rename from public/fonts/Poppins/poppins-regular-italic.woff rename to ui/public/fonts/Poppins/poppins-regular-italic.woff diff --git a/public/fonts/Poppins/poppins-regular-italic.woff2 b/ui/public/fonts/Poppins/poppins-regular-italic.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-regular-italic.woff2 rename to ui/public/fonts/Poppins/poppins-regular-italic.woff2 diff --git a/public/fonts/Poppins/poppins-regular.ttf b/ui/public/fonts/Poppins/poppins-regular.ttf similarity index 100% rename from public/fonts/Poppins/poppins-regular.ttf rename to ui/public/fonts/Poppins/poppins-regular.ttf diff --git a/public/fonts/Poppins/poppins-regular.woff b/ui/public/fonts/Poppins/poppins-regular.woff similarity index 100% rename from public/fonts/Poppins/poppins-regular.woff rename to ui/public/fonts/Poppins/poppins-regular.woff diff --git a/public/fonts/Poppins/poppins-regular.woff2 b/ui/public/fonts/Poppins/poppins-regular.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-regular.woff2 rename to ui/public/fonts/Poppins/poppins-regular.woff2 diff --git a/public/fonts/Poppins/poppins-semibold-italic.ttf b/ui/public/fonts/Poppins/poppins-semibold-italic.ttf similarity index 100% rename from public/fonts/Poppins/poppins-semibold-italic.ttf rename to ui/public/fonts/Poppins/poppins-semibold-italic.ttf diff --git a/public/fonts/Poppins/poppins-semibold-italic.woff b/ui/public/fonts/Poppins/poppins-semibold-italic.woff similarity index 100% rename from public/fonts/Poppins/poppins-semibold-italic.woff rename to ui/public/fonts/Poppins/poppins-semibold-italic.woff diff --git a/public/fonts/Poppins/poppins-semibold-italic.woff2 b/ui/public/fonts/Poppins/poppins-semibold-italic.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-semibold-italic.woff2 rename to ui/public/fonts/Poppins/poppins-semibold-italic.woff2 diff --git a/public/fonts/Poppins/poppins-semibold.ttf b/ui/public/fonts/Poppins/poppins-semibold.ttf similarity index 100% rename from public/fonts/Poppins/poppins-semibold.ttf rename to ui/public/fonts/Poppins/poppins-semibold.ttf diff --git a/public/fonts/Poppins/poppins-semibold.woff b/ui/public/fonts/Poppins/poppins-semibold.woff similarity index 100% rename from public/fonts/Poppins/poppins-semibold.woff rename to ui/public/fonts/Poppins/poppins-semibold.woff diff --git a/public/fonts/Poppins/poppins-semibold.woff2 b/ui/public/fonts/Poppins/poppins-semibold.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-semibold.woff2 rename to ui/public/fonts/Poppins/poppins-semibold.woff2 diff --git a/public/fonts/Poppins/poppins-thin-italic.ttf b/ui/public/fonts/Poppins/poppins-thin-italic.ttf similarity index 100% rename from public/fonts/Poppins/poppins-thin-italic.ttf rename to ui/public/fonts/Poppins/poppins-thin-italic.ttf diff --git a/public/fonts/Poppins/poppins-thin-italic.woff b/ui/public/fonts/Poppins/poppins-thin-italic.woff similarity index 100% rename from public/fonts/Poppins/poppins-thin-italic.woff rename to ui/public/fonts/Poppins/poppins-thin-italic.woff diff --git a/public/fonts/Poppins/poppins-thin-italic.woff2 b/ui/public/fonts/Poppins/poppins-thin-italic.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-thin-italic.woff2 rename to ui/public/fonts/Poppins/poppins-thin-italic.woff2 diff --git a/public/fonts/Poppins/poppins-thin.ttf b/ui/public/fonts/Poppins/poppins-thin.ttf similarity index 100% rename from public/fonts/Poppins/poppins-thin.ttf rename to ui/public/fonts/Poppins/poppins-thin.ttf diff --git a/public/fonts/Poppins/poppins-thin.woff b/ui/public/fonts/Poppins/poppins-thin.woff similarity index 100% rename from public/fonts/Poppins/poppins-thin.woff rename to ui/public/fonts/Poppins/poppins-thin.woff diff --git a/public/fonts/Poppins/poppins-thin.woff2 b/ui/public/fonts/Poppins/poppins-thin.woff2 similarity index 100% rename from public/fonts/Poppins/poppins-thin.woff2 rename to ui/public/fonts/Poppins/poppins-thin.woff2 diff --git a/public/icones/.gitkeep b/ui/public/icones/.gitkeep similarity index 100% rename from public/icones/.gitkeep rename to ui/public/icones/.gitkeep diff --git a/public/icones/agecem-logo.svg b/ui/public/icones/agecem-logo.svg similarity index 100% rename from public/icones/agecem-logo.svg rename to ui/public/icones/agecem-logo.svg diff --git a/public/icones/facebook-icon.svg b/ui/public/icones/facebook-icon.svg similarity index 100% rename from public/icones/facebook-icon.svg rename to ui/public/icones/facebook-icon.svg diff --git a/public/icones/fermer.svg b/ui/public/icones/fermer.svg similarity index 100% rename from public/icones/fermer.svg rename to ui/public/icones/fermer.svg diff --git a/public/icones/hamburger-menu.svg b/ui/public/icones/hamburger-menu.svg similarity index 100% rename from public/icones/hamburger-menu.svg rename to ui/public/icones/hamburger-menu.svg diff --git a/public/icones/instagram-icon.svg b/ui/public/icones/instagram-icon.svg similarity index 100% rename from public/icones/instagram-icon.svg rename to ui/public/icones/instagram-icon.svg diff --git a/public/images/.gitkeep b/ui/public/images/.gitkeep similarity index 100% rename from public/images/.gitkeep rename to ui/public/images/.gitkeep diff --git a/public/images/header_agecem.png b/ui/public/images/header_agecem.png similarity index 100% rename from public/images/header_agecem.png rename to ui/public/images/header_agecem.png diff --git a/public/js/header.js b/ui/public/js/header.js similarity index 100% rename from public/js/header.js rename to ui/public/js/header.js diff --git a/public/js/index.js b/ui/public/js/index.js similarity index 100% rename from public/js/index.js rename to ui/public/js/index.js diff --git a/public/public.go b/ui/public/public.go similarity index 100% rename from public/public.go rename to ui/public/public.go diff --git a/templates/html/snackbar.html b/ui/snackbar.html similarity index 100% rename from templates/html/snackbar.html rename to ui/snackbar.html diff --git a/ui/ui.go b/ui/ui.go new file mode 100644 index 0000000..c69ecf5 --- /dev/null +++ b/ui/ui.go @@ -0,0 +1,34 @@ +/* +Package templates contient les fichiers html à templater par l'application. + +Le contenu sera embedded dans le fichier binaire, dans le but de bundle les +dépendances avec l'application, simplifiant son déploiement. + +Une copie du contenu peut être obtenue par un appel de GetTemplatesFS(). +*/ +package ui + +import ( + "embed" + "io" + "text/template" + + "github.com/labstack/echo/v4" +) + +//go:embed *.html +var htmlFS embed.FS + +type Renderer struct { + templates *template.Template +} + +func (t *Renderer) Render(w io.Writer, name string, data any, c echo.Context) error { + return t.templates.ExecuteTemplate(w, name, data) +} + +func NewRenderer() *Renderer { + return &Renderer{ + templates: template.Must(template.ParseFS(htmlFS, "*.html")), + } +} diff --git a/templates/html/vie-etudiante.html b/ui/vie-etudiante.html similarity index 100% rename from templates/html/vie-etudiante.html rename to ui/vie-etudiante.html