From 04120f5bfe0934f82745ea6783f0c785bbcd1050 Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 21 Apr 2025 22:40:14 -0600 Subject: refactor: extract views package to render html templates --- app/controllers/dashboard/controller.go | 12 ++---------- app/controllers/dashboard/show.html.tmpl | 27 --------------------------- 2 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 app/controllers/dashboard/show.html.tmpl (limited to 'app/controllers') diff --git a/app/controllers/dashboard/controller.go b/app/controllers/dashboard/controller.go index 26b182f..106666b 100644 --- a/app/controllers/dashboard/controller.go +++ b/app/controllers/dashboard/controller.go @@ -1,12 +1,11 @@ package dashboard import ( - "html/template" - "io/ioutil" "net/http" "github.com/xlgmokha/x/pkg/log" "github.com/xlgmokha/x/pkg/x" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/views" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/key" ) @@ -31,15 +30,8 @@ func (c *Controller) Show(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Header().Add("Content-Type", "text/html") - b, err := ioutil.ReadFile("show.html.tmpl") - if err != nil { - log.WithFields(r.Context(), log.Fields{"error": err}) - w.WriteHeader(http.StatusInternalServerError) - return - } - t := template.Must(template.New("show").Parse(string(b))) - if err := t.Execute(w, &ViewDashboardDTO{ + if err := views.Render(w, "dashboard/show", &ViewDashboardDTO{ CurrentUser: currentUser, Sparkles: []string{}, }); err != nil { diff --git a/app/controllers/dashboard/show.html.tmpl b/app/controllers/dashboard/show.html.tmpl deleted file mode 100644 index 5293117..0000000 --- a/app/controllers/dashboard/show.html.tmpl +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - SparkleLab - - - -
- - {{range .Sparkles}} -
{{ . }}
- {{else}} -
No Sparkles
- {{end}} -
- - -- cgit v1.2.3