ability to squash and embed static files

This commit is contained in:
Brad Rydzewski 2015-04-25 16:16:56 -07:00
parent a1f3b2da4d
commit 3b7c9738a3
5 changed files with 41 additions and 8 deletions

6
.gitignore vendored
View file

@ -13,5 +13,9 @@ drone.sublime-workspace
*.db
*.txt
*.toml
bindata.go
drone
# combined assets
server/static/drone.js
drone

View file

@ -1,9 +1,10 @@
SHA := $(shell git rev-parse --short HEAD)
VERSION := 0.4.0-alpha
all: build
all: concat bindata build
deps:
go get -u github.com/jteeuwen/go-bindata/...
go get -t -v ./...
test:
@ -16,3 +17,17 @@ build:
clean:
find . -name "*.out" -delete
rm -f drone
rm -f bindata.go
concat:
cat server/static/scripts/drone.js \
server/static/scripts/services/*.js \
server/static/scripts/filters/*.js \
server/static/scripts/controllers/*.js \
server/static/scripts/term.js > server/static/drone.js
bindata_debug:
go-bindata --debug server/static/...
bindata:
go-bindata server/static/...

View file

@ -2,6 +2,7 @@ package main
import (
"flag"
"net/http"
"github.com/gin-gonic/gin"
@ -11,16 +12,17 @@ import (
"github.com/drone/drone/server"
"github.com/drone/drone/server/session"
"github.com/drone/drone/settings"
"github.com/elazarl/go-bindata-assetfs"
queue "github.com/drone/drone/queue/builtin"
)
var path = flag.String("config", "drone.toml", "")
var conf = flag.String("config", "drone.toml", "")
func main() {
flag.Parse()
settings, err := settings.Parse(*path)
settings, err := settings.Parse(*conf)
if err != nil {
panic(err)
}
@ -134,6 +136,18 @@ func main() {
r.NoRoute(func(c *gin.Context) {
c.File("server/static/index.html")
})
r.Static("/static", "server/static")
r.Run(settings.Server.Addr)
http.Handle("/static/", static())
http.Handle("/", r)
http.ListenAndServe(settings.Server.Addr, nil)
}
// static is a helper function that will setup handlers
// for serving static files.
func static() http.Handler {
return http.StripPrefix("/static/", http.FileServer(&assetfs.AssetFS{
Asset: Asset,
AssetDir: AssetDir,
Prefix: "server/static",
}))
}

View file

@ -72,7 +72,7 @@ func remove(c *gin.Context) {
func pull(c *gin.Context) {
q := fromContext(c)
var work *queue.Work
if c.Request.FormValue("ack") != "" {
if c.Request.FormValue("ack") == "true" {
work = q.PullAck()
} else {
work = q.Pull()

View file

@ -387,4 +387,4 @@ Filter = (function() {
return Filter;
})();
})();