Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Last active May 1, 2017 21:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save peterhellberg/802863eeb577b74b4392 to your computer and use it in GitHub Desktop.
Save peterhellberg/802863eeb577b74b4392 to your computer and use it in GitHub Desktop.
Code7 template used by the Caddy browse directive
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link rel="stylesheet" href="http://c7.se/css/main.css">
<style>
body { font-family: 'Helvetica Neue', Sans-serif; }
#list {
width: 100%;
}
th,td {
border-color: #eee;
padding: 0.2em 0.5em;
}
.path {
margin-top: 0.6em;
margin-bottom: 0.6em;
font-weight: bold;
font-size: 1.3em;
color: #333;
}
</style>
</head>
<body>
<div class="container">
<a href="/"><img src="http://c7.se/images/logo.png" alt="code7 interactive" /></a>
<h1 class="path">{{.Path}}</h1>
<table id="list" cellpadding="0.1em" cellspacing="0">
<thead>
<tr>
<th>File Name</th>
<th>File Size</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr>
<td>
{{if .CanGoUp}}
<a href="..">Parent directory/</a>
{{else}}
Parent directory/
{{end}}
</td>
<td>-</td>
<td>-</td>
</tr>
{{range .Items}}
{{if .IsDir}}
<tr>
<td><a href="{{.URL}}">{{.Name}}/</a></td>
<td>-</td>
<td>{{.HumanModTime "2006-01-02 15:04"}}</td>
</tr>
{{end}}
{{end}}
{{range .Items}}
{{if not .IsDir}}
{{if ne .Name "Caddyfile" }}
<tr>
<td><a href="{{.URL}}">{{.Name}}</a></td>
<td>{{.HumanSize}}</td>
<td>{{.HumanModTime "2006-01-02 15:04"}}</td>
</tr>
{{end}}
{{end}}
{{end}}
</tbody>
</table>
</div>
</body>
</html>
@peterhellberg
Copy link
Author

Code7 template for Caddy browse directive

Note: Directories are listed before files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment