From 36dc9ff10971cf97eb077907072c519cb5349fe4 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Sat, 21 Nov 2020 15:33:57 -0500 Subject: 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 --- cmd/web/index.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) (limited to 'cmd/web/index.go') 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 ( -

Library: {{.Folder}}

+

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

-Install a game from a URL: +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 +

+ + `)) ) 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) } -- cgit v1.2.3