From 177f73cb493de1f74599f4346ea0791da96c2c37 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Sat, 29 Feb 2020 11:25:46 -0500 Subject: [PATCH] Support additional track info in playlist This allows the user-defined mixtape.tmpl to define track notes for each individual track. By default, it only shows notes for the currently-playing track. --- mixtape.tmpl | 18 ++++++++++++++++++ templates.go | 21 +++++++++++++++++++++ templates/parts.tmpl | 3 +++ 3 files changed, 42 insertions(+) diff --git a/mixtape.tmpl b/mixtape.tmpl index a2503bc..35310ac 100644 --- a/mixtape.tmpl +++ b/mixtape.tmpl @@ -14,13 +14,31 @@ #playlist li { margin: 0.5em 0; } + li p { + display: none; + font-style: italic; + } li.active a { font-weight: bold; } + li.active p { + display: block; + } {{template "full-player" .Tracks}} +{{end}} + +{{define "track-info"}} + {{if eq .Num 1}} +

[Here I might introduce this mix.]

+

[Some notes about track 1.]

+ {{else if eq .Num 2}} +

[Some notes about track 2.]

+ {{else if eq .Num 5}} +

[Some notes about track 5.]

+ {{end}} {{end}} \ No newline at end of file diff --git a/templates.go b/templates.go index bdc56e1..9efdb78 100644 --- a/templates.go +++ b/templates.go @@ -34,15 +34,33 @@ var files = map[string]string{ #playlist li { margin: 0.5em 0; } + li p { + display: none; + font-style: italic; + } li.active a { font-weight: bold; } + li.active p { + display: block; + } {{template "full-player" .Tracks}} +{{end}} + +{{define "track-info"}} + {{if eq .Num 1}} +

[Here I might introduce this mix.]

+

[Some notes about track 1.]

+ {{else if eq .Num 2}} +

[Some notes about track 2.]

+ {{else if eq .Num 5}} +

[Some notes about track 5.]

+ {{end}} {{end}}`, "templates/parts.tmpl": `{{define "player"}} {{with $x := index . 0}} @@ -56,11 +74,14 @@ var files = map[string]string{ {{range $i, $el := .}} {{$el.Artist}} - {{$el.Title}} + {{template "track-info" $el}} {{end}} {{end}} +{{define "track-info"}}{{end}} + {{define "full-player"}} {{template "player" .}} {{template "playlist" .}} diff --git a/templates/parts.tmpl b/templates/parts.tmpl index 2074e9b..408fc5a 100644 --- a/templates/parts.tmpl +++ b/templates/parts.tmpl @@ -10,11 +10,14 @@ {{range $i, $el := .}} {{$el.Artist}} - {{$el.Title}} + {{template "track-info" $el}} {{end}} {{end}} +{{define "track-info"}}{{end}} + {{define "full-player"}} {{template "player" .}} {{template "playlist" .}}