Просмотр исходного кода

Add template func FileSize

tags/v0.9.99
Unknown 10 лет назад
Родитель
Сommit
8fb4b3afad
2 измененных файлов: 2 добавлений и 2 удалений
  1. 1
    1
      modules/base/tool.go
  2. 1
    1
      templates/repo/single.tmpl

+ 1
- 1
modules/base/tool.go Просмотреть файл

@@ -121,7 +121,7 @@ func humanateBytes(s uint64, base float64, sizes []string) 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"}
return humanateBytes(uint64(s), 1024, sizes)
}

+ 1
- 1
templates/repo/single.tmpl Просмотреть файл

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

Загрузка…
Отмена
Сохранить