forked from banool/codenames-pictures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.go
33 lines (26 loc) · 819 Bytes
/
data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package codenames
import "github.com/katorek/codenames-pictures/webpack"
//import "github.com/kimrgrey/go-create-react-app/webpack"
// User represents current user session
// ViewData contains data for the view
type ViewData struct {
assetsMapper webpack.AssetsMapper
SelectedGameID string
AutogeneratedGameID string
}
// NewViewData creates new data for the view
func (s *Server) NewViewData(id string, autogeneratedID string) (ViewData, error) {
assetsMapper, err := webpack.NewAssetsMapper(s.buildPath)
if err != nil {
return ViewData{}, err
}
return ViewData{
assetsMapper: assetsMapper,
SelectedGameID: id,
AutogeneratedGameID: autogeneratedID,
}, nil
}
// Webpack maps file name to path
func (d ViewData) Webpack(file string) string {
return d.assetsMapper(file)
}