Refactor Sort UI
This commit is contained in:
parent
f4afd2eb6b
commit
fd3f210a36
3 changed files with 8 additions and 7 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(),
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
<div id="playlist">
|
||||
<div class="nav">
|
||||
<ul>
|
||||
<li><a {{ if eq $.Sort "views" }}class="active"{{ end }}href="?sort=views">Trending</a></li>
|
||||
<li><a {{ if eq $.Sort "timestamp" }}class="active"{{ end }}href="?sort=timestamp">Recent</a></li>
|
||||
<li><a {{ if or (eq $.Sort "timestamp") (eq $.Sort "") }}class="active"{{ end }} href="?sort=timestamp">Recent</a></li>
|
||||
<li><a {{ if eq $.Sort "views" }}class="active"{{ end }} href="?sort=views">Views</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{{ range $m := .Playlist }}
|
||||
|
|
Loading…
Reference in a new issue