diff options
| author | James Mills <prologic@shortcircuit.net.au> | 2020-03-25 16:22:41 +1000 |
|---|---|---|
| committer | James Mills <prologic@shortcircuit.net.au> | 2020-03-25 16:22:41 +1000 |
| commit | 9fa34273082e588f8876c4f4d1f658f4b3590e92 (patch) | |
| tree | 3b99fc82d67b857e9dbe747d1bfc330aa21995e9 /app/app.go | |
| parent | 2c8af031648d110148dfe672c4fc3063f1743374 (diff) | |
Add trending and ability to sort playlist by views
Diffstat (limited to 'app/app.go')
| -rw-r--r-- | app/app.go | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -162,7 +162,7 @@ func (a *App) indexHandler(w http.ResponseWriter, r *http.Request) { log.Printf("/") pl := a.Library.Playlist() if len(pl) > 0 { - http.Redirect(w, r, "/v/"+pl[0].ID, 302) + http.Redirect(w, r, fmt.Sprintf("/v/%s?%s", pl[0].ID, r.URL.RawQuery), 302) } else { ctx := &struct { Playing *media.Video @@ -312,6 +312,13 @@ func (a *App) pageHandler(w http.ResponseWriter, r *http.Request) { video.Views = views } + if r.URL.Query().Get("trending") != "" { + log.Info("sorting by trending") + media.By(media.SortByViews).Sort(playlist) + } else { + media.By(media.SortByTimestamp).Sort(playlist) + } + w.Header().Set("Content-Type", "text/html; charset=utf-8") ctx := &struct { Playing *media.Video |
