Display video size
This commit is contained in:
parent
10a5f82498
commit
89d7d71cc5
4 changed files with 99 additions and 94 deletions
11
app/app.go
11
app/app.go
|
@ -15,6 +15,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
rice "github.com/GeertJohan/go.rice"
|
rice "github.com/GeertJohan/go.rice"
|
||||||
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
"github.com/gorilla/handlers"
|
"github.com/gorilla/handlers"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
@ -74,17 +75,21 @@ func NewApp(cfg *Config) (*App, error) {
|
||||||
|
|
||||||
a.Templates = newTemplateStore("base")
|
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("index.html")))
|
||||||
template.Must(indexTemplate.Parse(box.MustString("base.html")))
|
template.Must(indexTemplate.Parse(box.MustString("base.html")))
|
||||||
a.Templates.Add("index", indexTemplate)
|
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("upload.html")))
|
||||||
template.Must(uploadTemplate.Parse(box.MustString("base.html")))
|
template.Must(uploadTemplate.Parse(box.MustString("base.html")))
|
||||||
a.Templates.Add("upload", uploadTemplate)
|
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("import.html")))
|
||||||
template.Must(importTemplate.Parse(box.MustString("base.html")))
|
template.Must(importTemplate.Parse(box.MustString("base.html")))
|
||||||
a.Templates.Add("import", importTemplate)
|
a.Templates.Add("import", importTemplate)
|
||||||
|
|
176
app/rice-box.go
176
app/rice-box.go
File diff suppressed because one or more lines are too long
2
go.mod
2
go.mod
|
@ -9,7 +9,7 @@ require (
|
||||||
github.com/dhowden/tag v0.0.0-20190519100835-db0c67e351b1
|
github.com/dhowden/tag v0.0.0-20190519100835-db0c67e351b1
|
||||||
github.com/disintegration/gift v1.2.1 // indirect
|
github.com/disintegration/gift v1.2.1 // indirect
|
||||||
github.com/disintegration/imaging v1.6.2 // indirect
|
github.com/disintegration/imaging v1.6.2 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
github.com/dustin/go-humanize v1.0.0
|
||||||
github.com/fsnotify/fsnotify v1.4.7
|
github.com/fsnotify/fsnotify v1.4.7
|
||||||
github.com/gorilla/feeds v1.1.1
|
github.com/gorilla/feeds v1.1.1
|
||||||
github.com/gorilla/handlers v1.4.2
|
github.com/gorilla/handlers v1.4.2
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{{ if $playing.ID }}
|
{{ if $playing.ID }}
|
||||||
<video id="video" controls poster="/t/{{ $playing.ID}}" src="/v/{{ $playing.ID }}.mp4"></video>
|
<video id="video" controls poster="/t/{{ $playing.ID}}" src="/v/{{ $playing.ID }}.mp4"></video>
|
||||||
<h1>{{ $playing.Title }}</h1>
|
<h1>{{ $playing.Title }}</h1>
|
||||||
<h2>{{ $playing.Views }} views • {{ $playing.Modified }}</h2>
|
<h2>{{ $playing.Views }} views • {{ $playing.Modified }}<br />{{ $playing.Size | bytes }}</h2>
|
||||||
<p>{{ $playing.Description }}</p>
|
<p>{{ $playing.Description }}</p>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<video id="video" controls></video>
|
<video id="video" controls></video>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<img src="/t/{{ $m.ID }}">
|
<img src="/t/{{ $m.ID }}">
|
||||||
<div>
|
<div>
|
||||||
<h1>{{ $m.Title }}</h1>
|
<h1>{{ $m.Title }}</h1>
|
||||||
<h2>{{ $m.Views }} views • {{ $m.Modified }}</h2>
|
<h2>{{ $m.Views }} views • {{ $m.Modified }}<br />{{ $m.Size | bytes }}</h2>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in a new issue