mirror of https://github.com/statping/statping
assets generate changes
parent
140495d916
commit
fbde0a5132
|
@ -11,6 +11,7 @@
|
|||
- Modified email notifier template to be rendered from MJML (using go generate)
|
||||
- Modified database relationships with services using gorm
|
||||
- Modified "statping env" command to show user/group ID
|
||||
- Removed "js" folder when exporting assets, js files are always version of release, not static JS files
|
||||
|
||||
# 0.90.61 (07-22-2020)
|
||||
- Modified sass layouts, organized and split up sections
|
||||
|
|
2
app.json
2
app.json
|
@ -2,6 +2,6 @@
|
|||
"name": "Statping",
|
||||
"description": "Statping Server Monitoring with Status Page",
|
||||
"repository": "https://github.com/statping/statping",
|
||||
"logo": "https://raw.githubusercontent.com/statping/statping/master/source/tmpl/banner.png",
|
||||
"logo": "https://assets.statping.com/banner.png",
|
||||
"keywords": ["statping", "server", "monitoring", "status page","golang", "go"]
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Index Page */
|
||||
$background-color: #bf1010;
|
||||
$background-color: #EAEAEA;
|
||||
$container-color: #ffffff;
|
||||
$text-color: #2a2a2a;
|
||||
$max-width: 860px;
|
||||
|
|
|
@ -130,26 +130,15 @@ func apiThemeCreateHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
utils.Log.Infof("creating assets in folder: %s/%s", dir, "assets")
|
||||
if err := source.CreateAllAssets(dir); err != nil {
|
||||
log.Errorln(err)
|
||||
sendErrorJson(err, w, r)
|
||||
return
|
||||
}
|
||||
if err := source.CompileSASS(); err != nil {
|
||||
if err := source.CopyToPublic(source.TmplBox, "css", "style.css"); err != nil {
|
||||
log.Errorln(err)
|
||||
sendErrorJson(err, w, r)
|
||||
return
|
||||
}
|
||||
jsFiles := []string{"bundle.js", "main.chunk.js", "polyfill.chunk.js", "style.chunk.js"}
|
||||
for _, f := range jsFiles {
|
||||
if err := source.CopyToPublic(source.TmplBox, "js", f); err != nil {
|
||||
} else {
|
||||
log.Errorln(err)
|
||||
sendErrorJson(err, w, r)
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Errorln("Default 'base.css' was inserted because SASS did not work.")
|
||||
}
|
||||
resetRouter()
|
||||
sendJsonAction(dir+"/assets", "created", w, r)
|
||||
}
|
||||
|
|
|
@ -22,3 +22,8 @@ func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
returnJson(health, w, r)
|
||||
}
|
||||
|
||||
func notFoundHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
ExecuteResponse(w, r, "base.gohtml", core.App, nil)
|
||||
}
|
||||
|
|
|
@ -69,9 +69,7 @@ func Router() *mux.Router {
|
|||
if source.UsingAssets(dir) {
|
||||
indexHandler := http.FileServer(http.Dir(dir + "/assets/"))
|
||||
|
||||
r.PathPrefix("/css/").Handler(http.StripPrefix(basePath, Gzip(staticAssets("css"))))
|
||||
r.PathPrefix("/js/").Handler(http.StripPrefix(basePath, Gzip(staticAssets("js"))))
|
||||
r.PathPrefix("/scss/").Handler(http.StripPrefix(basePath, staticAssets("scss")))
|
||||
r.PathPrefix("/css/").Handler(http.StripPrefix(basePath, staticAssets("css")))
|
||||
r.PathPrefix("/favicon/").Handler(http.StripPrefix(basePath, staticAssets("favicon")))
|
||||
r.PathPrefix("/robots.txt").Handler(http.StripPrefix(basePath, indexHandler))
|
||||
r.PathPrefix("/banner.png").Handler(http.StripPrefix(basePath, indexHandler))
|
||||
|
@ -79,14 +77,14 @@ func Router() *mux.Router {
|
|||
tmplFileSrv := http.FileServer(source.TmplBox.HTTPBox())
|
||||
tmplBoxHandler := http.StripPrefix(basePath, tmplFileSrv)
|
||||
|
||||
r.PathPrefix("/css/").Handler(http.StripPrefix(basePath, Gzip(tmplFileSrv)))
|
||||
r.PathPrefix("/scss/").Handler(http.StripPrefix(basePath, tmplFileSrv))
|
||||
r.PathPrefix("/js/").Handler(http.StripPrefix(basePath, Gzip(tmplFileSrv)))
|
||||
r.PathPrefix("/css/").Handler(http.StripPrefix(basePath, tmplFileSrv))
|
||||
r.PathPrefix("/favicon/").Handler(http.StripPrefix(basePath, tmplFileSrv))
|
||||
r.PathPrefix("/robots.txt").Handler(tmplBoxHandler)
|
||||
r.PathPrefix("/banner.png").Handler(tmplBoxHandler)
|
||||
}
|
||||
|
||||
r.PathPrefix("/js/").Handler(http.StripPrefix(basePath, http.FileServer(source.TmplBox.HTTPBox())))
|
||||
|
||||
api := r.NewRoute().Subrouter()
|
||||
api.Use(apiMiddleware)
|
||||
api.Use(prometheusMiddleware)
|
||||
|
@ -182,11 +180,12 @@ func Router() *mux.Router {
|
|||
// API Generic Routes
|
||||
r.Handle("/metrics", readOnly(promhttp.Handler(), false))
|
||||
r.Handle("/health", http.HandlerFunc(healthCheckHandler))
|
||||
r.NotFoundHandler = http.HandlerFunc(error404Handler)
|
||||
r.NotFoundHandler = http.HandlerFunc(notFoundHandler)
|
||||
return r
|
||||
}
|
||||
|
||||
func resetRouter() {
|
||||
log.Infoln("Restarting HTTP Router")
|
||||
router = Router()
|
||||
httpServer.Handler = router
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func processSetupHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -123,7 +122,7 @@ func processSetupHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
CacheStorage.Delete("/")
|
||||
resetCookies()
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
out := struct {
|
||||
Message string `json:"message"`
|
||||
Config *configs.DbConfig `json:"config"`
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
var (
|
||||
log = utils.Log.WithField("type", "source")
|
||||
TmplBox *rice.Box // HTML and other small files from the 'source/tmpl' directory, this will be loaded into '/assets'
|
||||
TmplBox *rice.Box // HTML and other small files from the 'source/dist' directory, this will be loaded into '/assets'
|
||||
RequiredFiles = []string{
|
||||
"css/style.css",
|
||||
"css/style.css.gz",
|
||||
|
@ -25,17 +25,13 @@ var (
|
|||
"scss/mixin.scss",
|
||||
"scss/mobile.scss",
|
||||
"scss/variables.scss",
|
||||
"js/bundle.js",
|
||||
"js/main.chunk.js",
|
||||
"js/polyfill.chunk.js",
|
||||
"js/style.chunk.js",
|
||||
"banner.png",
|
||||
"favicon.ico",
|
||||
"robots.txt",
|
||||
}
|
||||
)
|
||||
|
||||
// Assets will load the Rice boxes containing the CSS, SCSS, JS, and HTML files.
|
||||
// Assets will load the Rice boxes containing the CSS, SCSS, favicon, and HTML files.
|
||||
func Assets() error {
|
||||
if utils.Params.GetBool("DISABLE_HTTP") {
|
||||
return nil
|
||||
|
@ -130,7 +126,7 @@ func OpenAsset(path string) string {
|
|||
return data
|
||||
}
|
||||
|
||||
// CreateAllAssets will dump HTML, CSS, SCSS, and JS assets into the '/assets' directory
|
||||
// CreateAllAssets will dump HTML, CSS, SCSS, and favicon assets into the '/assets' directory
|
||||
func CreateAllAssets(folder string) error {
|
||||
log.Infoln(fmt.Sprintf("Dump Statping assets into %s/assets", folder))
|
||||
fp := filepath.Join
|
||||
|
@ -138,9 +134,6 @@ func CreateAllAssets(folder string) error {
|
|||
if err := MakePublicFolder(fp(folder, "/assets")); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := MakePublicFolder(fp(folder, "assets", "js")); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := MakePublicFolder(fp(folder, "assets", "css")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -150,7 +143,7 @@ func CreateAllAssets(folder string) error {
|
|||
if err := MakePublicFolder(fp(folder, "assets", "scss")); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infoln("Inserting scss, css, and javascript files into assets folder")
|
||||
log.Infoln("Inserting scss, css, and favicon files into assets folder")
|
||||
|
||||
if err := CopyAllToPublic(TmplBox); err != nil {
|
||||
log.Errorln(err)
|
||||
|
@ -199,6 +192,9 @@ func CopyAllToPublic(box *rice.Box) error {
|
|||
if exclude[info.Name()] {
|
||||
return nil
|
||||
}
|
||||
if strings.Contains(path, "js") {
|
||||
return nil
|
||||
}
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
@ -232,11 +228,11 @@ func CopyToPublic(box *rice.Box, path, file string) error {
|
|||
|
||||
// MakePublicFolder will create a new folder
|
||||
func MakePublicFolder(folder string) error {
|
||||
log.Infoln(fmt.Sprintf("Creating folder '%v'", folder))
|
||||
log.Infoln(fmt.Sprintf("Creating folder '%s'", folder))
|
||||
if !utils.FolderExists(folder) {
|
||||
err := utils.CreateDirectory(folder)
|
||||
if err != nil {
|
||||
log.Errorln(fmt.Sprintf("Failed to created %v directory, %v", folder, err))
|
||||
log.Errorln(fmt.Sprintf("Failed to created %s directory, %v", folder, err))
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue