do some cssy stuff

This commit is contained in:
idk
2020-05-23 14:08:51 -04:00
parent 6df216330a
commit d7318e62f8
7 changed files with 374 additions and 288 deletions

View File

@ -6,7 +6,7 @@ gen:
#go run -tags generate gen.go #go run -tags generate gen.go
fmt: clean fmt: clean
gofmt -w -s *.go gofmt -w -s *.go reseed-monitor/main.go
setup: fmt setup: fmt
rsync -rav ~/i2p/certificates/ssl/ ssl/ rsync -rav ~/i2p/certificates/ssl/ ssl/

File diff suppressed because one or more lines are too long

View File

@ -78,9 +78,9 @@ func GeneratePage() (string, error) {
} }
Valid, Errored := CheckKeys(su3file, "./reseed") Valid, Errored := CheckKeys(su3file, "./reseed")
if Errored != nil { if Errored != nil {
ret += `<div id="` + TrimDir(path) + ` Invalid">` + Errored.Error() + `</div>` ret += `<div class="` + TrimDir(path) + ` Invalid">` + Errored.Error() + `</div>`
} else { } else {
ret += `<div id="` + TrimDir(path) + ` Valid">` + Valid + `</div>` ret += `<div class="` + TrimDir(path) + ` Valid">` + Valid + `</div>`
} }
} }
} else { } else {

View File

@ -1,25 +1,41 @@
package main package main
import ( import (
"log"
"github.com/eyedeekay/reseed-monitoring"
"io/ioutil" "io/ioutil"
"log"
"net/http"
"time"
"github.com/eyedeekay/reseed-monitoring"
) )
func main() { func main() {
config, err := monitor.SortedMap("config.json") go loop()
if err != nil { if err := http.ListenAndServe("127.0.0.1:7672", &monitor.MonitorServer{}); err != nil {
log.Fatal(err) log.Fatal(err)
} }
errs := monitor.SortedMonitor(config) }
if errs != nil {
if len(errs) > 0 { func loop() {
log.Println(errs) for {
} config, err := monitor.SortedMap("config.json")
} if err != nil {
index, err := monitor.GeneratePage() log.Fatal(err)
if err != nil { }
log.Fatal(err) errs := monitor.SortedMonitor(config)
} if errs != nil {
ioutil.WriteFile("index.html", []byte(index), 0644) if len(errs) > 0 {
log.Println(errs)
}
}
index, err := monitor.GeneratePage()
if err != nil {
log.Fatal(err)
}
err = ioutil.WriteFile("index.html", []byte(index), 0644)
if err != nil {
log.Fatal(err)
}
time.Sleep(time.Duration(24 * time.Hour))
}
} }

Binary file not shown.

36
server.go Normal file
View File

@ -0,0 +1,36 @@
package monitor
import (
"io/ioutil"
"net/http"
"strings"
)
type MonitorServer struct {
}
func (m *MonitorServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
path := strings.TrimSpace(strings.Replace(r.URL.Path, "/", "", -1))
//path = strings.Replace(r.URL.Path, ".", "", -1)
if r.URL.Path == "/" {
r.URL.Path = "/index.html"
}
if strings.HasSuffix(r.URL.Path, ".css") {
w.Header().Set("Content-Type", "text/css")
} else if strings.HasSuffix(r.URL.Path, ".js") {
w.Header().Set("Content-Type", "text/javascript")
} else if strings.HasSuffix(r.URL.Path, ".png") {
w.Header().Set("Content-Type", "image/png")
} else {
w.Header().Set("Content-Type", "text/html")
}
if strings.HasPrefix(path, "data-dir") {
return
}
bytes, err := ioutil.ReadFile(path)
if err != nil {
return
}
w.Write(bytes)
}

View File

@ -1,3 +1,37 @@
.Reseed { .Reseed {
border: 1px solid black; border: 1px solid black;
} }
.key {
border: 1px solid black;
min-width: 20%;
min-height: 15px;
display: inline-block;
overflow: scroll;
margin-left: 3%;
}
.value {
border: 1px solid black;
min-width: 70%;
max-width: 70%;
font-family: monospace;
min-height: 15px;
display: inline-block;
overflow: scroll;
margin-left: 3%;
}
.Valid {
overflow: scroll;
min-width: 90%;
max-width: 90%;
margin-left: 5%;
}
.Invalid {
overflow: scroll;
min-width: 90%;
max-width: 90%;
margin-left: 5%;
}