mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-12 21:40:26 +00:00
ea0c2f35d1
* Introduce views.Meta for passing common stuff around. * Store both category-related templates in one HTML file, which is go:embed:ded. * Fix a bug.
26 lines
526 B
Go
26 lines
526 B
Go
package views
|
|
|
|
import (
|
|
"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,
|
|
}
|
|
}
|