-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace go-bindata with vfsgen (#521)
Signed-off-by: niedhui <niedhui@gmail.com>
- Loading branch information
Showing
11 changed files
with
119 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,33 @@ | ||
// Copyright 2020 PingCAP, Inc. | ||
// | ||
// 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, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// +build ui_server | ||
|
||
package uiserver | ||
|
||
import ( | ||
"html" | ||
"net/http" | ||
"os" | ||
"strings" | ||
) | ||
|
||
type modifiedFileInfo struct { | ||
os.FileInfo | ||
size int64 | ||
} | ||
|
||
func (f modifiedFileInfo) Size() int64 { | ||
return f.size | ||
} | ||
|
||
func (f modifiedFileInfo) Sys() interface{} { | ||
return nil | ||
} | ||
|
||
func InitAssetFS(prefix string) { | ||
rewrite := func(assetPath string) { | ||
a, err := _bindata[assetPath]() | ||
if err != nil { | ||
panic("Asset " + assetPath + " not found.") | ||
} | ||
tmplText := string(a.bytes) | ||
updated := strings.ReplaceAll(tmplText, "__PUBLIC_PATH_PREFIX__", html.EscapeString(prefix)) | ||
a.bytes = []byte(updated) | ||
a.info = modifiedFileInfo{a.info, int64(len(a.bytes))} | ||
_bindata[assetPath] = func() (*asset, error) { | ||
return a, nil | ||
func RewriteAssetsPublicPath(publicPath string) { | ||
RewriteAssets(publicPath, AssetFS(), func(fs http.FileSystem, f http.File, path, newContent string, bs []byte) { | ||
m := fs.(vfsgen۰FS) | ||
fi := f.(os.FileInfo) | ||
m[path] = &vfsgen۰CompressedFileInfo{ | ||
name: fi.Name(), | ||
modTime: fi.ModTime(), | ||
uncompressedSize: int64(len(newContent)), | ||
compressedContent: bs, | ||
} | ||
} | ||
rewrite("build/index.html") | ||
rewrite("build/diagnoseReport.html") | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.