Initial commit.

This commit is contained in:
magmaus3 2023-02-12 13:11:24 +01:00
commit e886b8648d
Signed by: magmaus3
GPG key ID: 966755D3F4A9B251
3 changed files with 250 additions and 0 deletions

5
Caddyfile Normal file
View file

@ -0,0 +1,5 @@
:8000
file_server {
browse template.html
}

156
style.css Normal file
View file

@ -0,0 +1,156 @@
/* This stylesheet file is based on the browse.html template, provided at
* https://github.com/caddyserver/caddy/blob/master/modules/caddyhttp/fileserver/browse.html
*/
* { padding: 0; margin: 0; }
body {
padding: 1em;
font-family: monospace;
text-rendering: optimizespeed;
background-color: #20202a;
color: #A09999;
}
main {
display: block;
}
.readmeFile > * {
background-color: inherit;
color: inherit;
}
.readmeHeader {
font-size: small;
color: #979494;
margin-bottom: 1em;
}
.readmeFile {
margin-top: 1em;
padding: 0.5em;
margin: 1rem;
color: white;
}
.readmeFile li {
list-style-position: inside;
}
/* .readmeFile li { */
/* margin-left: 1rem; */
/* margin-right: 1rem; */
/* } */
a {
color: #7dc1ff;
text-decoration: none;
}
a:active {
border-radius: 1rem;
box-shadow: 3px 3px 15px black;
}
a:hover,
h1 a:hover {
color: #b0ff94;
}
a:visited {
color: #fd7dfd;
}
a:visited:hover {
color: #b0ff94;
}
header {
padding-top: 25px;
padding-bottom: 15px;
}
h1 {
font-size: 20px;
font-weight: normal;
white-space: nowrap;
overflow-x: hidden;
text-overflow: ellipsis;
color: #999;
}
h1 a {
/* color: #000; */
margin: 0 4px;
}
h1 a:hover {
text-decoration: underline;
}
h1 a:first-child {
margin: 0;
}
table {
width: 100%;
border-collapse: collapse;
}
tr {
border-bottom: 1px dashed #555;
}
tbody tr:hover {
background-color: #30303A;
}
th,
td {
text-align: left;
padding: 10px 0;
}
th {
padding-top: 15px;
padding-bottom: 15px;
font-size: 16px;
white-space: nowrap;
}
th a {
color: white;
}
td {
white-space: nowrap;
font-size: 14px;
}
@media (max-width: 600px) {
.hideable {
display: none;
}
td:nth-child(2) {
width: auto;
}
th:nth-child(3),
td:nth-child(3) {
padding-right: 5%;
text-align: right;
}
h1 {
color: #000;
}
h1 a {
margin: 0;
}
#filter {
max-width: 100px;
}
}

89
template.html Normal file
View file

@ -0,0 +1,89 @@
<!DOCTYPE html>
{{/*
This template is based on the file provided at
https://github.com/caddyserver/caddy/blob/master/modules/caddyhttp/fileserver/browse.html
*/}}
<html lang="en">
<head>
<title>{{html .Name}}</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/style.css" rel="stylesheet">
</head>
<body>
{{if (not .Req.URL.Query.embed)}}
<header>
<h1>
{{range $i, $crumb := .Breadcrumbs}}<a href="{{html $crumb.Link}}">{{html $crumb.Text}}</a>{{if ne $i 0}}/{{end}}{{end}}
</h1>
</header>
{{end}}
<main>
<div class="listing">
<table>
<thead>
<th>
{{- if and (eq .Sort "name") (ne .Order "desc")}}
<a href="?sort=name&order=desc{{if ne 0 .Limit}}&limit={{.Limit}}{{end}}{{if ne 0 .Offset}}&offset={{.Offset}}{{end}}">Name</a>
{{- else if and (eq .Sort "name") (ne .Order "asc")}}
<a href="?sort=name&order=asc{{if ne 0 .Limit}}&limit={{.Limit}}{{end}}{{if ne 0 .Offset}}&offset={{.Offset}}{{end}}">Name</a>
{{- else}}
<a href="?sort=name&order=asc{{if ne 0 .Limit}}&limit={{.Limit}}{{end}}{{if ne 0 .Offset}}&offset={{.Offset}}{{end}}">Name </a>
{{- end}}
</th>
<th>
{{- if and (eq .Sort "size") (ne .Order "desc")}}
<a href="?sort=size&order=desc{{if ne 0 .Limit}}&limit={{.Limit}}{{end}}{{if ne 0 .Offset}}&offset={{.Offset}}{{end}}">Size</a>
{{- else if and (eq .Sort "size") (ne .Order "asc")}}
<a href="?sort=size&order=asc{{if ne 0 .Limit}}&limit={{.Limit}}{{end}}{{if ne 0 .Offset}}&offset={{.Offset}}{{end}}">Size</a>
{{- else}}
<a href="?sort=size&order=asc{{if ne 0 .Limit}}&limit={{.Limit}}{{end}}{{if ne 0 .Offset}}&offset={{.Offset}}{{end}}">Size</a>
{{- end}}
</th>
<th class="hideable">
{{- if and (eq .Sort "time") (ne .Order "desc")}}
<a href="?sort=time&order=desc{{if ne 0 .Limit}}&limit={{.Limit}}{{end}}{{if ne 0 .Offset}}&offset={{.Offset}}{{end}}">Modified</a>
{{- else if and (eq .Sort "time") (ne .Order "asc")}}
<a href="?sort=time&order=asc{{if ne 0 .Limit}}&limit={{.Limit}}{{end}}{{if ne 0 .Offset}}&offset={{.Offset}}{{end}}">Modified</a>
{{- else}}
<a href="?sort=time&order=asc{{if ne 0 .Limit}}&limit={{.Limit}}{{end}}{{if ne 0 .Offset}}&offset={{.Offset}}{{end}}">Modified</a>
{{- end}}
</th>
</thead>
<tbody>
{{- if .CanGoUp}}
<td><a href="..">..</a></td>
<td>&mdash;</td>
<td class="hideable">&mdash;</td>
</tr>
{{- end}}
{{- range .Items}}
<tr class="file">
<td>
<a href="{{html .URL}}" target="_top">
<span class="name">{{html .Name}}</span>
</a>
</td>
{{- if .IsDir}}
<td data-order="-1">&mdash;</td>
{{- else}}
<td data-order="{{.Size}}">{{.HumanSize}}</td>
{{- end}}
<td class="hideable"><time datetime="{{.HumanModTime "2006-01-02T15:04:05Z"}}">{{.HumanModTime "01/02/2006 03:04:05 PM -07:00"}}</time></td>
</tr>
{{- end}}
</tbody>
</table>
</div>
{{if (not .Req.URL.Query.embed)}}
{{ $readmeFilePath := list (placeholder "http.request.uri.path") "README" | join ""}}
{{if (fileExists $readmeFilePath )}}
<div class="readmeFile">
<div class="readmeHeader">README</div>
{{markdown (include $readmeFilePath)}}
</div>
{{end}}
{{end}}
</main>
</body>
</html>