diff --git a/Makefile b/Makefile
index e711f49..8d40ad1 100644
--- a/Makefile
+++ b/Makefile
@@ -32,4 +32,4 @@ stop-container:
docker rm -f golias 2>/dev/null && echo "old container removed"
run-container: stop-container
- docker run --name=golias -v $(CURDIR)/store.json:/root/store.json -p 0.0.0.0:9000:9000 -d golias:master
+ docker run --name=golias -v $(CURDIR)/store.json:/root/store.json -p 0.0.0.0:3000:3000 -d golias:master
diff --git a/components/base.html b/components/base.html
new file mode 100644
index 0000000..769062e
--- /dev/null
+++ b/components/base.html
@@ -0,0 +1,49 @@
+{{define "base"}}
+
+
+
+ Alias
+
+
+
+
+
+
+
+
+
+
+ {{template "main" .}}
+
+
+
+{{end}}
diff --git a/components/index.html b/components/index.html
index fe83049..e3a9956 100644
--- a/components/index.html
+++ b/components/index.html
@@ -1,72 +1,8 @@
{{define "main"}}
-
-
-
- Word Colors
-
-
-
-
-
-
-
-
-
-
{{template "login"}}
{{template "room" .}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{{end}}
diff --git a/components/room.html b/components/room.html
index 90c3faf..3117cff 100644
--- a/components/room.html
+++ b/components/room.html
@@ -1,41 +1,8 @@
{{define "room"}}
-
- {{template "cardtable" .}}
+ {{template "teampew" "blue"}}
-
+ {{template "cardtable" "red"}}
{{end}}
diff --git a/components/teampew.html b/components/teampew.html
new file mode 100644
index 0000000..575debe
--- /dev/null
+++ b/components/teampew.html
@@ -0,0 +1,18 @@
+{{define "teampew"}}
+
+{{end}}
diff --git a/handlers/auth.go b/handlers/auth.go
index 3458e6f..c908b62 100644
--- a/handlers/auth.go
+++ b/handlers/auth.go
@@ -45,7 +45,7 @@ func HandleFrontLogin(w http.ResponseWriter, r *http.Request) {
abortWithError(w, err.Error())
return
}
- tmpl.ExecuteTemplate(w, "main", roundWords)
+ tmpl.ExecuteTemplate(w, "base", roundWords)
}
func makeCookie(username string, remote string) (*http.Cookie, error) {
diff --git a/handlers/game.go b/handlers/game.go
index b84f725..8be29bf 100644
--- a/handlers/game.go
+++ b/handlers/game.go
@@ -40,5 +40,42 @@ func HandleCreateRoom(w http.ResponseWriter, r *http.Request) {
abortWithError(w, err.Error())
return
}
- tmpl.ExecuteTemplate(w, "main", nil)
+ tmpl.ExecuteTemplate(w, "base", nil)
+}
+
+func HandleRoomEnter(w http.ResponseWriter, r *http.Request) {
+ // parse payload
+ roomID := r.URL.Query().Get("id")
+ if roomID == "" {
+ // error
+ return
+ }
+ // create a room
+ room, err := getRoomByID(roomID)
+ if err != nil {
+ msg := "failed to find the room"
+ log.Error(msg, "error", err, "room_id", roomID)
+ abortWithError(w, msg)
+ return
+ }
+ ctx := context.WithValue(r.Context(), "current_room", room.ID)
+ ctx, err = updateRoomInSession(ctx, room.ID)
+ if err != nil {
+ msg := "failed to set current room to session"
+ log.Error(msg, "error", err)
+ abortWithError(w, msg)
+ return
+ }
+ // send msg of created room
+ // h.Broker.Notifier <- broker.NotificationEvent{
+ // EventName: models.MsgRoomListUpdate,
+ // Payload: fmt.Sprintf("%s created a room named %s", r.CreatorName, r.RoomName),
+ // }
+ // return html
+ tmpl, err := template.ParseGlob("components/*.html")
+ if err != nil {
+ abortWithError(w, err.Error())
+ return
+ }
+ tmpl.ExecuteTemplate(w, "base", room)
}
diff --git a/handlers/handlers.go b/handlers/handlers.go
index 5207d62..261990c 100644
--- a/handlers/handlers.go
+++ b/handlers/handlers.go
@@ -58,5 +58,5 @@ func HandleHome(w http.ResponseWriter, r *http.Request) {
// return
// }
userState := models.MakeTestState()
- tmpl.ExecuteTemplate(w, "main", userState)
+ tmpl.ExecuteTemplate(w, "base", userState)
}
diff --git a/main.go b/main.go
index d26bcfc..566b59a 100644
--- a/main.go
+++ b/main.go
@@ -22,6 +22,7 @@ func ListenToRequests(port string) error {
mux.HandleFunc("GET /ping", handlers.HandlePing)
mux.HandleFunc("GET /", handlers.HandleHome)
mux.HandleFunc("POST /login", handlers.HandleFrontLogin)
+ mux.HandleFunc("GET /room", handlers.HandleRoomEnter)
//elements
mux.HandleFunc("GET /room/createform", handlers.HandleShowCreateForm)
mux.HandleFunc("GET /room/hideform", handlers.HandleHideCreateForm)