aboutsummaryrefslogtreecommitdiffstats
path: root/web.go
diff options
context:
space:
mode:
Diffstat (limited to 'web.go')
-rw-r--r--web.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/web.go b/web.go
index 31a8317..371ae9f 100644
--- a/web.go
+++ b/web.go
@@ -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) {