1
0
mirror of https://github.com/thebaer/cdr.git synced 2024-11-15 01:31:01 +00:00

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.
This commit is contained in:
Matt Baer 2020-02-29 11:25:46 -05:00
parent 9a8150b144
commit 177f73cb49
3 changed files with 42 additions and 0 deletions

View File

@ -14,9 +14,16 @@
#playlist li { #playlist li {
margin: 0.5em 0; margin: 0.5em 0;
} }
li p {
display: none;
font-style: italic;
}
li.active a { li.active a {
font-weight: bold; font-weight: bold;
} }
li.active p {
display: block;
}
</style> </style>
</head> </head>
<body> <body>
@ -24,3 +31,14 @@
</body> </body>
</html> </html>
{{end}} {{end}}
{{define "track-info"}}
{{if eq .Num 1}}
<p>[Here I might introduce this mix.]</p>
<p>[Some notes about track 1.]</p>
{{else if eq .Num 2}}
<p>[Some notes about track 2.]</p>
{{else if eq .Num 5}}
<p>[Some notes about track 5.]</p>
{{end}}
{{end}}

View File

@ -34,15 +34,33 @@ var files = map[string]string{
#playlist li { #playlist li {
margin: 0.5em 0; margin: 0.5em 0;
} }
li p {
display: none;
font-style: italic;
}
li.active a { li.active a {
font-weight: bold; font-weight: bold;
} }
li.active p {
display: block;
}
</style> </style>
</head> </head>
<body> <body>
{{template "full-player" .Tracks}} {{template "full-player" .Tracks}}
</body> </body>
</html> </html>
{{end}}
{{define "track-info"}}
{{if eq .Num 1}}
<p>[Here I might introduce this mix.]</p>
<p>[Some notes about track 1.]</p>
{{else if eq .Num 2}}
<p>[Some notes about track 2.]</p>
{{else if eq .Num 5}}
<p>[Some notes about track 5.]</p>
{{end}}
{{end}}`, {{end}}`,
"templates/parts.tmpl": `{{define "player"}} "templates/parts.tmpl": `{{define "player"}}
{{with $x := index . 0}} {{with $x := index . 0}}
@ -56,11 +74,14 @@ var files = map[string]string{
{{range $i, $el := .}} {{range $i, $el := .}}
<li{{if eq $i 0}} class="active"{{end}}> <li{{if eq $i 0}} class="active"{{end}}>
<a href="{{$el.Filename}}">{{$el.Artist}} - {{$el.Title}}</a> <a href="{{$el.Filename}}">{{$el.Artist}} - {{$el.Title}}</a>
{{template "track-info" $el}}
</li> </li>
{{end}} {{end}}
</ol> </ol>
{{end}} {{end}}
{{define "track-info"}}{{end}}
{{define "full-player"}} {{define "full-player"}}
{{template "player" .}} {{template "player" .}}
{{template "playlist" .}} {{template "playlist" .}}

View File

@ -10,11 +10,14 @@
{{range $i, $el := .}} {{range $i, $el := .}}
<li{{if eq $i 0}} class="active"{{end}}> <li{{if eq $i 0}} class="active"{{end}}>
<a href="{{$el.Filename}}">{{$el.Artist}} - {{$el.Title}}</a> <a href="{{$el.Filename}}">{{$el.Artist}} - {{$el.Title}}</a>
{{template "track-info" $el}}
</li> </li>
{{end}} {{end}}
</ol> </ol>
{{end}} {{end}}
{{define "track-info"}}{{end}}
{{define "full-player"}} {{define "full-player"}}
{{template "player" .}} {{template "player" .}}
{{template "playlist" .}} {{template "playlist" .}}