frostfs-http-gw/internal/handler/templates/index.gotmpl
Nikita Zinkevich 26b36e442c
All checks were successful
/ DCO (pull_request) Successful in 56s
/ Builds (pull_request) Successful in 54s
/ Vulncheck (pull_request) Successful in 1m20s
/ Lint (pull_request) Successful in 2m11s
/ Tests (pull_request) Successful in 1m4s
[#137] Add index page support
Signed-off-by: Nikita Zinkevich <n.zinkevich@yadro.com>
2024-09-26 11:17:11 +03:00

77 lines
2 KiB
Go Template

{{$bucketName := .BucketName}}
{{ $prefix := trimPrefix .Prefix }}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Index of s3://{{$bucketName}}{{if $prefix}}/{{$prefix}}/{{end}}</title>
<style>
table {
width: 80%;
border-collapse: collapse;
}
body {
background: #f2f2f2;
}
table, th, td {
border: 0 solid transparent;
}
th, td {
padding: 10px;
text-align: left;
}
th {
background-color: #c3bcbc;
}
tr:nth-child(even) {background-color: #ebe7e7;}
</style>
</head>
<body>
<h1>Index of s3://{{$bucketName}}/{{if $prefix}}{{$prefix}}/{{end}}</h1>
<table>
<thead>
<tr>
<th>Filename</th>
<th>Size</th>
<th>Created</th>
<th>Download</th>
</tr>
</thead>
<tbody>
{{if $prefix}}
<tr>
<td><a href="../">../</a></td>
<td></td>
<td></td>
</tr>
{{else}}
<tr>
<td><a href="/get/{{ $bucketName}}/">../</a></td>
<td></td>
<td></td>
</tr>
{{end}}
{{range .Objects}}
{{if .FileName}}
<tr>
<td>
<a href="/get/{{ $bucketName}}/{{ $prefix}}{{if $prefix}}/{{end}}{{ .FileName}}{{if not .Size}}/{{end}}">
{{.FileName}}{{if not .Size}}/{{end}}
</a>
</td>
<td>{{ formatSize .Size }}</td>
<td>{{ formatTimestamp .Created }}</td>
<td>
{{ if .Size }}
<a href="/get/{{ $bucketName}}/{{ $prefix}}{{if $prefix}}/{{end}}{{ .FileName}}?download=true">
Link
</a>
{{ end }}
</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
</body>
</html>