Browse Source

Hide caldav/carrdav in nav unless present

master
Drew DeVault 3 years ago
parent
commit
8de661b3bb
2 changed files with 15 additions and 0 deletions
  1. +11
    -0
      renderer.go
  2. +4
    -0
      themes/alps/nav.html

+ 11
- 0
renderer.go View File

@@ -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 {


+ 4
- 0
themes/alps/nav.html View File

@@ -6,18 +6,22 @@
class="active"
{{ end }}
>Email</a>
{{ if call .GlobalData.HavePlugin "caldav" }}
<a
href="/calendar"
{{ if eq $page "calendar" }}
class="active"
{{ end }}
>Calendar</a>
{{ end }}
{{ if call .GlobalData.HavePlugin "carddav" }}
<a
href="/contacts"
{{ if eq $page "contacts" }}
class="active"
{{ end }}
>Contacts</a>
{{ end }}
<div>
<span>{{ .GlobalData.Username }}</span>
<a href="/settings">Settings</a>


Loading…
Cancel
Save