diff options
| author | davy <davy.wybiral@gmail.com> | 2019-06-28 20:44:56 -0500 |
|---|---|---|
| committer | davy <davy.wybiral@gmail.com> | 2019-06-28 20:44:56 -0500 |
| commit | ff0b322a332b6c20502faf564292f77001fdb965 (patch) | |
| tree | 4b9b603f8ac066e4249d1e9085f565aa626051b1 | |
| parent | 6e9f1ca8ab34914bcc2327e7d4fab99e6ff6e73c (diff) | |
prefix paths
| -rw-r--r-- | pkg/app/app.go | 6 | ||||
| -rw-r--r-- | templates/index.html | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go index 61d93c2..665b602 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -43,7 +43,7 @@ func NewApp(cfg *Config) (*App, error) { r.HandleFunc("/", a.indexHandler).Methods("GET") r.HandleFunc("/v/{id}.mp4", a.videoHandler).Methods("GET") r.HandleFunc("/t/{id}", a.thumbHandler).Methods("GET") - r.HandleFunc("/{id}", a.pageHandler).Methods("GET") + r.HandleFunc("/v/{id}", a.pageHandler).Methods("GET") fsHandler := http.StripPrefix( "/static/", http.FileServer(http.Dir("./static/")), @@ -89,7 +89,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, "/"+pl[0].ID, 302) + http.Redirect(w, r, "/v/"+pl[0].ID, 302) } else { a.Templates.ExecuteTemplate(w, "index.html", &struct { Playing *media.Video @@ -104,7 +104,7 @@ func (a *App) indexHandler(w http.ResponseWriter, r *http.Request) { func (a *App) pageHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id := vars["id"] - log.Printf("/%s", id) + log.Printf("/v/%s", id) playing, ok := a.Library.Videos[id] if !ok { a.Templates.ExecuteTemplate(w, "index.html", &struct { diff --git a/templates/index.html b/templates/index.html index a63d4e9..ab91c8a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -23,9 +23,9 @@ <div id="sidebar">
{{ range $m := .Playlist }}
{{ if eq $m.ID $playing.ID }}
- <a href="/{{ $m.ID }}" class="playing">
+ <a href="/v/{{ $m.ID }}" class="playing">
{{ else }}
- <a href="/{{ $m.ID }}">
+ <a href="/v/{{ $m.ID }}">
{{ end }}
<img src="/t/{{ $m.ID }}">
<div>
|
