mirror of
https://github.com/thebaer/cdr.git
synced 2024-11-15 01:31:01 +00:00
Fall back to default mixtape template
if there is no mixtape.tmpl in the destination directory.
This commit is contained in:
parent
2246bed69b
commit
ef54c10c9d
@ -1,4 +1,4 @@
|
||||
//go:generate inline -o templates.go -p cdr templates/parts.tmpl
|
||||
//go:generate inline -o templates.go -p cdr mixtape.tmpl templates/parts.tmpl
|
||||
|
||||
package cdr
|
||||
|
||||
@ -14,9 +14,12 @@ func Render(m *Mixtape, w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
mixtapeRawTmpl, err := ioutil.ReadFile("mixtape.tmpl")
|
||||
if err != nil {
|
||||
mixtapeRawTmpl, err = ReadAsset("mixtape.tmpl", false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
t, err := template.New("mixtape").Parse(string(mixtapeRawTmpl) + string(partsRawTmpl))
|
||||
if err != nil {
|
||||
return err
|
||||
|
29
templates.go
29
templates.go
@ -1,4 +1,4 @@
|
||||
// Code generated by "inline -o templates.go -p cdr templates/parts.tmpl" -- DO NOT EDIT --
|
||||
// Code generated by "inline -o templates.go -p cdr mixtape.tmpl templates/parts.tmpl" -- DO NOT EDIT --
|
||||
|
||||
package cdr
|
||||
|
||||
@ -18,6 +18,33 @@ func ReadAsset(file string, useLocal bool) ([]byte, error) {
|
||||
}
|
||||
|
||||
var files = map[string]string{
|
||||
"mixtape.tmpl": `{{define "mixtape"}}
|
||||
<html>
|
||||
<head>
|
||||
<title>Mixtape</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-size: 1.2em;
|
||||
margin: 1em;
|
||||
}
|
||||
.active {
|
||||
font-weight: bold;
|
||||
}
|
||||
#playlist {
|
||||
list-style: none;
|
||||
margin: 1em 0;
|
||||
padding: 0;
|
||||
}
|
||||
#playlist li {
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{{template "full-player" .Tracks}}
|
||||
</body>
|
||||
</html>
|
||||
{{end}}`,
|
||||
"templates/parts.tmpl": `{{define "player"}}
|
||||
{{with $x := index . 0}}
|
||||
<audio id="player" preload="auto" tabindex="0" controls>
|
||||
|
Loading…
Reference in New Issue
Block a user