Browse Source

Add template func FileSize

tags/v0.9.99
Unknown 10 years ago
parent
commit
8fb4b3afad
2 changed files with 2 additions and 2 deletions
  1. 1
    1
      modules/base/tool.go
  2. 1
    1
      templates/repo/single.tmpl

+ 1
- 1
modules/base/tool.go View File

} }


// 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)
} }

+ 1
- 1
templates/repo/single.tmpl View File

{{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>

Loading…
Cancel
Save