use go html templates

This commit is contained in:
ari melody 2025-06-08 21:15:39 +01:00
parent 1ff61e9b8f
commit 59230b7ad5
Signed by: ari
GPG key ID: CF99829C92678188
3 changed files with 142 additions and 80 deletions

91
templates/dir.html Normal file
View file

@ -0,0 +1,91 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Files in {{.Name}}</title>
<style>
html {
background: #101010;
color: #f0f0f0;
font-family: 'Monaspace Argon', monospace;
}
body {
width: min(calc(100% - 1em), 1000px);
margin: 0 auto;
}
table {
width: 100%;
border-collapse: collapse;
}
tr:hover {
background-color: #80808040;
}
th {
text-align: left;
}
td {
width: 1%;
max-width: 500px;
padding: .2em 0;
}
table a {
display: block;
line-break: anywhere;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
a {
color: #b7fd49;
text-decoration: none;
}
a:hover {
color: white;
text-decoration: underline;
}
footer {
padding: 1em 0;
}
</style>
</head>
<body>
<main>
<h1>Files in {{.Name}}</h1>
<hr>
<table>
<tr>
<th>Name</th>
<th>Size</th>
<th>Modified</th>
</tr>
{{if not .Root}}
<tr>
<td><a href="./..">../</a></td>
<td>&mdash;</td>
<td>&mdash;</td>
</tr>
{{end}}
{{range .Files}}
<tr>
<td><a href="{{.URI}}">{{.Name}}</a></td>
<td>{{if .IsDir}}&mdash;{{else}}{{.Size}}{{end}}</td>
<td>{{.ModifiedDate}}</td>
</tr>
{{end}}
</table>
<hr>
</main>
<footer>
<em>made with <span aria-label="love"></span> by ari, 2025 <a href="https://git.arimelody.me/ari/indir" target="_blank">[source]</a></em>
</footer>
</body>
</html>