]> source.dussan.org Git - gitea.git/commitdiff
Add template func FileSize
authorUnknown <joe2010xtmf@163.com>
Sat, 15 Mar 2014 16:31:12 +0000 (12:31 -0400)
committerUnknown <joe2010xtmf@163.com>
Sat, 15 Mar 2014 16:31:12 +0000 (12:31 -0400)
modules/base/tool.go
templates/repo/single.tmpl

index 8576b941cc01bd149cc6277782976746f42cf35f..3f8b8ffa8499d840c0b0cc21aff15b46e4cdc3a1 100644 (file)
@@ -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)
 }
index b99950ef51f4281b698b2a57242ae4856784e1cf..5774c0051d52a7ce5c814e0807dceb21c97b54ab 100644 (file)
@@ -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>