footer: Add a semi-flexible template system
This commit is contained in:
parent
bda763725e
commit
021fc3cc7e
26 changed files with 239 additions and 208 deletions
|
|
@ -28,7 +28,7 @@ type componentContext struct {
|
|||
}
|
||||
|
||||
func (admin *Admin) components(r *http.Request) (cp componentContext, err error) {
|
||||
admin.Dependencies.Custom.Update(&cp)
|
||||
admin.Dependencies.Custom.Update(&cp, r)
|
||||
|
||||
cp.Analytics = *admin.Analytics
|
||||
return
|
||||
|
|
@ -49,7 +49,7 @@ type ingredientsContext struct {
|
|||
}
|
||||
|
||||
func (admin *Admin) ingredients(r *http.Request) (cp ingredientsContext, err error) {
|
||||
admin.Dependencies.Custom.Update(&cp)
|
||||
admin.Dependencies.Custom.Update(&cp, r)
|
||||
|
||||
// find the instance itself!
|
||||
instance, err := admin.Dependencies.Instances.WissKI(r.Context(), mux.Vars(r)["slug"])
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ type indexContext struct {
|
|||
}
|
||||
|
||||
func (admin *Admin) index(r *http.Request) (idx indexContext, err error) {
|
||||
admin.Dependencies.Custom.Update(&idx)
|
||||
admin.Dependencies.Custom.Update(&idx, r)
|
||||
idx.Distillery, idx.Instances, err = admin.Status(r.Context(), true)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package admin
|
|||
|
||||
import (
|
||||
_ "embed"
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static"
|
||||
|
|
@ -25,13 +24,12 @@ var instanceTemplate = static.AssetsAdmin.MustParseShared(
|
|||
type instanceContext struct {
|
||||
custom.BaseContext
|
||||
|
||||
CSRF template.HTML
|
||||
Instance models.Instance
|
||||
Info status.WissKI
|
||||
}
|
||||
|
||||
func (admin *Admin) instance(r *http.Request) (is instanceContext, err error) {
|
||||
admin.Dependencies.Custom.Update(&is)
|
||||
admin.Dependencies.Custom.Update(&is, r)
|
||||
|
||||
is.CSRF = csrf.TemplateField(r)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package admin
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
_ "embed"
|
||||
|
|
@ -27,12 +26,11 @@ type userContext struct {
|
|||
custom.BaseContext
|
||||
httpx.FormContext
|
||||
|
||||
CSRF template.HTML
|
||||
Users []*auth.AuthUser
|
||||
}
|
||||
|
||||
func (admin *Admin) users(r *http.Request) (uc userContext, err error) {
|
||||
admin.Dependencies.Custom.Update(&uc)
|
||||
admin.Dependencies.Custom.Update(&uc, r)
|
||||
|
||||
uc.CSRF = csrf.TemplateField(r)
|
||||
uc.Users, err = admin.Dependencies.Auth.Users(r.Context())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue