Skip to content

Commit

Permalink
Move generated assets to seperate package
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleBanks committed Mar 24, 2017
1 parent a5ca260 commit 5ddc523
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ before_install:

# Note: Need to ignore all cmd/goggles files because gallium will not work on the linix travis instances.
script:
- rm -rf cmd/goggles/
- rm -rf server/assets
- $HOME/gopath/bin/goveralls -service=travis-ci
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ assets:
npm install ; \
gulp

@go-bindata-assetfs -ignore=node_modules -pkg server static/... ; \
mv bindata_assetfs.go server/
@go-bindata-assetfs -ignore=node_modules -pkg assets static/... ; \
mv bindata_assetfs.go server/assets/
.PHONY: assets

# Cleans any built artifacts.
Expand Down Expand Up @@ -61,7 +61,7 @@ build.app: | clean assets
# binaries for the browser application.
release: | sanity build.app
@cd $(BIN) ; \
zip -r -y goggles.$(VERSION).zip $(APP_NAME)
zip -r -y goggles.osx.app.$(VERSION).zip $(APP_NAME)

@gox -osarch="$(strip $(RELEASE_PLATFORMS))" \
-output "bin/{{.Dir}}_$(VERSION)_{{.OS}}_{{.Arch}}" $(INSTALL_PKG)
Expand All @@ -82,7 +82,7 @@ sanity:
@go list ./... | grep -v vendor/ | xargs go vet

@echo "---------------- LINT ----------------"
@go list ./... | grep -v vendor/ | xargs golint
@go list ./... | grep -v -e vendor/ -e server/assets | xargs golint

@echo "---------------- FMT ----------------"
@go list ./... | grep -v vendor/ | xargs go fmt
Expand Down
10 changes: 10 additions & 0 deletions server/assets/assets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package assets

import (
"github.com/elazarl/go-bindata-assetfs"
)

// FS returns the assets FileSystem.
func FS() *assetfs.AssetFS {
return assetFS()
}
22 changes: 11 additions & 11 deletions server/bindata_assetfs.go → server/assets/bindata_assetfs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"net/http"

"github.com/KyleBanks/goggles/server/api"
"github.com/KyleBanks/goggles/server/assets"
)

// New prepares and returns an HTTP ServeMux bound to the Goggles API and
// static assets.
func New(p api.Provider) *http.ServeMux {
mux := http.NewServeMux()
fs := http.FileServer(assetFS())
fs := http.FileServer(assets.FS())
mux.Handle("/", http.StripPrefix("/static/", fs))
api.Bind(p, mux)

Expand Down

0 comments on commit 5ddc523

Please sign in to comment.