Migrate viewutil
This commit is contained in:
parent
72b079cc2e
commit
132882c37c
@ -3,11 +3,12 @@ package newtmpl
|
|||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/bouncepaw/mycorrhiza/internal/cfg"
|
"github.com/bouncepaw/mycorrhiza/internal/cfg"
|
||||||
"github.com/bouncepaw/mycorrhiza/util"
|
"github.com/bouncepaw/mycorrhiza/util"
|
||||||
"github.com/bouncepaw/mycorrhiza/web/viewutil"
|
"github.com/bouncepaw/mycorrhiza/web/viewutil"
|
||||||
"html/template"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed *.html
|
//go:embed *.html
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
package viewutil
|
package viewutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bouncepaw/mycorrhiza/internal/user"
|
|
||||||
"github.com/bouncepaw/mycorrhiza/l18n"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/bouncepaw/mycorrhiza/internal/user"
|
||||||
|
"github.com/bouncepaw/mycorrhiza/l18n"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Meta is a bundle of common stuffs used by views, templates.
|
// Meta is a bundle of common stuffs used by views, templates.
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bouncepaw/mycorrhiza/internal/cfg"
|
"github.com/bouncepaw/mycorrhiza/internal/cfg"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log/slog"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template" // TODO: save the world
|
"text/template" // TODO: save the world
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ func Base(meta Meta, title, body string, bodyAttributes map[string]string, headE
|
|||||||
BodyAttributes: bodyAttributes,
|
BodyAttributes: bodyAttributes,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
slog.Info("Failed to execute the legacy Base template; proceeding anyway", "err", err)
|
||||||
}
|
}
|
||||||
return w.String()
|
return w.String()
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ func ExecutePage(meta Meta, chain Chain, data interface {
|
|||||||
}) {
|
}) {
|
||||||
data.withBaseValues(meta, HeaderLinks, cfg.CommonScripts)
|
data.withBaseValues(meta, HeaderLinks, cfg.CommonScripts)
|
||||||
if err := chain.Get(meta).ExecuteTemplate(meta.W, "page", data); err != nil {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user