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:
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"
|
"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}}
|
||||||
|
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue