launcher: automatically display first help document
Change-Id: I0f887d5b9303876f6fbab4c96e935dbd58ff5936
diff --git a/core/installer/welcome/launcher-tmpl/launcher.html b/core/installer/welcome/launcher-tmpl/launcher.html
index 6b79d80..b12c96f 100644
--- a/core/installer/welcome/launcher-tmpl/launcher.html
+++ b/core/installer/welcome/launcher-tmpl/launcher.html
@@ -43,7 +43,7 @@
{{ template "help-menu-template" .Help }}
</div>
<div class="modal-right" id="modal-right-help-content-{{ CleanAppName .Name }}">
- {{ template "help-content-template" .Help }}
+ {{ template "help-content-template" (dict "Help" .Help "First" true) }}
</div>
</div>
</article>
@@ -56,7 +56,7 @@
</div>
{{ define "help-menu-template" }}
<ul class="ul">
- {{ range .}}
+ {{ range . }}
<li>
<a class="title-menu" id="title-{{ CleanAppName .Title }}">{{ .Title }}</a>
{{ template "help-menu-template" .Children }}
@@ -64,10 +64,11 @@
{{ end }}
</ul>
{{ end }}
- {{ define "help-content-template" }}
- {{ range . }}
- <div class="help-content" id="help-content-{{ CleanAppName .Title }}"> {{ .Contents }}</div>
- {{ template "help-content-template" .Children }}
+ {{ define "help-content-template" }}
+ {{ $first := .First }}
+ {{ range $i, $h := .Help }}
+ <div class="help-content" id="help-content-{{ CleanAppName $h.Title }}" {{ if (and $first (eq 0 $i)) }}style="display: block;"{{ end }}> {{ $h.Contents }}</div>
+ {{ template "help-content-template" (dict "Help" $h.Children "First" false) }}
{{ end }}
{{ end }}
<script src="/static/launcher.js"></script>
diff --git a/core/installer/welcome/launcher.go b/core/installer/welcome/launcher.go
index fe80fe0..51313eb 100644
--- a/core/installer/welcome/launcher.go
+++ b/core/installer/welcome/launcher.go
@@ -10,6 +10,7 @@
"github.com/giolekva/pcloud/core/installer"
+ "github.com/Masterminds/sprig/v3"
"github.com/gomarkdown/markdown"
)
@@ -76,7 +77,7 @@
if err != nil {
return nil, fmt.Errorf("failed to parse template: %v", err)
}
- t := template.New("index").Funcs(template.FuncMap{
+ t := template.New("index").Funcs(template.FuncMap(sprig.FuncMap())).Funcs(template.FuncMap{
"GetUserInitials": getUserInitials,
"CleanAppName": cleanAppName,
})