From 28c60aecc9549933f9ec6d9d8ed14d2843c9bd1c Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Wed, 28 May 2025 20:08:25 +0000 Subject: [PATCH] rename html fragments to go.tmpl extension --- app/routes/config.go | 12 ++++++------ app/routes/index.go | 7 ++++--- web/html/{config-boot.frag => config-boot.go.tmpl} | 0 .../{config-devices.frag => config-devices.go.tmpl} | 0 web/html/{config-nets.frag => config-nets.go.tmpl} | 0 .../{config-volumes.frag => config-volumes.go.tmpl} | 0 ...{index-instances.frag => index-instances.go.tmpl} | 0 7 files changed, 10 insertions(+), 9 deletions(-) rename web/html/{config-boot.frag => config-boot.go.tmpl} (100%) rename web/html/{config-devices.frag => config-devices.go.tmpl} (100%) rename web/html/{config-nets.frag => config-nets.go.tmpl} (100%) rename web/html/{config-volumes.frag => config-volumes.go.tmpl} (100%) rename web/html/{index-instances.frag => index-instances.go.tmpl} (100%) diff --git a/app/routes/config.go b/app/routes/config.go index 5c8fd28..280a1cd 100644 --- a/app/routes/config.go +++ b/app/routes/config.go @@ -42,7 +42,7 @@ type GlobalConfig struct { } } -type UserConfig struct { +type UserConfigResources struct { CPU struct { Global []CPUConfig Nodes map[string][]CPUConfig @@ -102,7 +102,7 @@ func HandleGETConfigVolumesFragment(c *gin.Context) { } c.Header("Content-Type", "text/plain") - common.TMPL.ExecuteTemplate(c.Writer, "html/config-volumes.frag", gin.H{ + common.TMPL.ExecuteTemplate(c.Writer, "html/config-volumes.go.tmpl", gin.H{ "config": config, }) c.Status(http.StatusOK) @@ -125,7 +125,7 @@ func HandleGETConfigNetsFragment(c *gin.Context) { } c.Header("Content-Type", "text/plain") - common.TMPL.ExecuteTemplate(c.Writer, "html/config-nets.frag", gin.H{ + common.TMPL.ExecuteTemplate(c.Writer, "html/config-nets.go.tmpl", gin.H{ "config": config, }) c.Status(http.StatusOK) @@ -148,7 +148,7 @@ func HandleGETConfigDevicesFragment(c *gin.Context) { } c.Header("Content-Type", "text/plain") - common.TMPL.ExecuteTemplate(c.Writer, "html/config-devices.frag", gin.H{ + common.TMPL.ExecuteTemplate(c.Writer, "html/config-devices.go.tmpl", gin.H{ "config": config, }) c.Status(http.StatusOK) @@ -171,7 +171,7 @@ func HandleGETConfigBootFragment(c *gin.Context) { } c.Header("Content-Type", "text/plain") - common.TMPL.ExecuteTemplate(c.Writer, "html/config-boot.frag", gin.H{ + common.TMPL.ExecuteTemplate(c.Writer, "html/config-boot.go.tmpl", gin.H{ "config": config, }) c.Status(http.StatusOK) @@ -264,7 +264,7 @@ func GetCPUTypes(vm VMPath, auth common.Auth) (common.Select, error) { if code != 200 { return cputypes, fmt.Errorf("request to %s resulted in %+v", path, res) } - user := UserConfig{} + user := UserConfigResources{} err = mapstructure.Decode(ctx.Body, &user) if err != nil { return cputypes, err diff --git a/app/routes/index.go b/app/routes/index.go index d10e3af..b8dac6c 100644 --- a/app/routes/index.go +++ b/app/routes/index.go @@ -50,11 +50,12 @@ func HandleGETIndex(c *gin.Context) { if err != nil { common.HandleNonFatalError(c, err) } - c.HTML(http.StatusOK, "html/index.html", gin.H{ + page := gin.H{ "global": common.Global, "page": "index", "instances": instances, - }) + } + c.HTML(http.StatusOK, "html/index.html", page) } else { // return index without populating c.Redirect(http.StatusFound, "/login") // if user is not authed, redirect user to login page } @@ -68,7 +69,7 @@ func HandleGETInstancesFragment(c *gin.Context) { common.HandleNonFatalError(c, err) } c.Header("Content-Type", "text/plain") - common.TMPL.ExecuteTemplate(c.Writer, "html/index-instances.frag", gin.H{ + common.TMPL.ExecuteTemplate(c.Writer, "html/index-instances.go.tmpl", gin.H{ "instances": instances, }) c.Status(http.StatusOK) diff --git a/web/html/config-boot.frag b/web/html/config-boot.go.tmpl similarity index 100% rename from web/html/config-boot.frag rename to web/html/config-boot.go.tmpl diff --git a/web/html/config-devices.frag b/web/html/config-devices.go.tmpl similarity index 100% rename from web/html/config-devices.frag rename to web/html/config-devices.go.tmpl diff --git a/web/html/config-nets.frag b/web/html/config-nets.go.tmpl similarity index 100% rename from web/html/config-nets.frag rename to web/html/config-nets.go.tmpl diff --git a/web/html/config-volumes.frag b/web/html/config-volumes.go.tmpl similarity index 100% rename from web/html/config-volumes.frag rename to web/html/config-volumes.go.tmpl diff --git a/web/html/index-instances.frag b/web/html/index-instances.go.tmpl similarity index 100% rename from web/html/index-instances.frag rename to web/html/index-instances.go.tmpl