Skip to content

Commit

Permalink
Migrate to react, welcome to the future (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-pousse authored and ggerbaud committed Aug 19, 2016
1 parent ca4a3d9 commit 08d6112
Show file tree
Hide file tree
Showing 49 changed files with 479 additions and 1,674 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
go-dart
dist/
webapp/build
.idea
/go-dart.iml
vendor
Expand Down
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ SOURCES=$(shell git ls-files '*.go')
BUILD_IMAGE=go-dart.build:latest
RUN_IMAGE=docker run --rm -e GITHUB_TOKEN -v $(CURDIR)/dist:/go/src/github.com/gocaine/go-dart/dist -v $(CURDIR)/reports:/go/src/github.com/gocaine/go-dart/reports go-dart.build:latest

UI_BUILD_IMAGE=ggerbaud/node-bower-grunt:5
UI_RUN_IMAGE=docker run --rm -v $(PWD)/webapp:/data $(UI_BUILD_IMAGE)
UI_RUN_PRESTEP=
UI_BUILD_IMAGE=go-dart-ui.build:latest
UI_RUN_IMAGE=docker run --rm -v $(CURDIR)/webapp:/data go-dart-ui.build:latest
UI_RUN_PRESTEP=cd $(CURDIR)/webapp &&

# Set the pi user
RPI_USER?=pi
Expand All @@ -30,9 +30,9 @@ arm: ## build for ARM target
$(eval GOARCH=GOOS=linux GOARCH=arm)

mock.ui:
if [ ! -e webapp/dist/index.html ]; then \
mkdir -p webapp/dist; \
echo "void starts here" > webapp/dist/index.html; \
if [ ! -e webapp/build/index.html ]; then \
mkdir -p webapp/build; \
echo "void starts here" > webapp/build/index.html; \
fi

binary-noui: mock.ui build.go ## package the core w/o ui
Expand All @@ -58,13 +58,12 @@ build.go: build.go-image

build.ui-image:
@if [ "$(USE_LOCAL)" != "local" ]; then \
echo "using remote image" ;\
cd webapp && docker build -t $(UI_BUILD_IMAGE) -f Dockerfile.build . ;\
fi

build.ui: build.ui-image
$(UI_RUN_PRESTEP) $(UI_RUN_IMAGE) npm install && \
$(UI_RUN_IMAGE) bower install && \
$(UI_RUN_IMAGE) grunt build
$(UI_RUN_IMAGE) npm install && \
$(UI_RUN_IMAGE) npm run build

validate:
$(RUN_IMAGE) scripts/make.sh validate-gofmt validate-govet validate-golint
Expand Down
2 changes: 1 addition & 1 deletion generate.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main

//go:generate rm -vf server/autogen/statics.go
//go:generate go-bindata -pkg autogen -o server/autogen/statics.go ./webapp/dist/...
//go:generate go-bindata -pkg autogen -o server/autogen/statics.go ./webapp/build/...
7 changes: 4 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (server *Server) Start() {
fmt.Println("Ready to Dart !!")
engine := gin.Default()

apiRouter := engine.Group("api")
apiRouter := engine.Group("/api")

// les styles de jeu possibles
apiRouter.GET("/styles", server.getStylesHandler) // retourne la liste des styles
Expand All @@ -71,11 +71,12 @@ func (server *Server) Start() {
apiRouter.GET("/games/:gameId/ws", server.wsHandler)

assetsRouter := engine.Group("/web")
assetsRouter.StaticFS("/", &assetfs.AssetFS{Asset: autogen.Asset, AssetDir: autogen.AssetDir, AssetInfo: autogen.AssetInfo, Prefix: "webapp/dist"})
assetsRouter.StaticFS("/", &assetfs.AssetFS{Asset: autogen.Asset, AssetDir: autogen.AssetDir, AssetInfo: autogen.AssetInfo, Prefix: "webapp/build"})

engine.Any("/", func(c *gin.Context) {
c.Redirect(http.StatusMovedPermanently, "web")
})

engine.Run(":8080")
}

Expand Down Expand Up @@ -251,7 +252,7 @@ func (server *Server) findGameByIDHandler(c *gin.Context) {
return
}

c.JSON(http.StatusOK, gin.H{"game": currentGame})
c.JSON(http.StatusOK, gin.H{"game": currentGame.State()})
}

func (server *Server) addPlayerToGameHandler(c *gin.Context) {
Expand Down
1 change: 1 addition & 0 deletions webapp/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
1 change: 1 addition & 0 deletions webapp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/node_modules
/dist
/build
/.tmp
/.sass-cache
/bower_components
5 changes: 5 additions & 0 deletions webapp/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM node:6

RUN mkdir /data
WORKDIR /data

Loading

0 comments on commit 08d6112

Please sign in to comment.