mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-01-11 18:08:57 +08:00
268 lines
8.9 KiB
Go
268 lines
8.9 KiB
Go
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
|
|
}
|
|
|
|
// _escFS returns a http.Filesystem for the embedded assets. If useLocal is true,
|
|
// the filesystem's contents are instead used.
|
|
func _escFS(useLocal bool) http.FileSystem {
|
|
if useLocal {
|
|
return _escLocal
|
|
}
|
|
return _escStatic
|
|
}
|
|
|
|
// _escDir 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 _escDir(useLocal bool, name string) http.FileSystem {
|
|
if useLocal {
|
|
return _escDirectory{fs: _escLocal, name: name}
|
|
}
|
|
return _escDirectory{fs: _escStatic, name: name}
|
|
}
|
|
|
|
// _escFSByte returns the named file from the embedded assets. If useLocal is
|
|
// true, the filesystem's contents are instead used.
|
|
func _escFSByte(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
|
|
}
|
|
|
|
// _escFSMustByte is the same as _escFSByte, but panics if name is not present.
|
|
func _escFSMustByte(useLocal bool, name string) []byte {
|
|
b, err := _escFSByte(useLocal, name)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return b
|
|
}
|
|
|
|
// _escFSString is the string version of _escFSByte.
|
|
func _escFSString(useLocal bool, name string) (string, error) {
|
|
b, err := _escFSByte(useLocal, name)
|
|
return string(b), err
|
|
}
|
|
|
|
// _escFSMustString is the string version of _escFSMustByte.
|
|
func _escFSMustString(useLocal bool, name string) string {
|
|
return string(_escFSMustByte(useLocal, name))
|
|
}
|
|
|
|
var _escData = map[string]*_escFile{
|
|
|
|
"/helpers.js": {
|
|
local: "pkg/js/helpers.js",
|
|
size: 13505,
|
|
modtime: 0,
|
|
compressed: `
|
|
H4sIAAAAAAAA/+w6WXPbSHrv/BXfoJIhIMEgJY+1W6S5Ga6OLVV0FUU73mIYVYtokm3jSneDsuLQvz3V
|
|
F9C4JLtqtvYlfpCJ7q+/++rDyRkGxilZcWfc6+0QhVWarGEC33oAABRvCOMUUTaCxdKXY2HCHjKa7kiI
|
|
K8NpjEgiB3p7jSvEa5RHfEo3DCawWI57vXWerDhJEyAJ4QRF5H+w6yliFcpd1F/goM6F+N6PFXMNRvYW
|
|
Kzf4aWZIuQmKsc+fM+zHmCNPs0PW4IpBr2BPfMFkAs719ObD9MpRhPbyr5Cd4o0QRqAbgUQql4zkXx8E
|
|
8pH8q1kU0gelxEGWs61L8cYba0vwnCYSUYP5s4TdaXW4JSVFwxIAXClCupYTMJlMoJ8+fsYr3vfg11/B
|
|
7ZPsYZUmO0wZSRPWB5IoHJ5lFDEQVAFhAuuUxog/cO62zHs11YQs+3nVVIyutBOy7DXtJPjpTLqEUkyh
|
|
X69wcLmwwksBNCp/aq6+7cX0KqUhGy2WvvDEu9IRxaz2tPn8agRDX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