cachefs/pkg/srv/templates.go
2022-03-13 20:36:15 +01:00

48 lines
1.3 KiB
Go

// Copyright (C) 2022 Marius Schellenberger
package srv
import "html/template"
var (
index = template.Must(template.New("index").Parse(`<!doctype html>
<html>
<head>
<style>
body { text-align: center; padding: 0 150px 0 150px; font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
table { text-align: left; }
</style>
</head>
<body>
<article>
<pre>
[v]: show video
[n]: skip file caching
[p]: preload file
</pre>
<table>
<tr><th>Path</th><th>Options</th></tr>
<tr><td><a href="../">../</a></td><td></td></tr>
{{range $s := .Dirs -}}
<tr><td><a href="{{$s}}">{{$s}}</a></td><td></td></tr>
{{end -}}
{{range $s := .Files -}}
<tr><td><a id="{{$s.Anchor}}" href="{{$s.Name}}">{{$s.Name}}</a></td>
<td><a href="{{$s.Name}}?v=t">[v]</a>&nbsp;<a href="{{$s.Name}}?n=t">[n]</a>&nbsp;<a href="{{$s.Name}}?p=t">[p]</a></td></tr>
{{end -}}
</table>
</article>
</body>
</html>`))
video = template.Must(template.New("video").Parse(`<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width">
</head>
<body>
<video id="video" style="width: 100%; height: 100%;" src="{{.}}" controls=""></video>
<script>document.getElementById("video").volume = 0.5;</script>
</body>
</html>`))
)