1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-21 12:44:49 -05:00

Add template func FileSize

This commit is contained in:
Unknown 2014-03-15 12:31:12 -04:00
parent 4224ef142e
commit 8fb4b3afad
2 changed files with 2 additions and 2 deletions

View file

@ -121,7 +121,7 @@ func humanateBytes(s uint64, base float64, sizes []string) string {
} }
// FileSize calculates the file size and generate user-friendly string. // FileSize calculates the file size and generate user-friendly string.
func FileSize(s uint64) string { func FileSize(s int64) string {
sizes := []string{"B", "KB", "MB", "GB", "TB", "PB", "EB"} sizes := []string{"B", "KB", "MB", "GB", "TB", "PB", "EB"}
return humanateBytes(uint64(s), 1024, sizes) return humanateBytes(uint64(s), 1024, sizes)
} }

View file

@ -47,7 +47,7 @@
{{if .IsDir}} {{if .IsDir}}
<a href="/{{$username}}/{{$reponame}}/tree/{{$branchname}}/{{.Path}}">{{.Name}}</a> <a href="/{{$username}}/{{$reponame}}/tree/{{$branchname}}/{{.Path}}">{{.Name}}</a>
{{else}} {{else}}
<a href="#">{{.Name}} - {{.Size}}</a> <a href="#">{{.Name}} - {{FileSize .Size}}</a>
{{end}}</td> {{end}}</td>
<td class="date"><time datetime="{{.Created}}" data-title="true" title="{{.Created}}">{{TimeSince .Created}}</time></td> <td class="date"><time datetime="{{.Created}}" data-title="true" title="{{.Created}}">{{TimeSince .Created}}</time></td>
<td class="text">{{.Message}}</td> <td class="text">{{.Message}}</td>