From 3374238bc625150b05882e0ca75425055cf7198b Mon Sep 17 00:00:00 2001 From: Jo Vandeginste Date: Tue, 9 Apr 2024 12:05:55 +0200 Subject: [PATCH] Add AppConfig as a function and get app settings from there Signed-off-by: Jo Vandeginste --- pkg/app/data.go | 2 -- pkg/app/templates.go | 1 + views/user/user_login.html | 2 +- views/workouts/workouts_show.html | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/app/data.go b/pkg/app/data.go index 37f665a5..ea4149cc 100644 --- a/pkg/app/data.go +++ b/pkg/app/data.go @@ -52,8 +52,6 @@ func (a *App) getCurrentUser(c echo.Context) *database.User { func (a *App) defaultData(c echo.Context) map[string]interface{} { data := map[string]interface{}{} - data["RegistrationDisabled"] = a.Config.RegistrationDisabled - data["SocialsDisabled"] = a.Config.SocialsDisabled a.addError(data, c) a.addNotice(data, c) diff --git a/pkg/app/templates.go b/pkg/app/templates.go index a9e786a2..ab581e50 100644 --- a/pkg/app/templates.go +++ b/pkg/app/templates.go @@ -54,6 +54,7 @@ func (a *App) viewTemplateFunctions() template.FuncMap { return template.FuncMap{ "i18n": echoFunc, "Version": func() *Version { return &a.Version }, + "AppConfig": func() *Config { return &a.Config }, "language": func() string { return BrowserLanguage }, "humanizer": func() *humanize.Humanizer { return h }, "CurrentUser": func() *database.User { return nil }, diff --git a/views/user/user_login.html b/views/user/user_login.html index 8e108186..f7f91401 100644 --- a/views/user/user_login.html +++ b/views/user/user_login.html @@ -51,7 +51,7 @@

{{ i18n "Sign in" }}

- {{ if not .RegistrationDisabled }} + {{ if not AppConfig.RegistrationDisabled }}

{{ i18n "Create a new account" }} diff --git a/views/workouts/workouts_show.html b/views/workouts/workouts_show.html index f73e67b1..ebef6ccf 100644 --- a/views/workouts/workouts_show.html +++ b/views/workouts/workouts_show.html @@ -52,7 +52,7 @@

- {{ if and (not $.SocialsDisabled) (not + {{ if and (not AppConfig.SocialsDisabled) (not CurrentUser.Profile.SocialsDisabled) }} {{ template "workout_social" .}} {{ end }}