Skip to content
Snippets Groups Projects
Verified Commit 6f7ff962 authored by Réthelyi Bálint's avatar Réthelyi Bálint :no_mouth:
Browse files

nice order

parent 5b8432bf
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ type User struct {
Point int
Group *Group
LastVisitedURL string
StoryCounter int
}
type Group struct {
......
......@@ -90,16 +90,17 @@ func login(c *gin.Context) {
Id: uuid.New(),
Name: c.PostForm("name"),
Point: 0,
StoryCounter: 0,
Group: group,
}
group.Members = append(group.Members, *user)
c.SetCookie("uuid", user.Id.String(), 7200, "/", "", false, true)
}
if user.LastVisitedURL == "" {
user.LastVisitedURL = "first"
if user.Group.Route[user.StoryCounter].Id == "" {
user.Group.Route[user.StoryCounter].Id = "first"
}
c.Redirect(http.StatusMovedPermanently, "/station/"+user.LastVisitedURL)
c.Redirect(http.StatusMovedPermanently, "/station/"+user.Group.Route[user.StoryCounter].Id)
}
func routeChooser(c *gin.Context) {
......@@ -122,8 +123,24 @@ func routeChooser(c *gin.Context) {
return
}
user.LastVisitedURL = stationUri.Id
story := ""
for i, stat := range user.Group.Route {
if user.StoryCounter < i {
break
}
if stat == station {
story = route.Stories[i]
}
}
if story != "" {
c.HTML(http.StatusOK, "station.html", gin.H{
"Name": station.Name,
"Story": story,
})
}
if user.Group.Route[user.StoryCounter] == station {
user.StoryCounter++
}
}
......@@ -5,8 +5,6 @@
<title>{{ .Name }}</title>
</head>
<body>
{{ .Name }}
{{ .Name }}
{{ .Story }}
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment