frontend: simplify assets filesystem

This commit is contained in:
nkanaev
2026-06-25 16:05:19 +01:00
parent d900c85ffa
commit 4701f864ec
4 changed files with 27 additions and 59 deletions

View File

@@ -44,7 +44,7 @@ func (m *Middleware) Handler(c *router.Context) {
c.Redirect(rootUrl)
return
} else {
c.HTML(http.StatusOK, assets.Template("login.html"), map[string]any{
c.HTML(http.StatusOK, assets.Templates().Lookup("login.html"), map[string]any{
"username": username,
"hasError": true,
"settings": m.DB.GetSettings().Map(),
@@ -52,7 +52,7 @@ func (m *Middleware) Handler(c *router.Context) {
return
}
}
c.HTML(http.StatusOK, assets.Template("login.html"), map[string]any{
c.HTML(http.StatusOK, assets.Templates().Lookup("login.html"), map[string]any{
"hasError": false,
"settings": m.DB.GetSettings().Map(),
})

View File

@@ -64,7 +64,7 @@ func (s *Server) handler() http.Handler {
}
func (s *Server) handleIndex(c *router.Context) {
c.HTML(http.StatusOK, assets.Template("index.html"), map[string]any{
c.HTML(http.StatusOK, assets.Templates().Lookup("index.html"), map[string]any{
"settings": s.db.GetSettings().Map(),
"authenticated": s.Username != "" && s.Password != "",
})
@@ -77,7 +77,7 @@ func (s *Server) handleStatic(c *router.Context) {
c.Out.WriteHeader(http.StatusNotFound)
return
}
http.StripPrefix(s.BasePath+"/static/", http.FileServer(http.FS(assets.FS))).
http.StripPrefix(s.BasePath+"/static/", http.FileServer(http.FS(assets.StaticFS()))).
ServeHTTP(c.Out, c.Req)
}