Change homepage to dark mode
This commit is contained in:
parent
ea80ac0b6a
commit
5c1af23f65
@ -4,12 +4,14 @@ import (
|
||||
"code.mrmelon54.xyz/sean/melon-tools/module/discord"
|
||||
"code.mrmelon54.xyz/sean/melon-tools/module/gitea"
|
||||
"code.mrmelon54.xyz/sean/melon-tools/utils"
|
||||
_ "embed"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"github.com/google/uuid"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/joho/godotenv"
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -22,6 +24,9 @@ var (
|
||||
discord.New(),
|
||||
}
|
||||
sessionStore = sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY")))
|
||||
|
||||
//go:embed pages/index.go.html
|
||||
indexTemplate string
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -37,9 +42,25 @@ func main() {
|
||||
router.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) {
|
||||
rw.Header().Set("Content-Type", "text/html")
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
_, _ = rw.Write([]byte("Melon Tools<br/>\n"))
|
||||
|
||||
modTmp := make([]template.HTML, 0)
|
||||
for _, v := range modules {
|
||||
_, _ = rw.Write([]byte(fmt.Sprintf("<a href=\"%s\">%s</a><br/>\n", v.GetEndpoint(), v.GetName())))
|
||||
modTmp = append(modTmp, template.HTML(fmt.Sprintf("<a href=\"%s\">%s</a>", v.GetEndpoint(), v.GetName())))
|
||||
}
|
||||
|
||||
tmp, err := template.New("homepage").Parse(indexTemplate)
|
||||
if err != nil {
|
||||
fmt.Println("Template parse error:", err)
|
||||
return
|
||||
}
|
||||
err = tmp.Execute(rw, struct {
|
||||
Modules []template.HTML
|
||||
}{
|
||||
Modules: modTmp,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println("Template execute error:", err)
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
|
25
cmd/melon-tools/pages/index.go.html
Normal file
25
cmd/melon-tools/pages/index.go.html
Normal file
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-GB">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Melon Tools</title>
|
||||
<style>
|
||||
html, body {
|
||||
background-color: #2a2c2d;
|
||||
color: #d8d4d0;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #4699fa;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Melon Tools</h1>
|
||||
<ul>
|
||||
{{range .Modules}}
|
||||
<li>{{.}}</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user