From 8de661b3bb47eec32cfbfab52c404e9fd610e8e2 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 22 Oct 2020 11:36:26 -0400 Subject: Hide caldav/carrdav in nav unless present --- renderer.go | 11 +++++++++++ themes/alps/nav.html | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/renderer.go b/renderer.go index a6b4118..4875745 100644 --- a/renderer.go +++ b/renderer.go @@ -26,6 +26,8 @@ type GlobalRenderData struct { Title string + HavePlugin func(name string) bool + // additional plugin-specific data Extra map[string]interface{} } @@ -74,6 +76,15 @@ func NewBaseRenderData(ctx *Context) *BaseRenderData { Path: strings.Split(ctx.Request().URL.Path, "/")[1:], Title: "Webmail", URL: ctx.Request().URL, + + HavePlugin: func(name string) bool { + for _, plugin := range ctx.Server.plugins { + if plugin.Name() == name { + return true + } + } + return false + }, } if ctx.Session != nil { diff --git a/themes/alps/nav.html b/themes/alps/nav.html index 1678434..d14a862 100644 --- a/themes/alps/nav.html +++ b/themes/alps/nav.html @@ -6,18 +6,22 @@ class="active" {{ end }} >Email + {{ if call .GlobalData.HavePlugin "caldav" }} Calendar + {{ end }} + {{ if call .GlobalData.HavePlugin "carddav" }} Contacts + {{ end }}
{{ .GlobalData.Username }} Settings -- cgit v1.2.3