bundle bootstrap, bootstrap-table and jquery assets

This way, the UI works even when the user is offline, which is handy for
router7.
This commit is contained in:
Michael Stapelberg 2019-11-09 09:21:47 +01:00
parent 520b8ca41d
commit 09fbdb123e
10 changed files with 61 additions and 17 deletions

6
assets/bootstrap-3.3.7.min.css vendored Normal file

File diff suppressed because one or more lines are too long

1
assets/bootstrap-table-1.11.0.min.css vendored Normal file

File diff suppressed because one or more lines are too long

8
assets/bootstrap-table-1.11.0.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.0/bootstrap-table.min.js" integrity="sha256-eXHLyyVI+v6X1wbfg9NB05IWqOqY4E9185nHZgeDIhg=" crossorigin="anonymous"></script>
<script src="/jquery-3.1.1.min.js"></script>
<script src="/bootstrap-table-1.11.0.min.js"></script>
</html>
</html>

View File

@ -1,8 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<title>{{ .Hostname }} — gokrazy</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.0/bootstrap-table.min.css" integrity="sha256-eU4xmpfQx1HSi5q1q2rHNcMEzTNJov7r2Wr/6zF3ANc=" crossorigin="anonymous" />
<link rel="stylesheet" href="/bootstrap-3.3.7.min.css" />
<link rel="stylesheet" href="/bootstrap-table-1.11.0.min.css" />
<style type="text/css">
.progress-bar:nth-child(5n) {
background-color: #337ab7;

4
assets/jquery-3.1.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
package gokrazy
//go:generate sh -c "go run goembed.go -package bundled -var assets assets/header.tmpl assets/footer.tmpl assets/overview.tmpl assets/status.tmpl assets/favicon.ico > internal/bundled/GENERATED_bundled.go"
//go:generate sh -c "go run goembed.go -package bundled -var assets assets/header.tmpl assets/footer.tmpl assets/overview.tmpl assets/status.tmpl assets/favicon.ico assets/bootstrap-3.3.7.min.css assets/bootstrap-table-1.11.0.min.css assets/bootstrap-table-1.11.0.min.js assets/jquery-3.1.1.min.js > internal/bundled/GENERATED_bundled.go"

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,18 @@
package bundled
import (
"bytes"
"net/http"
"time"
)
func Asset(basename string) string {
return string(assets["assets/"+basename])
}
func HTTPHandlerFunc(basename string) http.Handler {
modTime := time.Now()
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.ServeContent(w, r, basename, modTime, bytes.NewReader(assets["assets/"+basename]))
})
}

View File

@ -94,11 +94,15 @@ var overviewTmpl = template.Must(template.Must(commonTmpls.Clone()).New("overvie
var statusTmpl = template.Must(template.Must(commonTmpls.Clone()).New("statusTmpl").Parse(bundled.Asset("status.tmpl")))
func initStatus(services []*service) {
http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
if _, err := w.Write([]byte(bundled.Asset("favicon.ico"))); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
})
for _, fn := range []string{
"favicon.ico",
"bootstrap-3.3.7.min.css",
"bootstrap-table-1.11.0.min.css",
"bootstrap-table-1.11.0.min.js",
"jquery-3.1.1.min.js",
} {
http.Handle("/"+fn, bundled.HTTPHandlerFunc(fn))
}
http.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")