package main import ( "html/template" "net/http" "riedstra.dev/mitch/steam-export/steam" ) var ( Templ = template.Must(template.New("index").Parse(` Steam Game index {{ if .Local }}

Library: {{.Lib.Folder}}


About

The steam exporter is designed to let you export your steam games, either to another local hard drive or another computer on the network.

It also allows you to import games from across the network as well if you provide an HTTP url from which to download the game file as exported from this application.

You can download this application from this UI as well here.

You can give people this link to view the library remotely and download games from your computer:

http://{{.HostIP}}:{{.Port}}/

{{ else }}

Remote Steam library access

If you need this program to install the games click here.

Right click and copy the link address to paste into your local machine if you do not wish to store the archive or have enough space for it on your drive.

{{ end }}

Installed games: Tip: You can right click and save link as to specify a save location, e.g. an external hard drive

{{ if .Local }} 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
{{ end }}

Version information

{{.Version}}
`)) ) func index(w http.ResponseWriter, r *http.Request) { // During rendering of the template I believe it's // mutating during the sort of keys, so Lib no longer // is an RWMutex and we're just locking this as if // we're writing to it Lib.Lock() defer Lib.Unlock() status.Lock() defer status.Unlock() err := Templ.ExecuteTemplate(w, "index", struct { Lib *steam.Library Info *statusInfo Local bool HostIP string Port string Version string }{ &Lib.Library, status, isLocal(r.RemoteAddr), getHostIP(), getPort(), Version, }) if err != nil { Logger.Printf("While Rendering template: %s", err) } Logger.Printf("Client %s Index page", r.RemoteAddr) }