aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/index.go
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2020-11-21 15:33:57 -0500
committerMitch Riedstra <mitch@riedstra.us>2020-11-21 15:33:57 -0500
commit36dc9ff10971cf97eb077907072c519cb5349fe4 (patch)
treefaf3ff607714ee8b155c801b91a04e2cc8cb2279 /cmd/web/index.go
parent4ed57528379c9d1ac0f5bc77b95439bbba3d4488 (diff)
downloadsteam-export-36dc9ff10971cf97eb077907072c519cb5349fe4.tar.gz
steam-export-36dc9ff10971cf97eb077907072c519cb5349fe4.tar.xz
Most of the functionality I want is there now, it's not pretty though.
Build the web server and the command line in the build script Allow for deletion of games from the library Move the download function out of main.go Add more information to the index template and handler. Allow for downloads from URLs and installation from local files. Allow changing of the library path via a command line flag Automatically start the web browser on windows
Diffstat (limited to 'cmd/web/index.go')
-rw-r--r--cmd/web/index.go52
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)
}