diff options
Diffstat (limited to 'cmd/web/index.go')
| -rw-r--r-- | cmd/web/index.go | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/cmd/web/index.go b/cmd/web/index.go index 1a2c344..2dfe20e 100644 --- a/cmd/web/index.go +++ b/cmd/web/index.go @@ -1,8 +1,10 @@ package main import ( - "net/http" "html/template" + "net/http" + + "riedstra.dev/mitch/steam-export/steam" ) var ( @@ -23,33 +25,71 @@ var ( </div> </nav> -<h2>Library: {{.Folder}}</h2> +<h2>Library: {{.Lib.Folder}}</h2> + +{{ if .Info.Running }} +<pre><code> +Currently Downloading from: {{.Info.Url}} +</pre></code> +{{ end }} + +{{ if .Info.Error }} +<pre><code> +Error {{.Info.Error}} Downloading from: {{.Info.Url}} +{{ end }} +</pre></code> <p> Installed games: + +Tip: You can right click and save link as to specify a save location, e.g. +an external hard drive </p> <ul> -{{ range $key, $val := .Games }} +{{ range $key, $val := .Lib.Games }} <li> <a href="/download/{{$key}}">{{$key}}</a> </li> {{ end }} </ul> -Install a game from a URL: +Delete a game: ( Type out exact name, case sensitive ) + +<form action="/delete" method="POST"> + <input type="text" name="name" /> + <input type="submit" value="Delete"> +</form> + +Install a game from a URL or local file path: <form action="/install" method="GET"> - <input type="text" name="url" /> + <input type="text" name="uri" /> <input type="submit" value="Install"> </form> +<p> +Note that You can also give someone a URL to install a game if they're running +this program, e.g. <br /> +http://127.0.0.1:8899/install?uri=http://my-server-ip-or-hostname/download/My Game +</p> + + </body> `)) ) func index(w http.ResponseWriter, r *http.Request) { - err := Templ.ExecuteTemplate(w, "index", Lib) + 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) } |
