diff options
| author | James Mills <prologic@shortcircuit.net.au> | 2020-03-27 21:50:19 +1000 |
|---|---|---|
| committer | James Mills <prologic@shortcircuit.net.au> | 2020-03-27 21:50:19 +1000 |
| commit | fd3f210a36529bdd0d5988052d5fe60ab4fa5682 (patch) | |
| tree | 2a6927ad796fb4f0b28b55efa29c96f080e7396f /app | |
| parent | f4afd2eb6be4bdf6236c6e410d1c3846f2b6e685 (diff) | |
Refactor Sort UI
Diffstat (limited to 'app')
| -rw-r--r-- | app/app.go | 3 | ||||
| -rw-r--r-- | app/rice-box.go | 8 |
2 files changed, 6 insertions, 5 deletions
@@ -177,12 +177,13 @@ func (a *App) indexHandler(w http.ResponseWriter, r *http.Request) { if len(pl) > 0 { http.Redirect(w, r, fmt.Sprintf("/v/%s?%s", pl[0].ID, r.URL.RawQuery), 302) } else { + sort := strings.ToLower(r.URL.Query().Get("sort")) ctx := &struct { Sort string Playing *media.Video Playlist media.Playlist }{ - Sort: "", + Sort: sort, Playing: &media.Video{ID: ""}, Playlist: a.Library.Playlist(), } diff --git a/app/rice-box.go b/app/rice-box.go index f928536..bafae0b 100644 --- a/app/rice-box.go +++ b/app/rice-box.go @@ -23,9 +23,9 @@ func init() { } file4 := &embedded.EmbeddedFile{ Filename: "index.html", - FileModTime: time.Unix(1585303713, 0), + FileModTime: time.Unix(1585309729, 0), - Content: string("{{ define \"content\" }}\r\n{{ $playing := .Playing }}\r\n<div id=\"player\">\r\n {{ if $playing.ID }}\r\n <video id=\"video\" controls poster=\"/t/{{ $playing.ID}}\" src=\"/v/{{ $playing.ID }}.mp4\"></video>\r\n <h1>{{ $playing.Title }}</h1>\r\n <h2>{{ $playing.Views }} views • {{ $playing.Modified }}<br />{{ $playing.Size | bytes }}</h2>\r\n <p>{{ $playing.Description }}</p>\r\n {{ else }}\r\n <video id=\"video\" controls></video>\r\n {{ end }}\r\n</div>\r\n<div id=\"playlist\">\r\n <div class=\"nav\">\r\n <ul>\r\n <li><a {{ if eq $.Sort \"views\" }}class=\"active\"{{ end }}href=\"?sort=views\">Trending</a></li>\r\n <li><a {{ if eq $.Sort \"timestamp\" }}class=\"active\"{{ end }}href=\"?sort=timestamp\">Recent</a></li>\r\n </ul>\r\n </div>\r\n {{ range $m := .Playlist }}\r\n {{ if eq $m.ID $playing.ID }}\r\n <a href=\"/v/{{ $m.ID }}\" class=\"playing\">\r\n {{ else }}\r\n <a href=\"/v/{{ $m.ID }}\">\r\n {{ end }}\r\n <img src=\"/t/{{ $m.ID }}\">\r\n <div>\r\n <h1>{{ $m.Title }}</h1>\r\n <h2>{{ $m.Views }} views • {{ $m.Modified }}<br />{{ $m.Size | bytes }}</h2>\r\n </div>\r\n </a>\r\n {{ end }}\r\n</div>\r\n{{end}}\r\n"), + Content: string("{{ define \"content\" }}\r\n{{ $playing := .Playing }}\r\n<div id=\"player\">\r\n {{ if $playing.ID }}\r\n <video id=\"video\" controls poster=\"/t/{{ $playing.ID}}\" src=\"/v/{{ $playing.ID }}.mp4\"></video>\r\n <h1>{{ $playing.Title }}</h1>\r\n <h2>{{ $playing.Views }} views • {{ $playing.Modified }}<br />{{ $playing.Size | bytes }}</h2>\r\n <p>{{ $playing.Description }}</p>\r\n {{ else }}\r\n <video id=\"video\" controls></video>\r\n {{ end }}\r\n</div>\r\n<div id=\"playlist\">\r\n <div class=\"nav\">\r\n <p>{{ $.Sort }}</p>\r\n <ul>\r\n <li><a {{ if or (eq $.Sort \"timestamp\") (eq $.Sort \"\") }}class=\"active\"{{ end }} href=\"?sort=timestamp\">Recent</a></li>\r\n <li><a {{ if eq $.Sort \"views\" }}class=\"active\"{{ end }} href=\"?sort=views\">Views</a></li>\r\n </ul>\r\n </div>\r\n {{ range $m := .Playlist }}\r\n {{ if eq $m.ID $playing.ID }}\r\n <a href=\"/v/{{ $m.ID }}\" class=\"playing\">\r\n {{ else }}\r\n <a href=\"/v/{{ $m.ID }}\">\r\n {{ end }}\r\n <img src=\"/t/{{ $m.ID }}\">\r\n <div>\r\n <h1>{{ $m.Title }}</h1>\r\n <h2>{{ $m.Views }} views • {{ $m.Modified }}<br />{{ $m.Size | bytes }}</h2>\r\n </div>\r\n </a>\r\n {{ end }}\r\n</div>\r\n{{end}}\r\n"), } file5 := &embedded.EmbeddedFile{ Filename: "upload.html", @@ -37,7 +37,7 @@ func init() { // define dirs dir1 := &embedded.EmbeddedDir{ Filename: "", - DirModTime: time.Unix(1585307937, 0), + DirModTime: time.Unix(1585309730, 0), ChildFiles: []*embedded.EmbeddedFile{ file2, // "base.html" file3, // "import.html" @@ -53,7 +53,7 @@ func init() { // register embeddedBox embedded.RegisterEmbeddedBox(`../templates`, &embedded.EmbeddedBox{ Name: `../templates`, - Time: time.Unix(1585307937, 0), + Time: time.Unix(1585309730, 0), Dirs: map[string]*embedded.EmbeddedDir{ "": dir1, }, |
