mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 00:46:30 +00:00
ability to squash and embed static files
This commit is contained in:
parent
a1f3b2da4d
commit
3b7c9738a3
5 changed files with 41 additions and 8 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -13,5 +13,9 @@ drone.sublime-workspace
|
||||||
*.db
|
*.db
|
||||||
*.txt
|
*.txt
|
||||||
*.toml
|
*.toml
|
||||||
|
bindata.go
|
||||||
|
|
||||||
drone
|
# combined assets
|
||||||
|
server/static/drone.js
|
||||||
|
|
||||||
|
drone
|
||||||
|
|
17
Makefile
17
Makefile
|
@ -1,9 +1,10 @@
|
||||||
SHA := $(shell git rev-parse --short HEAD)
|
SHA := $(shell git rev-parse --short HEAD)
|
||||||
VERSION := 0.4.0-alpha
|
VERSION := 0.4.0-alpha
|
||||||
|
|
||||||
all: build
|
all: concat bindata build
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
|
go get -u github.com/jteeuwen/go-bindata/...
|
||||||
go get -t -v ./...
|
go get -t -v ./...
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
@ -16,3 +17,17 @@ build:
|
||||||
clean:
|
clean:
|
||||||
find . -name "*.out" -delete
|
find . -name "*.out" -delete
|
||||||
rm -f drone
|
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/...
|
22
drone.go
22
drone.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
@ -11,16 +12,17 @@ import (
|
||||||
"github.com/drone/drone/server"
|
"github.com/drone/drone/server"
|
||||||
"github.com/drone/drone/server/session"
|
"github.com/drone/drone/server/session"
|
||||||
"github.com/drone/drone/settings"
|
"github.com/drone/drone/settings"
|
||||||
|
"github.com/elazarl/go-bindata-assetfs"
|
||||||
|
|
||||||
queue "github.com/drone/drone/queue/builtin"
|
queue "github.com/drone/drone/queue/builtin"
|
||||||
)
|
)
|
||||||
|
|
||||||
var path = flag.String("config", "drone.toml", "")
|
var conf = flag.String("config", "drone.toml", "")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
settings, err := settings.Parse(*path)
|
settings, err := settings.Parse(*conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -134,6 +136,18 @@ func main() {
|
||||||
r.NoRoute(func(c *gin.Context) {
|
r.NoRoute(func(c *gin.Context) {
|
||||||
c.File("server/static/index.html")
|
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",
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ func remove(c *gin.Context) {
|
||||||
func pull(c *gin.Context) {
|
func pull(c *gin.Context) {
|
||||||
q := fromContext(c)
|
q := fromContext(c)
|
||||||
var work *queue.Work
|
var work *queue.Work
|
||||||
if c.Request.FormValue("ack") != "" {
|
if c.Request.FormValue("ack") == "true" {
|
||||||
work = q.PullAck()
|
work = q.PullAck()
|
||||||
} else {
|
} else {
|
||||||
work = q.Pull()
|
work = q.Pull()
|
||||||
|
|
|
@ -387,4 +387,4 @@ Filter = (function() {
|
||||||
|
|
||||||
return Filter;
|
return Filter;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue