diff options
| author | James Mills <prologic@shortcircuit.net.au> | 2020-03-27 18:16:23 +1000 |
|---|---|---|
| committer | James Mills <prologic@shortcircuit.net.au> | 2020-03-27 18:16:23 +1000 |
| commit | 89d7d71cc5b443dc392ca9aa4368362467a7d70a (patch) | |
| tree | 0a9a3228ff46d1cb9f6c8cf975a2ec8df6b7e621 /app/app.go | |
| parent | 10a5f824984713433536bd2e3371527281d9956a (diff) | |
Display video size
Diffstat (limited to 'app/app.go')
| -rw-r--r-- | app/app.go | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -15,6 +15,7 @@ import ( "strings" rice "github.com/GeertJohan/go.rice" + "github.com/dustin/go-humanize" "github.com/fsnotify/fsnotify" "github.com/gorilla/handlers" "github.com/gorilla/mux" @@ -74,17 +75,21 @@ func NewApp(cfg *Config) (*App, error) { a.Templates = newTemplateStore("base") - indexTemplate := template.New("index") + templateFuncs := map[string]interface{}{ + "bytes": func(size int64) string { return humanize.Bytes(uint64(size)) }, + } + + indexTemplate := template.New("index").Funcs(templateFuncs) template.Must(indexTemplate.Parse(box.MustString("index.html"))) template.Must(indexTemplate.Parse(box.MustString("base.html"))) a.Templates.Add("index", indexTemplate) - uploadTemplate := template.New("upload") + uploadTemplate := template.New("upload").Funcs(templateFuncs) template.Must(uploadTemplate.Parse(box.MustString("upload.html"))) template.Must(uploadTemplate.Parse(box.MustString("base.html"))) a.Templates.Add("upload", uploadTemplate) - importTemplate := template.New("import") + importTemplate := template.New("import").Funcs(templateFuncs) template.Must(importTemplate.Parse(box.MustString("import.html"))) template.Must(importTemplate.Parse(box.MustString("base.html"))) a.Templates.Add("import", importTemplate) |
