package main
import (
"html/template"
"net/http"
"riedstra.dev/mitch/steam-export/steam"
)
var (
Templ = template.Must(template.New("index").Parse(`
Steam Game index
Home
Library: {{.Lib.Folder}}
{{ if .Info.Running }}
Currently Downloading from: {{.Info.Url}}
{{ end }}
{{ if .Info.Error }}
Error {{.Info.Error}} Downloading from: {{.Info.Url}}
{{ end }}
Installed games:
Tip: You can right click and save link as to specify a save location, e.g.
an external hard drive
{{ range $key, $val := .Lib.Games }}
{{$key}}
{{ end }}
Delete a game: ( Type out exact name, case sensitive )
Install a game from a URL or local file path:
Note that You can also give someone a URL to install a game if they're running
this program, e.g.
http://127.0.0.1:8899/install?uri=http://my-server-ip-or-hostname/download/My Game
Change library path
`))
)
func index(w http.ResponseWriter, r *http.Request) {
libMu.RLock()
defer libMu.RUnlock()
status.m.RLock()
defer status.m.RUnlock()
err := Templ.ExecuteTemplate(w, "index",
struct {
Lib *steam.Library
Info *statusInfo
}{Lib, status.s})
if err != nil {
Logger.Printf("While Rendering template: %s", err)
}
Logger.Printf("Client %s Index page", r.RemoteAddr)
}