2016-08-23 08:31:50 +08:00
|
|
|
package js
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"compress/gzip"
|
|
|
|
"encoding/base64"
|
|
|
|
"io/ioutil"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type _escLocalFS struct{}
|
|
|
|
|
|
|
|
var _escLocal _escLocalFS
|
|
|
|
|
|
|
|
type _escStaticFS struct{}
|
|
|
|
|
|
|
|
var _escStatic _escStaticFS
|
|
|
|
|
|
|
|
type _escDirectory struct {
|
|
|
|
fs http.FileSystem
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
type _escFile struct {
|
|
|
|
compressed string
|
|
|
|
size int64
|
|
|
|
modtime int64
|
|
|
|
local string
|
|
|
|
isDir bool
|
|
|
|
|
|
|
|
once sync.Once
|
|
|
|
data []byte
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (_escLocalFS) Open(name string) (http.File, error) {
|
|
|
|
f, present := _escData[path.Clean(name)]
|
|
|
|
if !present {
|
|
|
|
return nil, os.ErrNotExist
|
|
|
|
}
|
|
|
|
return os.Open(f.local)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (_escStaticFS) prepare(name string) (*_escFile, error) {
|
|
|
|
f, present := _escData[path.Clean(name)]
|
|
|
|
if !present {
|
|
|
|
return nil, os.ErrNotExist
|
|
|
|
}
|
|
|
|
var err error
|
|
|
|
f.once.Do(func() {
|
|
|
|
f.name = path.Base(name)
|
|
|
|
if f.size == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var gr *gzip.Reader
|
|
|
|
b64 := base64.NewDecoder(base64.StdEncoding, bytes.NewBufferString(f.compressed))
|
|
|
|
gr, err = gzip.NewReader(b64)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
f.data, err = ioutil.ReadAll(gr)
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return f, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fs _escStaticFS) Open(name string) (http.File, error) {
|
|
|
|
f, err := fs.prepare(name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return f.File()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dir _escDirectory) Open(name string) (http.File, error) {
|
|
|
|
return dir.fs.Open(dir.name + name)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *_escFile) File() (http.File, error) {
|
|
|
|
type httpFile struct {
|
|
|
|
*bytes.Reader
|
|
|
|
*_escFile
|
|
|
|
}
|
|
|
|
return &httpFile{
|
|
|
|
Reader: bytes.NewReader(f.data),
|
|
|
|
_escFile: f,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *_escFile) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *_escFile) Readdir(count int) ([]os.FileInfo, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *_escFile) Stat() (os.FileInfo, error) {
|
|
|
|
return f, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *_escFile) Name() string {
|
|
|
|
return f.name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *_escFile) Size() int64 {
|
|
|
|
return f.size
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *_escFile) Mode() os.FileMode {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *_escFile) ModTime() time.Time {
|
|
|
|
return time.Unix(f.modtime, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *_escFile) IsDir() bool {
|
|
|
|
return f.isDir
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *_escFile) Sys() interface{} {
|
|
|
|
return f
|
|
|
|
}
|
|
|
|
|
|
|
|
// FS returns a http.Filesystem for the embedded assets. If useLocal is true,
|
|
|
|
// the filesystem's contents are instead used.
|
|
|
|
func FS(useLocal bool) http.FileSystem {
|
|
|
|
if useLocal {
|
|
|
|
return _escLocal
|
|
|
|
}
|
|
|
|
return _escStatic
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dir returns a http.Filesystem for the embedded assets on a given prefix dir.
|
|
|
|
// If useLocal is true, the filesystem's contents are instead used.
|
|
|
|
func Dir(useLocal bool, name string) http.FileSystem {
|
|
|
|
if useLocal {
|
|
|
|
return _escDirectory{fs: _escLocal, name: name}
|
|
|
|
}
|
|
|
|
return _escDirectory{fs: _escStatic, name: name}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FSByte returns the named file from the embedded assets. If useLocal is
|
|
|
|
// true, the filesystem's contents are instead used.
|
|
|
|
func FSByte(useLocal bool, name string) ([]byte, error) {
|
|
|
|
if useLocal {
|
|
|
|
f, err := _escLocal.Open(name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b, err := ioutil.ReadAll(f)
|
|
|
|
f.Close()
|
|
|
|
return b, err
|
|
|
|
}
|
|
|
|
f, err := _escStatic.prepare(name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return f.data, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// FSMustByte is the same as FSByte, but panics if name is not present.
|
|
|
|
func FSMustByte(useLocal bool, name string) []byte {
|
|
|
|
b, err := FSByte(useLocal, name)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
// FSString is the string version of FSByte.
|
|
|
|
func FSString(useLocal bool, name string) (string, error) {
|
|
|
|
b, err := FSByte(useLocal, name)
|
|
|
|
return string(b), err
|
|
|
|
}
|
|
|
|
|
|
|
|
// FSMustString is the string version of FSMustByte.
|
|
|
|
func FSMustString(useLocal bool, name string) string {
|
|
|
|
return string(FSMustByte(useLocal, name))
|
|
|
|
}
|
|
|
|
|
|
|
|
var _escData = map[string]*_escFile{
|
|
|
|
|
|
|
|
"/helpers.js": {
|
|
|
|
local: "js/helpers.js",
|
2016-12-17 04:10:27 +08:00
|
|
|
size: 7195,
|
2016-08-23 08:31:50 +08:00
|
|
|
modtime: 0,
|
|
|
|
compressed: `
|
2016-12-17 04:10:27 +08:00
|
|
|
H4sIAAAAAAAA/7RZfU/jzBH/P59iaqkXu/gc4A5aOU+qpgc8OpUEBKFFiiK02JtkOdtr7a6TUhQ+e7Uv
|
|
|
|
ttdxcoD0HH+E2Dsvv3nZ2dmJU3AMXDASCaff6awQg4hmcxjASwcAgOEF4YIhxkOYznz1Ls74Q87oisS4
|
|
|
|
8ZqmiGTqRWdjZMV4jopEDNmCwwCms36nMy+ySBCaAcmIICgh/8Oup5U1NO/T/hME2yjk86avwbWAbCwo
|
|
|
|
Y7y+KVW5GUqxL55z7KdYIM/AIXNw5UuvgiefYDAAZzQc3w0vHa1ooz6l7QwvpDFSXAhKqGIJ1acPUnio
|
|
|
|
Pg1EaX1QWxzkBV+6DC+8vomEKFimBLXAn2X82rjDrTVpHZYB4CoT6FwtwGAwgC59fMKR6Hrw6RO4XZI/
|
|
|
|
RDRbYcYJzXgXSKZleFZQ5IugSQgDmFOWIvEghLtj3dtyTczzj7umEXTtnZjnb3knw+szlRLaMZV/vSrB
|
|
|
|
FWMDS0UU1l8NqpeNXI4oi3k4nfkyE6/rRJSrJtMmk8sQDn0lkWMmPRFOZ5smuJzRCHN+htiCu6lvktd2
|
|
|
|
dq8nPQsYRUtIaUzmBDNfxpIIIBxQEAQNWiM5hAgliSRaE7E0cm1CxBh6DksA0qSCcbLCybNNpZNDhoIt
|
|
|
|
sFKZCaocESOBKkq5Nx4Cwi+MdjdtJEyZN64xr1+tbAAnHFf8QwlqB7P0gCvz5kklZFt204/Tp1nlygbh
|
|
|
|
Zp/iK2XnDs0PAf6vwFlsoAfSdD9tW2BziSWja3D+M7wZfx//HhokVfR03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