custom: Add new footer template and context

This commit is contained in:
Tom Wiesing 2023-01-06 19:56:13 +01:00
parent 009d649ea6
commit bda763725e
No known key found for this signature in database
18 changed files with 197 additions and 33 deletions

View file

@ -2,11 +2,11 @@ package admin
import (
"net/http"
"time"
_ "embed"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static/custom"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/instances"
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/pkg/httpx"
@ -22,15 +22,15 @@ var componentsTemplate = static.AssetsAdmin.MustParseShared(
)
type componentContext struct {
Time time.Time
custom.BaseContext
Analytics lazy.PoolAnalytics
}
func (admin *Admin) components(r *http.Request) (cp componentContext, err error) {
cp.Analytics = *admin.Analytics
cp.Time = time.Now().UTC()
admin.Dependencies.Custom.Update(&cp)
cp.Analytics = *admin.Analytics
return
}
@ -42,14 +42,14 @@ var ingredientsTemplate = static.AssetsAdmin.MustParseShared(
)
type ingredientsContext struct {
Time time.Time
custom.BaseContext
Instance models.Instance
Analytics *lazy.PoolAnalytics
}
func (admin *Admin) ingredients(r *http.Request) (cp ingredientsContext, err error) {
cp.Time = time.Now().UTC()
admin.Dependencies.Custom.Update(&cp)
// find the instance itself!
instance, err := admin.Dependencies.Instances.WissKI(r.Context(), mux.Vars(r)["slug"])