mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Add template func FileSize
This commit is contained in:
		@@ -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)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user