Last active
July 21, 2023 11:44
-
-
Save Flygsand/ffa8df9bb241cb520dbcd57e9359f6cf to your computer and use it in GitHub Desktop.
Apache-style index for Caddy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{- define "icon" -}} | |
{{- if .IsDir -}} | |
<img src="data:image/gif;base64,R0lGODlhFAAWAMIAAP/////Mmcz//5lmMzMzMwAAAAAAAAAAACH+TlRoaXMgYXJ0IGlzIGluIHRoZSBwdWJsaWMgZG9tYWluLiBLZXZpbiBIdWdoZXMsIGtldmluaEBlaXQuY29tLCBTZXB0ZW1iZXIgMTk5NQAh+QQBAAACACwAAAAAFAAWAAADVCi63P4wyklZufjOErrvRcR9ZKYpxUB6aokGQyzHKxyO9RoTV54PPJyPBewNSUXhcWc8soJOIjTaSVJhVphWxd3CeILUbDwmgMPmtHrNIyxM8Iw7AQA7" alt="[DIR]"> | |
{{- else if or (hasSuffix ".jpg" .Name) (hasSuffix ".jpeg" .Name) (hasSuffix ".png" .Name) (hasSuffix ".gif" .Name) (hasSuffix ".webp" .Name) (hasSuffix ".tiff" .Name) (hasSuffix ".bmp" .Name) (hasSuffix ".heif" .Name) (hasSuffix ".heic" .Name) -}} | |
<img src="data:image/gif;base64,R0lGODlhFAAWAOMAAP////8zM8z//8zMzJmZmWZmZmYAADMzMwCZzACZMwAzZgAAAAAAAAAAAAAAAAAAACH+TlRoaXMgYXJ0IGlzIGluIHRoZSBwdWJsaWMgZG9tYWluLiBLZXZpbiBIdWdoZXMsIGtldmluaEBlaXQuY29tLCBTZXB0ZW1iZXIgMTk5NQAh+QQBAAACACwAAAAAFAAWAAAEkPDISae4WBzAu99Hdm1eSYYZWXYqOgJBLAcDoNrYNssGsBy/4GsX6y2OyMWQ2OMQngSlBjZLWBM1AFSqkyU4A2tWywUMYt/wlTSIvgYGA/Zq3QwU7mmHvh4g8GUsfAUHCH95NwMHV4SGh4EdihOOjy8rZpSVeiV+mYCWHncKo6Sfm5cliAdQrK1PQBlJsrNSEQA7" alt="[IMG]"> | |
{{- else if or (hasSuffix ".mp4" .Name) (hasSuffix ".mov" .Name) (hasSuffix ".mpeg" .Name) (hasSuffix ".mpg" .Name) (hasSuffix ".avi" .Name) (hasSuffix ".ogg" .Name) (hasSuffix ".webm" .Name) (hasSuffix ".mkv" .Name) (hasSuffix ".vob" .Name) (hasSuffix ".gifv" .Name) (hasSuffix ".3gp" .Name) -}} | |
<img src="data:image/gif;base64,R0lGODlhFAAWAMIAAP///8z//8zMzJmZmWZmZjMzMwAAAAAAACH+TlRoaXMgYXJ0IGlzIGluIHRoZSBwdWJsaWMgZG9tYWluLiBLZXZpbiBIdWdoZXMsIGtldmluaEBlaXQuY29tLCBTZXB0ZW1iZXIgMTk5NQAh+QQBAAABACwAAAAAFAAWAAADZmi63BrQCOHaNCVewjsHEpUFDDGc6AAuY2iY6Qle7RbLbrvA8arUFF5qJtIEb6pcZAFoOp0MYIVBM748HSJmqRCifFuS7aaVenFV0g4JNrOV4iMZznjao9apIu3SwwMFgYKDhIEQCQA7" alt="[VID]"> | |
{{- else if or (hasSuffix ".mp3" .Name) (hasSuffix ".m4a" .Name) (hasSuffix ".aac" .Name) (hasSuffix ".ogg" .Name) (hasSuffix ".flac" .Name) (hasSuffix ".wav" .Name) (hasSuffix ".wma" .Name) (hasSuffix ".midi" .Name) (hasSuffix ".cda" .Name) -}} | |
<img src="data:image/gif;base64,R0lGODlhFAAWAMIAAP///8z//8zMzJmZmWZmZjMzMwAAAAAAACH+TlRoaXMgYXJ0IGlzIGluIHRoZSBwdWJsaWMgZG9tYWluLiBLZXZpbiBIdWdoZXMsIGtldmluaEBlaXQuY29tLCBTZXB0ZW1iZXIgMTk5NQAh+QQBAAABACwAAAAAFAAWAAADUBi63P7OSPikLXRZQySmGyF6UCgKV8mdm/FFHHqRVVvcNOzdSt7sr4CPMRS6VC8bsmcADIrMT/M5VBo3QYkzh81ufTce0Zph7sqMcBDNXiQAADs=" alt="[SND]"> | |
{{- else if hasSuffix ".pdf" .Name -}} | |
<img src="data:image/gif;base64,R0lGODlhFAAWAOMAAP/////MM/8zM8z//5mZmZlmM2bM/zMzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH+TlRoaXMgYXJ0IGlzIGluIHRoZSBwdWJsaWMgZG9tYWluLiBLZXZpbiBIdWdoZXMsIGtldmluaEBlaXQuY29tLCBTZXB0ZW1iZXIgMTk5NQAh+QQBAAADACwAAAAAFAAWAAAEb/DISee4eBzAu99Hdm1eSYbZWXEkgI5sEBg0+2HnTBsccvhAmGtXAyCOSITwUGg2PYQoQalhOZ/QKLVV6gKmQm8XXDUmzx0yV5ze9s7JdpgtL3ME5jhHTS/xO3hwdWt0f317WwdSi4xRPxlwkUgXEQA7" alt="[ ]"> | |
{{- else if or (hasSuffix ".txt" .Name) (hasSuffix ".doc" .Name) (hasSuffix ".docx" .Name) (hasSuffix ".odt" .Name) (hasSuffix ".fodt" .Name) (hasSuffix ".rtf" .Name) -}} | |
<img src="data:image/gif;base64,R0lGODlhFAAWAMIAAP///8z//5mZmTMzMwAAAAAAAAAAAAAAACH+TlRoaXMgYXJ0IGlzIGluIHRoZSBwdWJsaWMgZG9tYWluLiBLZXZpbiBIdWdoZXMsIGtldmluaEBlaXQuY29tLCBTZXB0ZW1iZXIgMTk5NQAh+QQBAAABACwAAAAAFAAWAAADWDi6vPEwDECrnSO+aTvPEddVIriN1wVxROtSxBDPJwq7bo23luALhJqt8gtKbrsXBSgcEo2spBLAPDp7UKT02bxWRdrp94rtbpdZMrrr/A5+8LhPFpHajQkAOw==" alt="[TXT]"> | |
{{- else if or (hasSuffix ".zip" .Name) (hasSuffix ".gz" .Name) (hasSuffix ".xz" .Name) (hasSuffix ".tar" .Name) (hasSuffix ".7z" .Name) (hasSuffix ".rar" .Name) (hasSuffix ".xz" .Name) (hasSuffix ".zst" .Name) -}} | |
<img src="data:image/gif;base64,R0lGODlhFAAWAOcAAP//////zP//mf//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9tYWluLiBLZXZpbiBIdWdoZXMsIGtldmluaEBlaXQuY29tLCBTZXB0ZW1iZXIgMTk5NQAh+QQBAAAkACwAAAAAFAAWAAAImQBJCCTBqmDBgQgTDmQFAABDVgojEmzI0KHEhBUrWrwoMGNDihwnAvjHiqRJjhX/qVz5D+VHAFZiWmmZ8BGHji9hxqTJ4ZFAmzc1vpxJgkPPn0Y5CP04M6lPEkCN5mxoJelRqFY5TM36NGrPqV67Op0KM6rYnkup/gMq1mdamC1tdn36lijUpwjr0pSoFyUrmTJLhiTBkqXCgAA7" alt="[ ]"> | |
{{- else -}} | |
<img src="data:image/gif;base64,R0lGODlhFAAWAMIAAP///8z//5mZmTMzMwAAAAAAAAAAAAAAACH+TlRoaXMgYXJ0IGlzIGluIHRoZSBwdWJsaWMgZG9tYWluLiBLZXZpbiBIdWdoZXMsIGtldmluaEBlaXQuY29tLCBTZXB0ZW1iZXIgMTk5NQAh+QQBAAABACwAAAAAFAAWAAADaDi6vPEwDECrnSO+aTvPEQcIAmGaIrhR5XmKgMq1LkoMN7ECrjDWp52r0iPpJJ0KjUAq7SxLE+sI+9V8vycFiM0iLb2O80s8JcfVJJTaGYrZYPNby5Ov6WolPD+XDJqAgSQ4EUCGQQEJADs=" alt="[ ]"> | |
{{- end -}} | |
{{- end -}} | |
{{- define "order" -}} | |
{{- if eq "asc" . }}desc{{ else }}asc{{ end -}} | |
{{- end -}} | |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> | |
<html> | |
<head> | |
<title>Index of {{html .Path}}</title> | |
</head> | |
<body> | |
<h1>Index of {{html .Path}}</h1> | |
<table> | |
<tr><th valign="top"><img src="data:image/gif;base64,R0lGODlhFAAWAKEAAP///8z//wAAAAAAACH+TlRoaXMgYXJ0IGlzIGluIHRoZSBwdWJsaWMgZG9tYWluLiBLZXZpbiBIdWdoZXMsIGtldmluaEBlaXQuY29tLCBTZXB0ZW1iZXIgMTk5NQAh+QQBAAABACwAAAAAFAAWAAACE4yPqcvtD6OctNqLs968+w+GSQEAOw==" alt="[ICO]"></th><th><a href="?sort=namedirfirst&order={{template "order" .Order}}">Name</a></th><th><a href="?sort=time&order={{template "order" .Order}}">Last modified</a></th><th><a href="?sort=size&order={{template "order" .Order}}">Size</a></th><th><a href="">Description</a></th></tr> | |
<tr><th colspan="5"><hr></th></tr> | |
{{- if .CanGoUp -}} | |
<tr><td valign="top"><img src="data:image/gif;base64,R0lGODlhFAAWAMIAAP///8z//5mZmWZmZjMzMwAAAAAAAAAAACH+TlRoaXMgYXJ0IGlzIGluIHRoZSBwdWJsaWMgZG9tYWluLiBLZXZpbiBIdWdoZXMsIGtldmluaEBlaXQuY29tLCBTZXB0ZW1iZXIgMTk5NQAh+QQBAAABACwAAAAAFAAWAAADSxi63P4jEPJqEDNTu6LO3PVpnDdOFnaCkHQGBTcqRRxuWG0v+5LrNUZQ8QPqeMakkaZsFihOpyDajMCoOoJAGNVWkt7QVfzokc+LBAA7" alt="[PARENTDIR]"></td><td><a href="..">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> | |
{{- end -}} | |
{{- range .Items}} | |
<tr><td valign="top">{{template "icon" .}}</td><td><a href="{{html .URL}}">{{html .Name}}</a> </td><td align="right">{{html (.HumanModTime "2006-01-02 15:04:05")}} </td><td align="right"> {{.HumanSize}}</td><td> </td></tr> | |
{{- end}} | |
<tr><th colspan="5"><hr></th></tr> | |
</table> | |
<address>Caddy Server at {{html .Host}}</address> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment