2022-03-20 09:04:08 +00:00
|
|
|
package views
|
|
|
|
|
|
|
|
import (
|
2022-03-22 13:40:40 +00:00
|
|
|
"embed"
|
2022-03-20 09:04:08 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/l18n"
|
|
|
|
"github.com/bouncepaw/mycorrhiza/user"
|
|
|
|
"io"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Meta is a bundle of common stuffs used by views, templates.
|
|
|
|
type Meta struct {
|
|
|
|
Lc *l18n.Localizer
|
|
|
|
U *user.User
|
|
|
|
W io.Writer
|
|
|
|
PageTitle string
|
|
|
|
}
|
|
|
|
|
|
|
|
// MetaFrom makes a Meta from the given data. You are meant to further modify it.
|
|
|
|
func MetaFrom(w http.ResponseWriter, rq *http.Request) Meta {
|
|
|
|
return Meta{
|
|
|
|
Lc: l18n.FromRequest(rq),
|
|
|
|
U: user.FromRequest(rq),
|
|
|
|
W: w,
|
|
|
|
}
|
|
|
|
}
|
2022-03-22 13:40:40 +00:00
|
|
|
|
|
|
|
//go:embed *.html
|
|
|
|
var fs embed.FS
|