1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
package main
import (
"html/template"
"net/http"
"riedstra.dev/mitch/steam-export/steam"
)
var (
Templ = template.Must(template.New("index").Parse(`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link id="maincss" rel="stylesheet" href="/style.css" defer>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Steam Game index</title>
</head>
<body>
<nav>
<a href="/">Home</a>
{{ if .Local }}
<div style="display: block; float: right;">
<a href="/quit">Shutdown Server / Quit</a>
</div>
{{ end }}
</nav>
{{ if .Local }}
<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>
<h3>About</h3>
<p>
The steam exporter is designed to let you export your steam games, either to
another local hard drive or another computer on the network.
</p>
<p>
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.
</p>
<p>
<a href="/steam-export-web.exe">
You can download this application from this UI as well here.
</a>
</p>
<p>
You can give people this link to view the library remotely and download
games from your computer:
<br /><br />
<a href="http://{{.HostIP}}:{{.Port}}/">http://{{.HostIP}}:{{.Port}}/</a>
</p>
{{ else }}
<h2>Remote Steam library access</h2>
<a href="/steam-export-web.exe">
If you need this program to install the games click here.
</a>
<p>
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.
</p>
{{ end }}
<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 := .Lib.Games }}
<li>
<a href="/download/{{$key}}">{{$key}} ({{$val.GetSize}})</a>
</li>
{{ end }}
</ul>
{{ if .Local }}
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="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>
Change library path
<form action="/setLib" method="GET">
<input type="text" name="path" />
<input type="submit" value="Update">
</form>
{{ end }}
<h3>Version information</h3>
<pre><code>{{.Version}}</pre></code>
</body>
`))
)
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
Local bool
HostIP string
Port string
Version string
}{
Lib,
status.s,
isLocal(r.RemoteAddr),
getHostIP(),
getPort(),
Version,
})
if err != nil {
Logger.Printf("While Rendering template: %s", err)
}
Logger.Printf("Client %s Index page", r.RemoteAddr)
}
|