1
0
Fork 0
mirror of https://github.com/vbatts/imgsrv.git synced 2024-12-25 23:36:30 +00:00

layout: humanize some values

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2017-04-07 14:55:13 -04:00
parent f768d2f9f6
commit b3f5e06c4d
Signed by: vbatts
GPG key ID: 10937E57733F1362
2 changed files with 10 additions and 4 deletions

View file

@ -5,6 +5,7 @@ import (
"io" "io"
"text/template" "text/template"
humanize "github.com/dustin/go-humanize"
"github.com/vbatts/imgsrv/types" "github.com/vbatts/imgsrv/types"
) )
@ -234,7 +235,12 @@ var fileViewTemplateHTML = `
{{end}} {{end}}
` `
var fileViewInfoTemplate = template.Must(template.New("file").Parse(fileViewInfoTemplateHTML)) var funcs = template.FuncMap{
"humanBytes": humanize.Bytes,
"humanTime": humanize.Time,
}
var fileViewInfoTemplate = template.Must(template.New("file").Funcs(funcs).Parse(fileViewInfoTemplateHTML))
var fileViewInfoTemplateHTML = ` var fileViewInfoTemplateHTML = `
{{if .}} {{if .}}
<br/> <br/>
@ -242,9 +248,9 @@ var fileViewInfoTemplateHTML = `
<br/> <br/>
[md5: <a href="/md5/{{.Md5}}">{{.Md5}}</a>] [md5: <a href="/md5/{{.Md5}}">{{.Md5}}</a>]
<br/> <br/>
[size: {{.Length}}] [size: {{humanBytes .Length}}]
<br/> <br/>
[UploadDate: {{.Metadata.TimeStamp}}] [UploadDate: {{.Metadata.TimeStamp}} ({{humanTime .Metadata.TimeStamp}})]
<br/> <br/>
[<a href="/f/{{.Filename}}?delete=true">Delete</a>] [<a href="/f/{{.Filename}}?delete=true">Delete</a>]
{{end}} {{end}}

View file

@ -19,7 +19,7 @@ type File struct {
Md5 string Md5 string
ChunkSize int ChunkSize int
UploadDate time.Time UploadDate time.Time
Length int64 Length uint64
Filename string ",omitempty" Filename string ",omitempty"
} }