From fd3f210a36529bdd0d5988052d5fe60ab4fa5682 Mon Sep 17 00:00:00 2001 From: James Mills Date: Fri, 27 Mar 2020 21:50:19 +1000 Subject: [PATCH] Refactor Sort UI --- app/app.go | 3 ++- app/rice-box.go | 8 ++++---- templates/index.html | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/app.go b/app/app.go index bf027e8..fa1fd18 100644 --- a/app/app.go +++ b/app/app.go @@ -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
\r\n {{ if $playing.ID }}\r\n \r\n

{{ $playing.Title }}

\r\n

{{ $playing.Views }} views • {{ $playing.Modified }}
{{ $playing.Size | bytes }}

\r\n

{{ $playing.Description }}

\r\n {{ else }}\r\n \r\n {{ end }}\r\n
\r\n
\r\n
\r\n \r\n
\r\n {{ range $m := .Playlist }}\r\n {{ if eq $m.ID $playing.ID }}\r\n \r\n {{ else }}\r\n \r\n {{ end }}\r\n \r\n
\r\n

{{ $m.Title }}

\r\n

{{ $m.Views }} views • {{ $m.Modified }}
{{ $m.Size | bytes }}

\r\n
\r\n
\r\n {{ end }}\r\n
\r\n{{end}}\r\n"), + Content: string("{{ define \"content\" }}\r\n{{ $playing := .Playing }}\r\n
\r\n {{ if $playing.ID }}\r\n \r\n

{{ $playing.Title }}

\r\n

{{ $playing.Views }} views • {{ $playing.Modified }}
{{ $playing.Size | bytes }}

\r\n

{{ $playing.Description }}

\r\n {{ else }}\r\n \r\n {{ end }}\r\n
\r\n
\r\n
\r\n

{{ $.Sort }}

\r\n \r\n
\r\n {{ range $m := .Playlist }}\r\n {{ if eq $m.ID $playing.ID }}\r\n \r\n {{ else }}\r\n \r\n {{ end }}\r\n \r\n
\r\n

{{ $m.Title }}

\r\n

{{ $m.Views }} views • {{ $m.Modified }}
{{ $m.Size | bytes }}

\r\n
\r\n
\r\n {{ end }}\r\n
\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, }, diff --git a/templates/index.html b/templates/index.html index eeec78d..f953414 100644 --- a/templates/index.html +++ b/templates/index.html @@ -13,8 +13,8 @@
{{ range $m := .Playlist }}