Add WebDAV browser

This commit is contained in:
Neale Pickett 2022-12-16 15:02:50 -07:00
parent eb65f8cfe7
commit 59297a1a33
3 changed files with 43 additions and 2 deletions

View File

@ -24,7 +24,7 @@ drive.woozle.org {
route {
file_server @nondav {
root /srv/
browse
browse /browser.html
}
reverse_proxy webdav:8000
}

View File

@ -34,6 +34,8 @@ services:
target: /www/index.mjs
- source: index.css
target: /www/index.css
- source: browser.html
target: /browser.html
extra_hosts:
- host.docker.internal:host-gateway
@ -280,7 +282,7 @@ configs:
name: Corefile-v2
Caddyfile:
file: Caddyfile
name: Caddyfile-v77
name: Caddyfile-v79
index.html:
file: www/index.html
name: index.html-v32
@ -290,6 +292,9 @@ configs:
index.css:
file: www/index.css
name: index.css-v1
browser.html:
file: www/browser.html
name: browser.html-v3
secrets:
passwd:

36
homelab/www/browser.html Normal file
View File

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<title>Woozle Drive</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/dom111/webdav-js/assets/css/style-min.css">
<script>
function init() {
// This is dumb, but webdav-min.js doesn't have any checks to make sure the document is loaded.
let scr = document.head.appendChild(document.createElement("script"))
scr.src = "https://cdn.jsdelivr.net/gh/dom111/webdav-js/src/webdav-min.js"
for (let e of document.querySelectorAll(".listing")) {
console.log("Let's pray the WebDAV stuff works!", e)
e.remove()
}
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", init)
} else {
init()
}
</script>
</head>
<body>
<ul class="listing">
{{range .Items}}
<li>
<a href="{{html .URL}}">{{html .Name}}</a>
<span class="size" data-value="{{.Size}}">{{.HumanSize}}</span>
<time>{{.HumanModTime "2006-01-02T15:04:05Z"}}</time>
</li>
{{end}}
</ul>
</body>
</html>