Migrate viewutil

This commit is contained in:
Timur Ismagilov 2024-09-07 23:01:48 +03:00
parent 72b079cc2e
commit 132882c37c
3 changed files with 9 additions and 7 deletions

View File

@ -3,11 +3,12 @@ package newtmpl
import (
"embed"
"fmt"
"html/template"
"strings"
"github.com/bouncepaw/mycorrhiza/internal/cfg"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/bouncepaw/mycorrhiza/web/viewutil"
"html/template"
"strings"
)
//go:embed *.html

View File

@ -1,11 +1,12 @@
package viewutil
import (
"github.com/bouncepaw/mycorrhiza/internal/user"
"github.com/bouncepaw/mycorrhiza/l18n"
"html/template"
"io"
"net/http"
"github.com/bouncepaw/mycorrhiza/internal/user"
"github.com/bouncepaw/mycorrhiza/l18n"
)
// Meta is a bundle of common stuffs used by views, templates.

View File

@ -6,7 +6,7 @@ import (
"fmt"
"github.com/bouncepaw/mycorrhiza/internal/cfg"
"io/fs"
"log"
"log/slog"
"strings"
"text/template" // TODO: save the world
@ -125,7 +125,7 @@ func Base(meta Meta, title, body string, bodyAttributes map[string]string, headE
BodyAttributes: bodyAttributes,
})
if err != nil {
log.Println(err)
slog.Info("Failed to execute the legacy Base template; proceeding anyway", "err", err)
}
return w.String()
}
@ -149,7 +149,7 @@ func ExecutePage(meta Meta, chain Chain, data interface {
}) {
data.withBaseValues(meta, HeaderLinks, cfg.CommonScripts)
if err := chain.Get(meta).ExecuteTemplate(meta.W, "page", data); err != nil {
log.Println(err)
slog.Info("Failed to execute page; proceeding anyway", "err", err)
}
}