cachefs/pkg/srv/templates.go
2022-03-20 21:50:12 +01:00

152 lines
3.2 KiB
Go

// Copyright (C) 2022 Marius Schellenberger
package srv
import "html/template"
var (
index = template.Must(template.New("index").Parse(`<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#222222">
<meta name="description" content="cachefs">
<title>cachefs | {{.Base}}</title>
<style>
body {
font: 20px Helvetica, sans-serif;
background-color: #111;
color: #e6e6e6;
margin: 0px;
padding: 0 150px 0 150px;
}
@media only screen and (max-width: 800px) {
body {
padding: 0;
}
}
article {
background-color: #222;
}
pre {
margin: 0;
padding: 10px 0 14px 0;
}
a:link {
color: #e6e6e6;
text-decoration: none;
}
a:visited {
color: #e6e6e6;
}
a:hover {
color: #fff;
text-decoration: underline;
}
a:active {
color: #a6a6a6;
}
table {
border-collapse: collapse;
margin-bottom: 50px;
}
td {
padding: 0;
}
.listitem {
background-color: #333;
}
.listitem:hover {
background-color: #404040;
}
.listitem:active {
background-color: #202020;
}
.listpath {
white-space: normal;
overflow: hidden;
width: 100%;
}
.listpath a {
display: block;
min-height: 45px;
padding: 0.55em 0 0 5px;
overflow: hidden;
width: 100%;
box-sizing: border-box;
word-break: break-all;
}
.listoptions {
padding-right: 5px;
white-space: nowrap;
text-align: right;
}
.listoptions span, .listoptions a {
margin-left: 10px;
}
.spacer {
height: 3px;
}
.red {
background-color: #e74c3c;
}
.yellow {
background-color: #f39c12;
}
.green {
background-color: #4caf50;
}
span {
color: #9b9b9b;
font-size: 15px;
}
</style>
</head>
<body>
<article>
<pre>[v]: show video
[n]: skip file caching
[p]: preload file
[s]: stop preloading</pre>
<table>
<tr class="listitem">
<td class="listpath"><a href="../">../</a></td>
<td class="listoptions">[dir]</td>
</tr>
<tr class="spacer"><td colspan="2"></td></tr>
{{range $s := .Dirs -}}
<tr class="listitem">
<td class="listpath"><a href="{{$s.URI}}">{{$s.Name}}</a></td>
<td class="listoptions">[dir]</td>
</tr>
<tr class="spacer"><td colspan="2"></td></tr>
{{end -}}
{{range $s := .Files -}}
<tr class="listitem">
<td class="listpath"><a id="{{$s.Anchor}}" href="{{$s.URI}}">{{$s.Name}}</a></td>
<td class="listoptions">
{{if ge $s.Status 0}}<span>{{$s.Status}}%</span>{{end}}<a href="{{$s.URI}}?o=v">[v]</a><a href="{{$s.URI}}?o=n">[n]</a><a href="{{$s.URI}}?o=p">[p]</a><a href="{{$s.URI}}?o=s">[s]</a>
</td>
</tr>
<tr class="spacer"><td colspan="2">
{{if ge $s.Status 0}}
<div class="spacer {{if le $s.Status 35}}red{{else if le $s.Status 65}}yellow{{else}}green{{end}}" style="width: {{$s.Status}}%;"></div>
{{end -}}
</td></tr>
{{end -}}
</table>
</article>
</body>
</html>`))
video = template.Must(template.New("video").Parse(`<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>cachefs | {{.}}</title>
</head>
<body>
<video id="video" style="width: 100%; height: 100%;" src="{{.}}" controls=""></video>
<script>document.getElementById("video").volume = 0.5;</script>
</body>
</html>`))
)