Require access to Still via method
This commit adds a safeguard to accessing the still from a specific component by requiring access via the component.GetStill method.
This commit is contained in:
parent
81fa84c244
commit
8235ea9105
63 changed files with 288 additions and 197 deletions
|
|
@ -30,7 +30,7 @@ func (home *Home) Routes() component.Routes {
|
|||
MatchAllDomains: true,
|
||||
CSRF: false,
|
||||
|
||||
MenuTitle: home.Config.Home.Title,
|
||||
MenuTitle: component.GetStill(home).Config.Home.Title,
|
||||
MenuSticky: true,
|
||||
MenuPriority: component.MenuHome,
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ func (home *Home) HandleRoute(ctx context.Context, route string) (http.Handler,
|
|||
dflt.Fallback = home.publicHandler(ctx)
|
||||
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
slug, ok := home.Config.HTTP.NormSlugFromHost(r.Host)
|
||||
slug, ok := component.GetStill(home).Config.HTTP.NormSlugFromHost(r.Host)
|
||||
switch {
|
||||
case !ok:
|
||||
http.NotFound(w, r)
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ type publicContext struct {
|
|||
const logoHTML = template.HTML(`<img src="/logo.svg" alt="WissKI Distillery Logo" class="biglogo">`)
|
||||
|
||||
func (home *Home) publicHandler(ctx context.Context) http.Handler {
|
||||
title := home.Config.Home.Title
|
||||
config := component.GetStill(home).Config.Home
|
||||
|
||||
tpl := publicTemplate.Prepare(
|
||||
home.dependencies.Templating,
|
||||
// set title and menu item
|
||||
templating.Title(title),
|
||||
templating.Title(config.Title),
|
||||
templating.Crumbs(
|
||||
component.MenuItem{Title: title, Path: "/"},
|
||||
component.MenuItem{Title: config.Title, Path: "/"},
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ func (home *Home) publicHandler(ctx context.Context) http.Handler {
|
|||
// prepare about
|
||||
pc.aboutContext.Logo = logoHTML
|
||||
pc.aboutContext.Instances = home.dependencies.ListInstances.Infos()
|
||||
pc.aboutContext.SelfRedirect = home.Config.Home.SelfRedirect.String()
|
||||
pc.aboutContext.SelfRedirect = config.SelfRedirect.String()
|
||||
|
||||
// render the about template
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ func (home *Home) publicHandler(ctx context.Context) http.Handler {
|
|||
pc.ListEnabled = home.dependencies.ListInstances.ShouldShowList(r)
|
||||
|
||||
// title of the list
|
||||
pc.ListTitle = home.Config.Home.List.Title
|
||||
pc.ListTitle = config.List.Title
|
||||
|
||||
return
|
||||
})
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||
)
|
||||
|
||||
func (home *Home) loadRedirect(ctx context.Context) (redirect Redirect, err error) {
|
||||
|
|
@ -19,7 +21,7 @@ func (home *Home) loadRedirect(ctx context.Context) (redirect Redirect, err erro
|
|||
redirect.Permanent = false
|
||||
|
||||
// load the overrides file
|
||||
overrides, err := os.Open(home.Config.Paths.OverridesJSON)
|
||||
overrides, err := os.Open(component.GetStill(home).Config.Paths.OverridesJSON)
|
||||
if err != nil {
|
||||
return redirect, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue