Skip to content

Commit

Permalink
Add AppConfig as a function and get app settings from there
Browse files Browse the repository at this point in the history
Signed-off-by: Jo Vandeginste <[email protected]>
  • Loading branch information
jovandeginste committed Apr 9, 2024
1 parent 7183d05 commit 3374238
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 4 deletions.
2 changes: 0 additions & 2 deletions pkg/app/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pkg/app/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 1 addition & 1 deletion views/user/user_login.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h3 class="{{ IconFor `user-signin` }}">{{ i18n "Sign in" }}</h3>
</form>
</div>

{{ if not .RegistrationDisabled }}
{{ if not AppConfig.RegistrationDisabled }}
<div class="inner-form">
<h3 class="{{ IconFor `user-register` }}">
{{ i18n "Create a new account" }}
Expand Down
2 changes: 1 addition & 1 deletion views/workouts/workouts_show.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h2 class="{{ IconFor .Type.String }}">
</script>
<script src="{{ RouteFor `assets` }}/map.js"></script>
</div>
{{ if and (not $.SocialsDisabled) (not
{{ if and (not AppConfig.SocialsDisabled) (not
CurrentUser.Profile.SocialsDisabled) }} {{ template "workout_social"
.}} {{ end }}
</div>
Expand Down

0 comments on commit 3374238

Please sign in to comment.