Skip to content

Commit

Permalink
Merge pull request #78 from jovandeginste/version-function
Browse files Browse the repository at this point in the history
Convert data to functions
  • Loading branch information
jovandeginste authored Apr 9, 2024
2 parents 1ae4c02 + 3374238 commit fe842d2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
3 changes: 0 additions & 3 deletions pkg/app/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +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["version"] = a.Version
data["RegistrationDisabled"] = a.Config.RegistrationDisabled
data["SocialsDisabled"] = a.Config.SocialsDisabled

a.addError(data, c)
a.addNotice(data, c)
Expand Down
2 changes: 2 additions & 0 deletions pkg/app/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ 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/partials/footer.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ define "footer" }}
<div class="footer">
<div>
Workout Tracker{{ with .version }},
Workout Tracker{{ with Version }},
<a
target="_blank"
title="Build time: {{ .BuildTime }}"
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 fe842d2

Please sign in to comment.