mirror of
https://github.com/httpjamesm/AnonymousOverflow.git
synced 2025-04-20 13:59:16 +00:00
Propagate theme variable to template in options.go
Propagate the `theme` variable from the environment to the template in `src/routes/options.go` * Retrieve the `theme` variable from the environment using `os.Getenv("THEME")` * Set the `theme` variable in the `gin.H` map when rendering the `home.html` template --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/httpjamesm/AnonymousOverflow/pull/145?shareId=6397c9b4-9450-425c-bbbe-019425965d2b).
This commit is contained in:
parent
bd969567a4
commit
31390edfc4
1 changed files with 6 additions and 0 deletions
|
@ -3,6 +3,7 @@ package routes
|
||||||
import (
|
import (
|
||||||
"anonymousoverflow/config"
|
"anonymousoverflow/config"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -17,9 +18,14 @@ func ChangeOptions(c *gin.Context) {
|
||||||
text = "enabled"
|
text = "enabled"
|
||||||
}
|
}
|
||||||
c.SetCookie("disable_images", fmt.Sprintf("%t", !c.MustGet("disable_images").(bool)), 60*60*24*365*10, "/", "", false, true)
|
c.SetCookie("disable_images", fmt.Sprintf("%t", !c.MustGet("disable_images").(bool)), 60*60*24*365*10, "/", "", false, true)
|
||||||
|
theme := os.Getenv("THEME")
|
||||||
|
if theme == "" {
|
||||||
|
theme = "auto"
|
||||||
|
}
|
||||||
c.HTML(200, "home.html", gin.H{
|
c.HTML(200, "home.html", gin.H{
|
||||||
"successMessage": "Images are now " + text,
|
"successMessage": "Images are now " + text,
|
||||||
"version": config.Version,
|
"version": config.Version,
|
||||||
|
"theme": theme,
|
||||||
})
|
})
|
||||||
default:
|
default:
|
||||||
c.String(400, "400 Bad Request")
|
c.String(400, "400 Bad Request")
|
||||||
|
|
Loading…
Add table
Reference in a new issue