diff --git a/.dockerignore b/.dockerignore index a2b2dfb5..91725b18 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,10 @@ .git +.github .idea +logs *.log build +assets source/rice-box.go .env .DS_Store diff --git a/Makefile b/Makefile index fefcbf65..8f70dcd8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=0.79.1 +VERSION=0.79.2 BINARY_NAME=statup GOPATH:=$(GOPATH) GOCMD=go diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml index 3683a79e..9e2ce64b 100644 --- a/dev/docker-compose.yml +++ b/dev/docker-compose.yml @@ -1,3 +1,10 @@ +statup: + container_name: statup + image: hunterlong/statup + restart: always + ports: + - 8080:8080 + postgres: container_name: postgres image: postgres @@ -20,13 +27,3 @@ mysql: MYSQL_DATABASE: root MYSQL_USER: root MYSQL_PASSWORD: password123 - -mssql: - container_name: mssql - image: microsoft/mssql-server-linux - restart: always - ports: - - 1433:1433 - environment: - SA_PASSWORD: PaSsW0rD123 - ACCEPT_EULA: "Y" diff --git a/handlers/handlers.go b/handlers/handlers.go index 683d4ede..1620658e 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -105,6 +105,9 @@ var handlerFuncs = func(w http.ResponseWriter, r *http.Request) template.FuncMap "Services": func() []types.ServiceInterface { return core.CoreApp.Services }, + "len": func(g []types.ServiceInterface) int { + return len(g) + }, "USE_CDN": func() bool { return core.CoreApp.UseCdn }, diff --git a/handlers/routes.go b/handlers/routes.go index eb03e800..a182ab2f 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -38,17 +38,17 @@ func Router() *mux.Router { r.Handle("/", cached("120s", "text/html", http.HandlerFunc(indexHandler))) if source.UsingAssets(dir) { indexHandler := http.FileServer(http.Dir(dir + "/assets/")) - r.PathPrefix("/css/").Handler(http.StripPrefix("/font/", http.FileServer(http.Dir(dir+"/assets/font")))) - r.PathPrefix("/font/").Handler(http.StripPrefix("/css/", http.FileServer(http.Dir(dir+"/assets/css")))) + r.PathPrefix("/css/").Handler(http.StripPrefix("/css/", http.FileServer(http.Dir(dir+"/assets/css")))) + r.PathPrefix("/font/").Handler(http.StripPrefix("/font/", http.FileServer(http.Dir(dir+"/assets/font")))) r.PathPrefix("/robots.txt").Handler(indexHandler) r.PathPrefix("/favicon.ico").Handler(indexHandler) r.PathPrefix("/statup.png").Handler(indexHandler) } else { r.PathPrefix("/css/").Handler(http.StripPrefix("/css/", http.FileServer(source.CssBox.HTTPBox()))) + r.PathPrefix("/font/").Handler(http.StripPrefix("/font/", http.FileServer(source.FontBox.HTTPBox()))) r.PathPrefix("/robots.txt").Handler(http.FileServer(source.TmplBox.HTTPBox())) r.PathPrefix("/favicon.ico").Handler(http.FileServer(source.TmplBox.HTTPBox())) r.PathPrefix("/statup.png").Handler(http.FileServer(source.TmplBox.HTTPBox())) - r.PathPrefix("/font/").Handler(http.StripPrefix("/font/", http.FileServer(source.FontBox.HTTPBox()))) } r.PathPrefix("/js/").Handler(http.StripPrefix("/js/", http.FileServer(source.JsBox.HTTPBox()))) r.Handle("/charts.js", http.HandlerFunc(renderServiceChartsHandler)) diff --git a/handlers/settings.go b/handlers/settings.go index a60137e2..6cc4a215 100644 --- a/handlers/settings.go +++ b/handlers/settings.go @@ -103,7 +103,7 @@ func saveAssetsHandler(w http.ResponseWriter, r *http.Request) { err = source.CompileSASS(dir) if err != nil { source.CopyToPublic(source.CssBox, dir+"/assets/css", "base.css") - utils.Log(2, "Default 'base.css' was insert because SASS did not work.") + utils.Log(3, "Default 'base.css' was inserted because SASS did not work.") } resetRouter() executeResponse(w, r, "settings.html", core.CoreApp, "/settings") diff --git a/notifiers/mobile.go b/notifiers/mobile.go index 363eac73..fd23d100 100644 --- a/notifiers/mobile.go +++ b/notifiers/mobile.go @@ -31,15 +31,15 @@ type mobilePush struct { var mobile = &mobilePush{¬ifier.Notification{ Method: "mobile", Title: "Mobile Notifications", - Description: "Receive push notifications on your mobile device using the Statup App.", + Description: "Receive push notifications on your Android or iPhone devices using the Statup App. You can scan the Authentication QR Code found in Settings to get the mobile app setup in seconds.", Author: "Hunter Long", AuthorUrl: "https://github.com/hunterlong", Delay: time.Duration(5 * time.Second), Icon: "fas fa-mobile-alt", Form: []notifier.NotificationForm{{ Type: "text", - Title: "Mobile Identifiers", - Placeholder: "A list of your mobile push notification ids", + Title: "Device Identifiers", + Placeholder: "A list of your mobile device push notification ID's.", DbField: "var1", }}}, } diff --git a/source/css/base.css b/source/css/base.css index 18949e90..fb6dc1be 100644 --- a/source/css/base.css +++ b/source/css/base.css @@ -1,36 +1,4 @@ @charset "UTF-8"; -/*! - * Statup - * Copyright (C) 2018. Hunter Long and the project contributors - * Written by Hunter Long and the project contributors - * - * https://github.com/hunterlong/statup - * - * The licenses for most software and other practical works are designed - * to take away your freedom to share and change the works. By contrast, - * the GNU General Public License is intended to guarantee your freedom to - * share and change all versions of a program--to make sure it remains free - * software for all its users. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -/*! - * Statup - * Copyright (C) 2018. Hunter Long and the project contributors - * Written by Hunter Long and the project contributors - * - * https://github.com/hunterlong/statup - * - * The licenses for most software and other practical works are designed - * to take away your freedom to share and change the works. By contrast, - * the GNU General Public License is intended to guarantee your freedom to - * share and change all versions of a program--to make sure it remains free - * software for all its users. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ /* Index Page */ /* Status Container */ /* Button Colors */ @@ -618,22 +586,6 @@ HTML, BODY { box-shadow: none; border-radius: 3px; } -/*! - * Statup - * Copyright (C) 2018. Hunter Long and the project contributors - * Written by Hunter Long and the project contributors - * - * https://github.com/hunterlong/statup - * - * The licenses for most software and other practical works are designed - * to take away your freedom to share and change the works. By contrast, - * the GNU General Public License is intended to guarantee your freedom to - * share and change all versions of a program--to make sure it remains free - * software for all its users. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ @media (max-width: 767px) { HTML, BODY { background-color: #fcfcfc; } diff --git a/source/scss/base.scss b/source/scss/base.scss index 9079c465..a6fb0907 100644 --- a/source/scss/base.scss +++ b/source/scss/base.scss @@ -1,20 +1,3 @@ -/*! - * Statup - * Copyright (C) 2018. Hunter Long and the project contributors - * Written by Hunter Long and the project contributors - * - * https://github.com/hunterlong/statup - * - * The licenses for most software and other practical works are designed - * to take away your freedom to share and change the works. By contrast, - * the GNU General Public License is intended to guarantee your freedom to - * share and change all versions of a program--to make sure it remains free - * software for all its users. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - @import 'variables'; diff --git a/source/scss/mobile.scss b/source/scss/mobile.scss index 29c4dad0..12919abe 100644 --- a/source/scss/mobile.scss +++ b/source/scss/mobile.scss @@ -1,20 +1,3 @@ -/*! - * Statup - * Copyright (C) 2018. Hunter Long and the project contributors - * Written by Hunter Long and the project contributors - * - * https://github.com/hunterlong/statup - * - * The licenses for most software and other practical works are designed - * to take away your freedom to share and change the works. By contrast, - * the GNU General Public License is intended to guarantee your freedom to - * share and change all versions of a program--to make sure it remains free - * software for all its users. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - @media (max-width: 767px) { HTML,BODY { diff --git a/source/scss/variables.scss b/source/scss/variables.scss index a5687691..e0c15b0b 100644 --- a/source/scss/variables.scss +++ b/source/scss/variables.scss @@ -1,20 +1,3 @@ -/*! - * Statup - * Copyright (C) 2018. Hunter Long and the project contributors - * Written by Hunter Long and the project contributors - * - * https://github.com/hunterlong/statup - * - * The licenses for most software and other practical works are designed - * to take away your freedom to share and change the works. By contrast, - * the GNU General Public License is intended to guarantee your freedom to - * share and change all versions of a program--to make sure it remains free - * software for all its users. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - /* Index Page */ $background-color: #fcfcfc; $max-width: 860px; diff --git a/source/source.go b/source/source.go index 9d3f22c5..2a8722ac 100644 --- a/source/source.go +++ b/source/source.go @@ -131,7 +131,7 @@ func UsingAssets(folder string) bool { // SaveAsset will save an asset to the '/assets/' folder. func SaveAsset(data []byte, folder, file string) error { - utils.Log(1, fmt.Sprintf("Saving %v/%v into assets folder", folder, file)) + utils.Log(1, fmt.Sprintf("Saving %v/assets/%v into assets folder", folder, file)) err := ioutil.WriteFile(folder+"/assets/"+file, data, 0744) if err != nil { utils.Log(3, fmt.Sprintf("Failed to save %v/%v, %v", folder, file, err)) @@ -157,23 +157,19 @@ func CreateAllAssets(folder string) error { MakePublicFolder(folder + "/assets/js") MakePublicFolder(folder + "/assets/css") MakePublicFolder(folder + "/assets/scss") + MakePublicFolder(folder + "/assets/font") utils.Log(1, "Inserting scss, css, and javascript files into assets folder") - CopyToPublic(ScssBox, folder+"/assets/scss", "base.scss") - CopyToPublic(ScssBox, folder+"/assets/scss", "variables.scss") - CopyToPublic(ScssBox, folder+"/assets/scss", "mobile.scss") - CopyToPublic(ScssBox, folder+"/assets/scss", "pikaday.scss") - CopyToPublic(CssBox, folder+"/assets/css", "bootstrap.min.css") - CopyToPublic(CssBox, folder+"/assets/css", "base.css") - //CopyToPublic(JsBox, folder+"/assets/js", "bootstrap.min.js") - //CopyToPublic(JsBox, folder+"/assets/js", "Chart.bundle.min.js") - //CopyToPublic(JsBox, folder+"/assets/js", "jquery-3.3.1.min.js") - //CopyToPublic(JsBox, folder+"/assets/js", "sortable.min.js") - //CopyToPublic(JsBox, folder+"/assets/js", "main.js") - //CopyToPublic(JsBox, folder+"/assets/js", "setup.js") + CopyAllToPublic(FontBox, "font") + CopyAllToPublic(ScssBox, "scss") + CopyAllToPublic(CssBox, "css") + CopyAllToPublic(JsBox, "js") + CopyToPublic(FontBox, folder+"/assets/font", "all.css") CopyToPublic(TmplBox, folder+"/assets", "robots.txt") CopyToPublic(TmplBox, folder+"/assets", "statup.png") + CopyToPublic(TmplBox, folder+"/assets", "favicon.ico") utils.Log(1, "Compiling CSS from SCSS style...") - err := utils.Log(1, "Statup assets have been inserted") + err := CompileSASS(utils.Directory) + utils.Log(1, "Statup assets have been inserted") return err } @@ -188,6 +184,27 @@ func DeleteAllAssets(folder string) error { return err } +func CopyAllToPublic(box *rice.Box, folder string) error { + err := box.Walk("/", func(path string, info os.FileInfo, err error) error { + if info.Name() == "" { + return nil + } + if info.IsDir() { + folder := fmt.Sprintf("%v/assets/%v/%v", utils.Directory, folder, info.Name()) + MakePublicFolder(folder) + return nil + } + file, err := box.Bytes(path) + if err != nil { + return nil + } + filePath := fmt.Sprintf("%v%v", folder, path) + SaveAsset(file, utils.Directory, filePath) + return nil + }) + return err +} + // CopyToPublic will create a file from a rice Box to the '/assets' directory func CopyToPublic(box *rice.Box, folder, file string) error { assetFolder := fmt.Sprintf("%v/%v", folder, file) diff --git a/source/tmpl/head.html b/source/tmpl/head.html index 2fd59939..86033ef5 100644 --- a/source/tmpl/head.html +++ b/source/tmpl/head.html @@ -1,7 +1,9 @@ {{ define "head"}} + {{block "title" .}} {{end}} + {{if USE_CDN}} @@ -14,6 +16,5 @@ {{end}} {{block "extra_css" .}} {{end}} -{{block "title" .}} {{end}} {{end}} diff --git a/source/tmpl/index.html b/source/tmpl/index.html index ac21821c..d4cb9ebd 100644 --- a/source/tmpl/index.html +++ b/source/tmpl/index.html @@ -1,4 +1,5 @@ {{define "title"}}{{CoreApp.Name}} Status{{end}} +{{define "description"}}{{CoreApp.Name}} is currently monitoring {{len CoreApp.Services}} services with 0 of them offline. {{CoreApp.Name}} is using Statup to monitor applications.{{end}} {{define "content"}}

{{.Name}}

diff --git a/source/tmpl/service.html b/source/tmpl/service.html index d767f41b..3eb11e96 100644 --- a/source/tmpl/service.html +++ b/source/tmpl/service.html @@ -1,7 +1,7 @@ {{define "title"}}{{.Service.Name}} Status{{end}} +{{define "description"}}{{$s := .Service}}{{if $s.Online }}{{.Service.Name}} is currently online and responding within {{$s.AvgTime}} milliseconds with {{$s.TotalUptime}}% total uptime on {{$s.Domain}}.{{else}}{{.Service.Name}} is currently offline on {{$s.Domain}}. Notify the admin to let them know their service is offline.{{end}}{{end}} {{ define "content" }} {{$s := .Service}} -
{{if Auth}} diff --git a/source/tmpl/settings.html b/source/tmpl/settings.html index e627e9df..763fa5fd 100644 --- a/source/tmpl/settings.html +++ b/source/tmpl/settings.html @@ -17,7 +17,7 @@ {{end}}
-
+
{{if Error}} {{end}} @@ -109,12 +109,15 @@ You can Regenerate API Keys if you need to.
- -
+ +
+
diff --git a/source/tmpl/setup.html b/source/tmpl/setup.html index 8b92e66b..f51ae353 100644 --- a/source/tmpl/setup.html +++ b/source/tmpl/setup.html @@ -1,4 +1,5 @@ {{define "title"}}Statup | Setup{{end}} +{{define "description"}}Setup your Statup instance to monitor your websites and servers using MySQL, Postgres or SQLite.{{end}} {{define "content"}}