diff options
Diffstat (limited to 'web.go')
| -rw-r--r-- | web.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -7,6 +7,7 @@ import ( "io/ioutil" "log" "net/http" + "time" _ "github.com/lib/pq" ) @@ -49,11 +50,17 @@ func (app *App) root(w http.ResponseWriter, r *http.Request) { } scrobbles := app.RecentScrobbles(se.UserId) + np := app.NowPlaying(se.UserId) + np.Image = "static/np2.gif" + if time.Since(np.Time) > time.Duration(np.Duration)*time.Second { + np = nil + } app.Template.ExecuteTemplate(w, "index.tmpl", struct { - Session *UserSession - Scrobbles []*Scrobble - }{se, scrobbles}) + Session *UserSession + Scrobbles []*Scrobble + NowPlaying *Scrobble + }{se, scrobbles, np}) } func (app *App) callback(w http.ResponseWriter, r *http.Request) { |
