Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a823da1f29 | ||
|
|
b0b7e9da61 | ||
|
|
6a25f39e36 |
@@ -30,7 +30,7 @@ jobs:
|
|||||||
v: true
|
v: true
|
||||||
x: false
|
x: false
|
||||||
race: false
|
race: false
|
||||||
ldflags: -s -w -X github.com/naiba/nezha/service/singleton.Version=${{ steps.extract_branch.outputs.tag }}
|
ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=${{ steps.extract_branch.outputs.tag }}
|
||||||
buildmode: default
|
buildmode: default
|
||||||
|
|
||||||
- name: fix dist
|
- name: fix dist
|
||||||
|
|||||||
@@ -17,10 +17,22 @@ jobs:
|
|||||||
- name: Unit test
|
- name: Unit test
|
||||||
run: |
|
run: |
|
||||||
go test -v ./...
|
go test -v ./...
|
||||||
- name: Build test
|
|
||||||
run: |
|
|
||||||
go build cmd/dashboard/main.go
|
|
||||||
- name: Run Gosec Security Scanner
|
- name: Run Gosec Security Scanner
|
||||||
uses: securego/gosec@master
|
uses: securego/gosec@master
|
||||||
with:
|
with:
|
||||||
args: --exclude=G104,G402 ./...
|
args: --exclude=G104,G402 ./...
|
||||||
|
- name: xgo build
|
||||||
|
uses: crazy-max/ghaction-xgo@v2
|
||||||
|
with:
|
||||||
|
xgo_version: latest
|
||||||
|
go_version: 1.21
|
||||||
|
dest: dist
|
||||||
|
pkg: cmd/dashboard
|
||||||
|
prefix: dashboard
|
||||||
|
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64 # linux/386,
|
||||||
|
v: true
|
||||||
|
x: false
|
||||||
|
race: false
|
||||||
|
ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=test
|
||||||
|
buildmode: default
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,21 @@ jobs:
|
|||||||
- name: Unit test
|
- name: Unit test
|
||||||
run: |
|
run: |
|
||||||
go test -v ./...
|
go test -v ./...
|
||||||
- name: Build test
|
|
||||||
run: |
|
|
||||||
go build cmd/dashboard/main.go
|
|
||||||
- name: Run Gosec Security Scanner
|
- name: Run Gosec Security Scanner
|
||||||
uses: securego/gosec@master
|
uses: securego/gosec@master
|
||||||
with:
|
with:
|
||||||
args: --exclude=G104,G402 ./...
|
args: --exclude=G104,G402 ./...
|
||||||
|
- name: xgo build
|
||||||
|
uses: crazy-max/ghaction-xgo@v2
|
||||||
|
with:
|
||||||
|
xgo_version: latest
|
||||||
|
go_version: 1.21
|
||||||
|
dest: dist
|
||||||
|
pkg: cmd/dashboard
|
||||||
|
prefix: dashboard
|
||||||
|
targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64 # linux/386,
|
||||||
|
v: true
|
||||||
|
x: false
|
||||||
|
race: false
|
||||||
|
ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=test
|
||||||
|
buildmode: default
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
||||||
<br><br>
|
<br><br>
|
||||||
<img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/naiba/nezha?style=for-the-badge&logo=github&label=Dashboard"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.15.0-brightgreen?style=for-the-badge&logo=linux">
|
<img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&style=for-the-badge&logo=github&label=Dashboard"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.15.0-brightgreen?style=for-the-badge&logo=linux">
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>
|
<p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -16,7 +18,6 @@ import (
|
|||||||
"github.com/nicksnyder/go-i18n/v2/i18n"
|
"github.com/nicksnyder/go-i18n/v2/i18n"
|
||||||
|
|
||||||
"github.com/naiba/nezha/pkg/mygin"
|
"github.com/naiba/nezha/pkg/mygin"
|
||||||
"github.com/naiba/nezha/pkg/utils"
|
|
||||||
"github.com/naiba/nezha/resource"
|
"github.com/naiba/nezha/resource"
|
||||||
"github.com/naiba/nezha/service/singleton"
|
"github.com/naiba/nezha/service/singleton"
|
||||||
)
|
)
|
||||||
@@ -30,12 +31,7 @@ func ServeWeb(port uint) *http.Server {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if utils.IsFileExists("resource/template") {
|
tmpl = loadThirdPartyTemplates(tmpl)
|
||||||
tmpl, err = tmpl.ParseGlob("resource/template/**/*.html")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
r.SetHTMLTemplate(tmpl)
|
r.SetHTMLTemplate(tmpl)
|
||||||
if singleton.Conf.Debug {
|
if singleton.Conf.Debug {
|
||||||
gin.SetMode(gin.DebugMode)
|
gin.SetMode(gin.DebugMode)
|
||||||
@@ -87,6 +83,28 @@ func routers(r *gin.Engine) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func loadThirdPartyTemplates(tmpl *template.Template) *template.Template {
|
||||||
|
var ret = tmpl
|
||||||
|
themes, err := os.ReadDir("resource/template")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("NEZHA>> Error reading themes folder: %v", err)
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
for _, theme := range themes {
|
||||||
|
if !theme.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// load templates
|
||||||
|
t, err := ret.ParseGlob(fmt.Sprintf("resource/template/%s/*.html", theme.Name()))
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("NEZHA>> Error parsing templates %s error: %v", theme.Name(), err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ret = t
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
var funcMap = template.FuncMap{
|
var funcMap = template.FuncMap{
|
||||||
"tr": func(id string, dataAndCount ...interface{}) string {
|
"tr": func(id string, dataAndCount ...interface{}) string {
|
||||||
conf := i18n.LocalizeConfig{
|
conf := i18n.LocalizeConfig{
|
||||||
|
|||||||
Reference in New Issue
Block a user