Skip to content

Commit bcfba0b

Browse files
committed
server: Updated the website
Added more information, made it more responsive
1 parent 096d3d4 commit bcfba0b

File tree

6 files changed

+47
-40
lines changed

6 files changed

+47
-40
lines changed

server/assets/css/cover.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ body {
3232

3333
.cover-container {
3434
max-width: 50%;
35-
/*max-width: 42em;*/
35+
@media (max-width: 1500px){
36+
max-width: 60%;
37+
}
38+
@media (max-width: 1020px){
39+
max-width: 80%;
40+
}
3641
}
3742

3843

server/assets/wasm/maze-wars.wasm

0 Bytes
Binary file not shown.

server/new.go

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ func New(ad *ActionDispatcher, s *Store, opt Options) error {
5555
r.HandleFunc("/ws", wsHandler(s)).Methods(http.MethodGet)
5656

5757
// Webpage
58-
r.HandleFunc("/play", playHandler).Methods(http.MethodGet)
59-
r.HandleFunc("/download", downloadHandler).Methods(http.MethodGet)
58+
r.HandleFunc("/play", playHandler(opt.Version)).Methods(http.MethodGet)
59+
r.HandleFunc("/download", downloadHandler(opt.Version)).Methods(http.MethodGet)
6060
r.HandleFunc("/game", gameHandler(opt.Version)).Methods(http.MethodGet)
61-
r.HandleFunc("/docs", docsHandler).Methods(http.MethodGet)
62-
r.HandleFunc("/", homeHandler).Methods(http.MethodGet)
61+
r.HandleFunc("/docs", docsHandler(opt.Version)).Methods(http.MethodGet)
62+
r.HandleFunc("/", homeHandler(opt.Version)).Methods(http.MethodGet)
6363

6464
// Game Endpoints
6565
r.HandleFunc("/users", usersCreateHandler(s)).Methods(http.MethodPost).Headers("Content-Type", "application/json")
@@ -90,22 +90,29 @@ func New(ad *ActionDispatcher, s *Store, opt Options) error {
9090
}
9191

9292
type templateData struct {
93-
Tab string
93+
Tab string
94+
Version string
9495
}
9596

96-
func homeHandler(w http.ResponseWriter, r *http.Request) {
97-
t, _ := templates.Templates["views/home/index.tmpl"]
98-
t.Execute(w, templateData{"home"})
97+
func homeHandler(v string) func(w http.ResponseWriter, r *http.Request) {
98+
return func(w http.ResponseWriter, r *http.Request) {
99+
t, _ := templates.Templates["views/home/index.tmpl"]
100+
t.Execute(w, templateData{Tab: "home", Version: v})
101+
}
99102
}
100103

101-
func playHandler(w http.ResponseWriter, r *http.Request) {
102-
t, _ := templates.Templates["views/game/play.tmpl"]
103-
t.Execute(w, templateData{"game"})
104+
func playHandler(v string) func(w http.ResponseWriter, r *http.Request) {
105+
return func(w http.ResponseWriter, r *http.Request) {
106+
t, _ := templates.Templates["views/game/play.tmpl"]
107+
t.Execute(w, templateData{Tab: "game", Version: v})
108+
}
104109
}
105110

106-
func downloadHandler(w http.ResponseWriter, r *http.Request) {
107-
t, _ := templates.Templates["views/game/download.tmpl"]
108-
t.Execute(w, templateData{"download"})
111+
func downloadHandler(v string) func(w http.ResponseWriter, r *http.Request) {
112+
return func(w http.ResponseWriter, r *http.Request) {
113+
t, _ := templates.Templates["views/game/download.tmpl"]
114+
t.Execute(w, templateData{Tab: "download", Version: v})
115+
}
109116
}
110117

111118
func gameHandler(v string) func(w http.ResponseWriter, r *http.Request) {
@@ -115,9 +122,11 @@ func gameHandler(v string) func(w http.ResponseWriter, r *http.Request) {
115122
}
116123
}
117124

118-
func docsHandler(w http.ResponseWriter, r *http.Request) {
119-
t, _ := templates.Templates["views/docs/index.tmpl"]
120-
t.Execute(w, templateData{"docs"})
125+
func docsHandler(v string) func(w http.ResponseWriter, r *http.Request) {
126+
return func(w http.ResponseWriter, r *http.Request) {
127+
t, _ := templates.Templates["views/docs/index.tmpl"]
128+
t.Execute(w, templateData{Tab: "docs", Version: v})
129+
}
121130
}
122131

123132
type usersCreateRequest struct {

server/templates/views/game/download.tmpl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{{define "content"}}
66
<div class="px-3">
77
<p class ="lead">
8-
Maze Wars is playable in 3 platforms: Windows, OSX and Linux on amd64 architecture
8+
Maze Wars is playable in 3 platforms: Windows, OSX and Linux on amd64 architecture. And also from the Web Browser
99
</p>
1010
</div>
1111
</br>
@@ -20,20 +20,11 @@
2020
<a href="https://github.com/xescugc/maze-wars/releases/latest/download/maze-wars_Linux_x86_64.tar.gz"class="btn btn-lg btn-light fw-bold border-white bg-white" role="button">
2121
<i class="fa fa-lg fa-linux"></i> Linux
2222
</a>
23-
</div>
24-
</div>
25-
</br>
26-
</br>
27-
<div class="px-3">
28-
<p class ="lead">
29-
Optionally you can also play it from the web, <strong>but it's really slow so play it at your own risk hehe</strong>
30-
</p>
31-
</div>
32-
<div class="px-3">
33-
<div class="d-grid gap-2 d-md-flex justify-content-md-center">
3423
<a href="/play"class="btn btn-lg btn-light fw-bold border-white bg-white" role="button">
3524
<i class="fa fa-lg fa-desktop"></i> Web
3625
</a>
3726
</div>
3827
</div>
28+
</br>
29+
</br>
3930
{{ end}}

server/templates/views/game/play.tmpl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
crossorigin="anonymous"
99
></script>
1010
<div class="px-3">
11-
<p class ="lead">
12-
The current web version of this game is really slow. If you want a smooth experience <a href='/download'>download</a> it.
13-
</p>
11+
</br>
12+
</br>
1413
<iframe id="iframe" src="/game" width="850" height="1000" scrolling="no"></iframe>
1514
<center>
1615
<button id="fullscreen" class="btn btn-lg btn-light fw-bold border-white bg-white">Full Screen</a>

server/templates/views/layouts/layout.tmpl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,26 @@
3232
<nav class="nav nav-masthead justify-content-center float-md-end">
3333
<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "home"}}active{{end}}" href="/">Home</a>
3434
<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "download"}}active{{end}}" href="/download">Download</a>
35-
{{ if eq .Tab "game" }}
36-
<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "game"}}active{{end}}" href="/play">Game</a>
37-
{{ end }}
38-
<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "docs"}}active{{end}}" href="/docs">Docs</a>
35+
<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "game"}}active{{end}}" href="/play">Play!</a>
36+
<!--<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "docs"}}active{{end}}" href="/docs">Docs</a>-->
3937
</nav>
4038
</div>
4139
</header>
4240
<main class="px-3">
4341
{{template "content" .}}
4442
</main>
4543
<footer class="mt-auto text-white-50">
46-
<p>Created by <a href="https://twitter.com/xescugc">@xescugc</a>, code can be found in <a href="https://github.com/xescugc/maze-wars">GitHub</a></p>
47-
<p>Join our <a href="https://discord.gg/xXcpD3Fjt9">Discord</a>, <a href="https://www.reddit.com/r/maze_wars/">Reddit</a> or <a href="https://twitter.com/MazeWars">Twitter/X</a></p>
48-
<p>Template from <a href="https://getbootstrap.com/docs/5.3/examples/cover/#">Bootstrap Cover</a>
44+
<p>Created by <a target="_blank" href="https://twitter.com/xescugc">@xescugc</a>, code can be found in <a target="_blank" href="https://github.com/xescugc/maze-wars">GitHub</a></p>
45+
<p>Join our <a target="_blank" href="https://discord.gg/xXcpD3Fjt9">Discord</a> or follow on <a target="_blank" href="https://twitter.com/MazeWars">Twitter/X</a></p>
46+
<p>Template from <a target="_blank" href="https://getbootstrap.com/docs/5.3/examples/cover/#">Bootstrap Cover</a>
4947
</footer>
5048
</div>
5149
<script type = "text/javascript" src="/js/bootstrap.bundle.min.js"></script>
5250
</body>
51+
52+
<div class="text-white-50" style="position: absolute; bottom: 5px; right: 5px;">
53+
Version v{{.Version}}
54+
</div>
55+
5356
</html>
5457
{{end}}

0 commit comments

Comments
 (0)