Skip to content

Commit

Permalink
Only show '+' button on relevant pages
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinmclean committed Apr 29, 2024
1 parent 252ca8e commit 6dbd59a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions garden-app/server/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ func templateFuncs(r *http.Request) map[string]any {
"NotRefresh": func() bool {
return r.URL.Query().Get("refresh") != "true"
},
"IncludePlusButton": func() bool {
parts := strings.Split(r.URL.Path, "/")
if len(parts) == 0 {
return false
}
_, err := xid.FromString(parts[len(parts)-1])
return err != nil
},
}
}

Expand Down
3 changes: 2 additions & 1 deletion garden-app/server/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
href="/water_schedules?exclude_weather_data=true">Water Schedules</a></li>
<li {{ if URLContains "/weather_clients" }}class="uk-active" {{ end }}><a
href="/weather_clients">Weather Clients</a></li>

<li>
</li>
</ul>
</div>
{{ if IncludePlusButton }}
<div class="uk-navbar-right">
<ul class="uk-navbar-nav">
<li>
Expand All @@ -49,6 +49,7 @@
</li>
</ul>
</div>
{{ end }}
</div>
</div>
</nav>
Expand Down

0 comments on commit 6dbd59a

Please sign in to comment.