prefix paths
This commit is contained in:
parent
6e9f1ca8ab
commit
ff0b322a33
2 changed files with 5 additions and 5 deletions
|
@ -43,7 +43,7 @@ func NewApp(cfg *Config) (*App, error) {
|
||||||
r.HandleFunc("/", a.indexHandler).Methods("GET")
|
r.HandleFunc("/", a.indexHandler).Methods("GET")
|
||||||
r.HandleFunc("/v/{id}.mp4", a.videoHandler).Methods("GET")
|
r.HandleFunc("/v/{id}.mp4", a.videoHandler).Methods("GET")
|
||||||
r.HandleFunc("/t/{id}", a.thumbHandler).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(
|
fsHandler := http.StripPrefix(
|
||||||
"/static/",
|
"/static/",
|
||||||
http.FileServer(http.Dir("./static/")),
|
http.FileServer(http.Dir("./static/")),
|
||||||
|
@ -89,7 +89,7 @@ func (a *App) indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("/")
|
log.Printf("/")
|
||||||
pl := a.Library.Playlist()
|
pl := a.Library.Playlist()
|
||||||
if len(pl) > 0 {
|
if len(pl) > 0 {
|
||||||
http.Redirect(w, r, "/"+pl[0].ID, 302)
|
http.Redirect(w, r, "/v/"+pl[0].ID, 302)
|
||||||
} else {
|
} else {
|
||||||
a.Templates.ExecuteTemplate(w, "index.html", &struct {
|
a.Templates.ExecuteTemplate(w, "index.html", &struct {
|
||||||
Playing *media.Video
|
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) {
|
func (a *App) pageHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
id := vars["id"]
|
id := vars["id"]
|
||||||
log.Printf("/%s", id)
|
log.Printf("/v/%s", id)
|
||||||
playing, ok := a.Library.Videos[id]
|
playing, ok := a.Library.Videos[id]
|
||||||
if !ok {
|
if !ok {
|
||||||
a.Templates.ExecuteTemplate(w, "index.html", &struct {
|
a.Templates.ExecuteTemplate(w, "index.html", &struct {
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
{{ range $m := .Playlist }}
|
{{ range $m := .Playlist }}
|
||||||
{{ if eq $m.ID $playing.ID }}
|
{{ if eq $m.ID $playing.ID }}
|
||||||
<a href="/{{ $m.ID }}" class="playing">
|
<a href="/v/{{ $m.ID }}" class="playing">
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<a href="/{{ $m.ID }}">
|
<a href="/v/{{ $m.ID }}">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<img src="/t/{{ $m.ID }}">
|
<img src="/t/{{ $m.ID }}">
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Reference in a new issue