aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-15 12:31:12 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-15 12:31:12 -0400
commit8fb4b3afadaea5a335b0e13a02e44377d8714523 (patch)
tree2b3c7e164e0c79a573121e556da20ac51d61c51f
parent4224ef142e9b7d7f34ae7f24799d62ea787787c5 (diff)
Add template func FileSize
-rw-r--r--modules/base/tool.go2
-rw-r--r--templates/repo/single.tmpl2
2 files changed, 2 insertions, 2 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 8576b941..3f8b8ffa 100644
--- a/modules/base/tool.go
+++ b/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)
}
diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl
index b99950ef..5774c005 100644
--- a/templates/repo/single.tmpl
+++ b/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>