mirror of
https://github.com/vbatts/imgsrv.git
synced 2024-12-24 23:06:31 +00:00
layout: humanize some values
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
f768d2f9f6
commit
b3f5e06c4d
2 changed files with 10 additions and 4 deletions
12
layouts.go
12
layouts.go
|
@ -5,6 +5,7 @@ import (
|
|||
"io"
|
||||
"text/template"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/vbatts/imgsrv/types"
|
||||
)
|
||||
|
||||
|
@ -234,7 +235,12 @@ var fileViewTemplateHTML = `
|
|||
{{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 = `
|
||||
{{if .}}
|
||||
<br/>
|
||||
|
@ -242,9 +248,9 @@ var fileViewInfoTemplateHTML = `
|
|||
<br/>
|
||||
[md5: <a href="/md5/{{.Md5}}">{{.Md5}}</a>]
|
||||
<br/>
|
||||
[size: {{.Length}}]
|
||||
[size: {{humanBytes .Length}}]
|
||||
<br/>
|
||||
[UploadDate: {{.Metadata.TimeStamp}}]
|
||||
[UploadDate: {{.Metadata.TimeStamp}} ({{humanTime .Metadata.TimeStamp}})]
|
||||
<br/>
|
||||
[<a href="/f/{{.Filename}}?delete=true">Delete</a>]
|
||||
{{end}}
|
||||
|
|
|
@ -19,7 +19,7 @@ type File struct {
|
|||
Md5 string
|
||||
ChunkSize int
|
||||
UploadDate time.Time
|
||||
Length int64
|
||||
Length uint64
|
||||
Filename string ",omitempty"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue