diff options
| author | James Mills <prologic@shortcircuit.net.au> | 2020-03-25 23:02:04 +1000 |
|---|---|---|
| committer | James Mills <prologic@shortcircuit.net.au> | 2020-03-25 23:02:14 +1000 |
| commit | bcd79ba2c55de3202f1e9b4b9b6070b36cfdb7db (patch) | |
| tree | 13e63cbea825dcb941ed801d05aa524dcf5684ce /app/app.go | |
| parent | af07f1aaa96184f4ac74762cb9668ad06da0796f (diff) | |
Refactor UX of Trending vs. Recent video sorting
Diffstat (limited to 'app/app.go')
| -rw-r--r-- | app/app.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -12,6 +12,7 @@ import ( "path" "path/filepath" "sort" + "strings" rice "github.com/GeertJohan/go.rice" "github.com/fsnotify/fsnotify" @@ -312,18 +313,24 @@ func (a *App) pageHandler(w http.ResponseWriter, r *http.Request) { video.Views = views } - if r.URL.Query().Get("trending") != "" { - log.Info("sorting by trending") + sort := strings.ToLower(r.URL.Query().Get("sort")) + switch sort { + case "views": media.By(media.SortByViews).Sort(playlist) - } else { + case "timestamp": media.By(media.SortByTimestamp).Sort(playlist) + default: + // By default the playlist is sorted by Timestamp + log.Warnf("invalid sort critiera: %s", sort) } w.Header().Set("Content-Type", "text/html; charset=utf-8") ctx := &struct { + Sort string Playing *media.Video Playlist media.Playlist }{ + Sort: sort, Playing: playing, Playlist: playlist, } |
