Browse Source

En cours de développement

master
mls-361 9 months ago
parent
commit
4d68142ddf
  1. 18
      Taskfile.yml
  2. 3
      cmd/main.go
  3. 22
      internal/gui/devel.go
  4. 11
      internal/gui/gui.go
  5. 31
      internal/gui/prod.go
  6. 0
      internal/gui/static/css/colors.css
  7. 0
      internal/gui/static/css/common.css
  8. 0
      internal/gui/static/css/dashboard.css
  9. 0
      internal/gui/static/css/normalize.css

18
Taskfile.yml

@ -25,23 +25,19 @@ tasks:
- go get -u forge.chapril.org/mls-361/logger
- go get -u forge.chapril.org/mls-361/uuid
- go mod tidy
lint:
cmds:
- golangci-lint run
test:
default:
cmds:
- golangci-lint run
- go test -cover -v ./...
build:
cmds:
- go build -ldflags "{{.LDFLAGS}}" -o $GOPATH/bin/armen ./cmd/main.go
default:
devel:
cmds:
- task: lint
- task: test
- task: build
- golangci-lint run --build-tags devel
- go test -tags devel -cover -v ./...
- go build -tags devel -ldflags "{{.LDFLAGS}}" -o $GOPATH/bin/armen ./cmd/main.go
git:
cmds:
- git add .

3
cmd/main.go

@ -84,9 +84,8 @@ func buildComponents(ccs *components.Components) error {
}
api.Build(ccs)
gui.Build(ccs)
return nil
return gui.Build(ccs)
}
func waitEnd(server components.Server) (*sync.WaitGroup, chan struct{}) {

22
internal/gui/devel.go

@ -0,0 +1,22 @@
// +build devel
/*
------------------------------------------------------------------------------------------------------------------------
####### gui ####### Copyright (c) 2021 mls-361 ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package gui
import (
"net/http"
"os"
)
func getStaticFS() (http.FileSystem, error) {
return http.FS(os.DirFS("static")), nil
}
/*
######################################################################################################## @(°_°)@ #######
*/

11
internal/gui/gui.go

@ -12,10 +12,15 @@ import (
"forge.chapril.org/armen/armen/internal/components"
)
func Build(ccs *components.Components) {
func Build(ccs *components.Components) error {
staticFS, err := getStaticFS()
if err != nil {
return err
}
router := ccs.Router
router.ServeFiles("/static/*filepath", http.Dir("static"))
router.ServeFiles("/static/*filepath", staticFS)
router.Get("/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
_ = newDashboard(ccs).
@ -28,6 +33,8 @@ func Build(ccs *components.Components) {
build().
Render(w)
}))
return nil
}
/*

31
internal/gui/prod.go

@ -0,0 +1,31 @@
// +build !devel
/*
------------------------------------------------------------------------------------------------------------------------
####### gui ####### Copyright (c) 2021 mls-361 ##################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package gui
import (
"embed"
"io/fs"
"net/http"
)
//go:embed static
var static embed.FS
func getStaticFS() (http.FileSystem, error) {
fsys, err := fs.Sub(static, "static")
if err != nil {
return nil, err
}
return http.FS(fsys), nil
}
/*
######################################################################################################## @(°_°)@ #######
*/

0
static/css/colors.css → internal/gui/static/css/colors.css

0
static/css/common.css → internal/gui/static/css/common.css

0
static/css/dashboard.css → internal/gui/static/css/dashboard.css

0
static/css/normalize.css → internal/gui/static/css/normalize.css vendored

Loading…
Cancel
Save