Skip to content

Commit

Permalink
basic game search done
Browse files Browse the repository at this point in the history
  • Loading branch information
kubegu committed Jun 20, 2024
1 parent 60e4661 commit a2bdd6a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func InitMux() *http.ServeMux {
mux.Handle("/", http.FileServer(http.Dir("web/static")))
mux.HandleFunc("/games-index/", gameIndexHandler)
mux.HandleFunc("/movies-search/", movieSearchHandler)
mux.HandleFunc("/games-search/", gameSearchHandler)
return mux
}

Expand All @@ -31,7 +32,11 @@ type MediaByBranch struct {
}

func gameSearchHandler(respWriter http.ResponseWriter, request *http.Request) {

title := strings.ToLower(request.PostFormValue("title"))
platform := strings.ToLower(request.PostFormValue("platform"))
client := libClient.Client{}
games := client.FindGames(title, platform)
renderMediaResults(games, respWriter)
}

func movieSearchHandler(respWriter http.ResponseWriter, request *http.Request) {
Expand Down
33 changes: 33 additions & 0 deletions web/static/games.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="https://unpkg.com/[email protected]" integrity="sha384-D1Kt99CQMDuVetoL1lrYwg5t+9QdHe7NLX/SoJYkXDFfX37iInKRy5xLSi8nO7UC" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<form hx-post="/games-search/" hx-target="#display-games" hx-indicator="#spinner" class="d-flex flex-wrap justify-content-center">
<div class="p-2">
<input type="text" class="form-control" id="title" name="title" placeholder="Titel des Spiels">
</div>
<!-- TODO: insert option für platform-->
<div class="p-2">
<select id="platformSelect" name="platform" class="form-select" style="width:auto;">
<option>Switch</option>
<option>XBox</option>
<option>Playstation</option>
</select>
</div>
<div class="p-2">
<button type="submit" class="btn btn-primary">Los</button>
</div>
</form>
<div class="d-flex justify-content-center htmx-indicator" id="spinner">
<div class="spinner-border" role="status"></div>
</div>
<div class="accordion" id="display-games">

</div>
</div>
</body>
</html>

0 comments on commit a2bdd6a

Please sign in to comment.