Separated asset files into their own folder with the correct file
formats, and added a script to build them into required .go file using go-bindata.
This commit is contained in:
parent
24b1bb0f2a
commit
700c3d1d4d
1
Makefile
1
Makefile
@ -33,6 +33,7 @@ vet:
|
||||
|
||||
build:
|
||||
@echo ">> building binaries"
|
||||
@./build/assets.sh
|
||||
@./build/build.sh
|
||||
|
||||
release: build
|
||||
|
37
build/assets.sh
Executable file
37
build/assets.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
GIT_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
YEAR=$(date +%Y)
|
||||
|
||||
TMP_OUTPUT="/tmp/cadvisor_assets.go"
|
||||
ASSETS_OUTPUT=$GIT_ROOT/pages/static/assets.go
|
||||
|
||||
go get -u github.com/jteeuwen/go-bindata/...
|
||||
|
||||
for f in $GIT_ROOT/pages/assets/**/*; do
|
||||
if [ "$f" -nt $ASSETS_OUTPUT -o ! -e $ASSETS_OUTPUT ]; then
|
||||
go-bindata -o $ASSETS_OUTPUT -pkg static $GIT_ROOT/pages/assets/...
|
||||
cat build/boilerplate/boilerplate.go.txt | sed "s/YEAR/$YEAR/" > "${TMP_OUTPUT}"
|
||||
echo -e "// generated by build/assets.sh; DO NOT EDIT\n" >> "${TMP_OUTPUT}"
|
||||
cat "${ASSETS_OUTPUT}" >> "${TMP_OUTPUT}"
|
||||
gofmt -w -s "${TMP_OUTPUT}"
|
||||
mv "${TMP_OUTPUT}" "${ASSETS_OUTPUT}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -43,3 +43,13 @@ Now you can run the built binary:
|
||||
```
|
||||
$GOPATH/src/github.com/google/cadvisor $ sudo ./cadvisor
|
||||
```
|
||||
|
||||
## Compiling Assets
|
||||
|
||||
If you modify files in the /assets folder, you will need to rebuild the assets:
|
||||
|
||||
```
|
||||
$GOPATH/src/github.com/google/cadvisor $ ./build/assets.sh
|
||||
$GOPATH/src/github.com/google/cadvisor $ godep go build .
|
||||
```
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -1,20 +1,3 @@
|
||||
// Copyright 2015 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package static
|
||||
|
||||
const gchartsJs = `
|
||||
(function() {
|
||||
var aa=encodeURIComponent,ba=window,ca=Object,da=Infinity,ea=document,fa=isNaN,h=Math,ga=Array,ha=Number,ia=NaN,m=Error,ja=Boolean,ka=parseInt,la=parseFloat,na=isFinite,oa=decodeURIComponent;function pa(a,b){return a.width=b}function qa(a,b){return a.data=b}function ra(a,b){return a.ceil=b}function sa(a,b){return a.floor=b}function ta(a,b){return a.format=b}function ua(a,b){return a.remove=b}function va(a,b){return a.clear=b}function wa(a,b){return a.getColumnIndex=b}
|
||||
function xa(a,b){return a.stroke=b}function ya(a,b){return a.getTime=b}function za(a,b){return a.fill=b}function Aa(a,b){return a.toString=b}function Ba(a,b){return a.position=b}function Ca(a,b){return a.toJSON=b}function Da(a,b){return a.next=b}function Ea(a,b){return a.constructor=b}function Fa(a,b){return a.fontSize=b}function Ga(a,b){return a.message=b}function Ia(a,b){return a.clone=b}function Ka(a,b){return a.start=b}function La(a,b){return a.init=b}function Ma(a,b){return a.bottom=b}
|
||||
@ -1392,4 +1375,4 @@ xx(oX[K],oX[K][hA]);Cw(oX[K],oX[K][qy]);oX[K].setAction=oX[K].dj;oX[K].getAction
|
||||
|
||||
google.load('visualization','1',{packages: ['corechart', 'gauge', 'default', 'format', 'ui', 'table']});
|
||||
google.loader.loaded({"module":"visualization","version":"1.0","components":["ui","corechart","default","gauge","format"]});
|
||||
google.loader.eval.visualization = function() {eval(arguments[0]);};if (google.loader.eval.scripts && google.loader.eval.scripts['visualization']) {(function() {var scripts = google.loader.eval.scripts['visualization'];for (var i = 0; i < scripts.length; i++) {google.loader.eval.visualization(scripts[i]);}})();google.loader.eval.scripts['visualization'] = null;}})();`
|
||||
google.loader.eval.visualization = function() {eval(arguments[0]);};if (google.loader.eval.scripts && google.loader.eval.scripts['visualization']) {(function() {var scripts = google.loader.eval.scripts['visualization'];for (var i = 0; i < scripts.length; i++) {google.loader.eval.visualization(scripts[i]);}})();google.loader.eval.scripts['visualization'] = null;}})();
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -32,6 +32,7 @@ const containersHtmlTemplate = `
|
||||
<script type="text/javascript" src="{{.Root}}static/google-jsapi.js"></script>
|
||||
|
||||
<script type="text/javascript" src="{{.Root}}static/containers.js"></script>
|
||||
<script type="text/javascript" src="{{.Root}}static/gcharts.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container theme-showcase" >
|
||||
|
419
pages/static/assets.go
Normal file
419
pages/static/assets.go
Normal file
File diff suppressed because one or more lines are too long
@ -26,14 +26,25 @@ import (
|
||||
|
||||
const StaticResource = "/static/"
|
||||
|
||||
var staticFiles = map[string]string{
|
||||
var bootstrapJs, _ = Asset("pages/assets/js/bootstrap-3.1.1.min.js")
|
||||
var containersJs, _ = Asset("pages/assets/js/containers.js")
|
||||
var gchartsJs, _ = Asset("pages/assets/js/gcharts.js")
|
||||
var googleJsapiJs, _ = Asset("pages/assets/js/google-jsapi.js")
|
||||
var jqueryJs, _ = Asset("pages/assets/js/jquery-1.10.2.min.js")
|
||||
|
||||
var bootstrapCss, _ = Asset("pages/assets/styles/bootstrap-3.1.1.min.css")
|
||||
var bootstrapThemeCss, _ = Asset("pages/assets/styles/bootstrap-theme-3.1.1.min.css")
|
||||
var containersCss, _ = Asset("pages/assets/styles/containers.css")
|
||||
|
||||
var staticFiles = map[string][]byte{
|
||||
"bootstrap-3.1.1.min.css": bootstrapCss,
|
||||
"bootstrap-3.1.1.min.js": bootstrapJs,
|
||||
"bootstrap-theme-3.1.1.min.css": bootstrapThemeCss,
|
||||
"containers.css": containersCss,
|
||||
"containers.js": containersJs,
|
||||
"bootstrap-3.1.1.min.css": bootstrapCss,
|
||||
"bootstrap-theme-3.1.1.min.css": bootstrapThemeCss,
|
||||
"jquery-1.10.2.min.js": jqueryJs,
|
||||
"bootstrap-3.1.1.min.js": bootstrapJs,
|
||||
"gcharts.js": gchartsJs,
|
||||
"google-jsapi.js": googleJsapiJs,
|
||||
"jquery-1.10.2.min.js": jqueryJs,
|
||||
}
|
||||
|
||||
func HandleRequest(w http.ResponseWriter, u *url.URL) error {
|
||||
@ -54,6 +65,6 @@ func HandleRequest(w http.ResponseWriter, u *url.URL) error {
|
||||
w.Header().Set("Content-Type", contentType)
|
||||
}
|
||||
|
||||
_, err := w.Write([]byte(content))
|
||||
_, err := w.Write(content)
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user