Skip to content

Commit

Permalink
server: Updated the website
Browse files Browse the repository at this point in the history
Added more information, made it more responsive
  • Loading branch information
xescugc committed Jun 13, 2024
1 parent 096d3d4 commit bcfba0b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 40 deletions.
7 changes: 6 additions & 1 deletion server/assets/css/cover.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ body {

.cover-container {
max-width: 50%;
/*max-width: 42em;*/
@media (max-width: 1500px){
max-width: 60%;
}
@media (max-width: 1020px){
max-width: 80%;
}
}


Expand Down
Binary file modified server/assets/wasm/maze-wars.wasm
Binary file not shown.
43 changes: 26 additions & 17 deletions server/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ func New(ad *ActionDispatcher, s *Store, opt Options) error {
r.HandleFunc("/ws", wsHandler(s)).Methods(http.MethodGet)

// Webpage
r.HandleFunc("/play", playHandler).Methods(http.MethodGet)
r.HandleFunc("/download", downloadHandler).Methods(http.MethodGet)
r.HandleFunc("/play", playHandler(opt.Version)).Methods(http.MethodGet)
r.HandleFunc("/download", downloadHandler(opt.Version)).Methods(http.MethodGet)
r.HandleFunc("/game", gameHandler(opt.Version)).Methods(http.MethodGet)
r.HandleFunc("/docs", docsHandler).Methods(http.MethodGet)
r.HandleFunc("/", homeHandler).Methods(http.MethodGet)
r.HandleFunc("/docs", docsHandler(opt.Version)).Methods(http.MethodGet)
r.HandleFunc("/", homeHandler(opt.Version)).Methods(http.MethodGet)

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

type templateData struct {
Tab string
Tab string
Version string
}

func homeHandler(w http.ResponseWriter, r *http.Request) {
t, _ := templates.Templates["views/home/index.tmpl"]
t.Execute(w, templateData{"home"})
func homeHandler(v string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
t, _ := templates.Templates["views/home/index.tmpl"]
t.Execute(w, templateData{Tab: "home", Version: v})
}
}

func playHandler(w http.ResponseWriter, r *http.Request) {
t, _ := templates.Templates["views/game/play.tmpl"]
t.Execute(w, templateData{"game"})
func playHandler(v string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
t, _ := templates.Templates["views/game/play.tmpl"]
t.Execute(w, templateData{Tab: "game", Version: v})
}
}

func downloadHandler(w http.ResponseWriter, r *http.Request) {
t, _ := templates.Templates["views/game/download.tmpl"]
t.Execute(w, templateData{"download"})
func downloadHandler(v string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
t, _ := templates.Templates["views/game/download.tmpl"]
t.Execute(w, templateData{Tab: "download", Version: v})
}
}

func gameHandler(v string) func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -115,9 +122,11 @@ func gameHandler(v string) func(w http.ResponseWriter, r *http.Request) {
}
}

func docsHandler(w http.ResponseWriter, r *http.Request) {
t, _ := templates.Templates["views/docs/index.tmpl"]
t.Execute(w, templateData{"docs"})
func docsHandler(v string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
t, _ := templates.Templates["views/docs/index.tmpl"]
t.Execute(w, templateData{Tab: "docs", Version: v})
}
}

type usersCreateRequest struct {
Expand Down
15 changes: 3 additions & 12 deletions server/templates/views/game/download.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{define "content"}}
<div class="px-3">
<p class ="lead">
Maze Wars is playable in 3 platforms: Windows, OSX and Linux on amd64 architecture
Maze Wars is playable in 3 platforms: Windows, OSX and Linux on amd64 architecture. And also from the Web Browser
</p>
</div>
</br>
Expand All @@ -20,20 +20,11 @@
<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">
<i class="fa fa-lg fa-linux"></i> Linux
</a>
</div>
</div>
</br>
</br>
<div class="px-3">
<p class ="lead">
Optionally you can also play it from the web, <strong>but it's really slow so play it at your own risk hehe</strong>
</p>
</div>
<div class="px-3">
<div class="d-grid gap-2 d-md-flex justify-content-md-center">
<a href="/play"class="btn btn-lg btn-light fw-bold border-white bg-white" role="button">
<i class="fa fa-lg fa-desktop"></i> Web
</a>
</div>
</div>
</br>
</br>
{{ end}}
5 changes: 2 additions & 3 deletions server/templates/views/game/play.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
crossorigin="anonymous"
></script>
<div class="px-3">
<p class ="lead">
The current web version of this game is really slow. If you want a smooth experience <a href='/download'>download</a> it.
</p>
</br>
</br>
<iframe id="iframe" src="/game" width="850" height="1000" scrolling="no"></iframe>
<center>
<button id="fullscreen" class="btn btn-lg btn-light fw-bold border-white bg-white">Full Screen</a>
Expand Down
17 changes: 10 additions & 7 deletions server/templates/views/layouts/layout.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,26 @@
<nav class="nav nav-masthead justify-content-center float-md-end">
<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "home"}}active{{end}}" href="/">Home</a>
<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "download"}}active{{end}}" href="/download">Download</a>
{{ if eq .Tab "game" }}
<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "game"}}active{{end}}" href="/play">Game</a>
{{ end }}
<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "docs"}}active{{end}}" href="/docs">Docs</a>
<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "game"}}active{{end}}" href="/play">Play!</a>
<!--<a class="nav-link fw-bold py-1 px-0 {{if eq .Tab "docs"}}active{{end}}" href="/docs">Docs</a>-->
</nav>
</div>
</header>
<main class="px-3">
{{template "content" .}}
</main>
<footer class="mt-auto text-white-50">
<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>
<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>
<p>Template from <a href="https://getbootstrap.com/docs/5.3/examples/cover/#">Bootstrap Cover</a>
<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>
<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>
<p>Template from <a target="_blank" href="https://getbootstrap.com/docs/5.3/examples/cover/#">Bootstrap Cover</a>
</footer>
</div>
<script type = "text/javascript" src="/js/bootstrap.bundle.min.js"></script>
</body>

<div class="text-white-50" style="position: absolute; bottom: 5px; right: 5px;">
Version v{{.Version}}
</div>

</html>
{{end}}

0 comments on commit bcfba0b

Please sign in to comment.