-
Notifications
You must be signed in to change notification settings - Fork 8
/
templates.go
237 lines (212 loc) · 7.04 KB
/
templates.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
// Code generated by go-bindata.
// sources:
// templates/info.html
// DO NOT EDIT!
package main
import (
"bytes"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
)
func bindataRead(data []byte, name string) ([]byte, error) {
gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil {
return nil, fmt.Errorf("Read %q: %v", name, err)
}
var buf bytes.Buffer
_, err = io.Copy(&buf, gz)
clErr := gz.Close()
if err != nil {
return nil, fmt.Errorf("Read %q: %v", name, err)
}
if clErr != nil {
return nil, err
}
return buf.Bytes(), nil
}
type asset struct {
bytes []byte
info os.FileInfo
}
type bindataFileInfo struct {
name string
size int64
mode os.FileMode
modTime time.Time
}
func (fi bindataFileInfo) Name() string {
return fi.name
}
func (fi bindataFileInfo) Size() int64 {
return fi.size
}
func (fi bindataFileInfo) Mode() os.FileMode {
return fi.mode
}
func (fi bindataFileInfo) ModTime() time.Time {
return fi.modTime
}
func (fi bindataFileInfo) IsDir() bool {
return false
}
func (fi bindataFileInfo) Sys() interface{} {
return nil
}
var _templatesInfoHtml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x7c\x92\x41\x6f\xd4\x30\x10\x85\xcf\xf8\x57\x8c\x44\x91\x40\xda\xac\x9b\x9e\x90\x6b\x2c\x55\x94\x43\x2b\xb8\xd0\xfe\x01\x6f\x3c\x89\x2d\x1c\x3b\xd8\xb3\xcb\x56\x91\xff\x3b\x4a\x9c\x42\x11\x82\x5c\x92\xcc\x7b\xfe\xf4\xe6\xc9\xd2\xd2\xe8\x15\x93\x16\xb5\xc1\xa4\x98\xcc\xf4\xe4\x51\x31\xd2\x07\x8f\x30\x33\x00\x80\x3e\x06\x6a\x7a\x3d\x3a\xff\x24\x40\x27\xa7\xfd\x0e\xb2\x0e\xb9\xc9\x98\x5c\x7f\xbd\x7a\x0e\x31\x19\x4c\x4d\x17\xbd\xd7\x53\x46\x01\xcf\x5f\x55\xfe\xe1\x0c\x59\x01\xed\xe5\xe5\x9b\x6b\x56\x18\x23\xb3\x03\xb2\x1b\xbf\x9e\x15\xd0\x4e\x67\xc8\xd1\x3b\x03\xaf\xcd\xfa\xd4\xb3\x84\x67\x6a\xb4\x77\x43\x10\xe0\xb1\xa7\x3a\x9d\xb4\x31\x2e\x0c\x02\xda\xf7\xd3\xb9\x32\x93\x08\x64\x9b\xce\x3a\x6f\xde\xe2\x09\xc3\xbb\x67\xbe\xee\xbe\x0d\x29\x1e\x83\x59\xf2\xc5\x24\x7e\xf3\x0b\x93\x7c\xdb\x58\xda\x56\x3d\x7e\x7c\x68\x1e\x3a\xed\x31\xc1\x5d\xe8\xa3\xe4\xb6\x55\x4c\xf2\x5f\xe5\xd8\x2b\xf5\x59\x67\x82\x79\xde\x2f\xfa\xa3\x1b\xb1\x14\xf8\xe2\xc2\x91\x30\x43\xc2\xef\x47\xcc\x04\x09\x3b\x87\x27\x34\x42\x72\x7b\xa5\x98\x5c\xbb\x5c\xde\x49\xb1\x57\x92\xac\xba\x8f\x87\xbb\x5b\xc9\xc9\x6e\xff\x5f\x71\x70\x31\xbc\x18\xdc\x78\x4c\x14\xf4\x88\x7f\x98\x2a\x15\x6e\xa8\x4e\x25\x5f\x80\x2b\x75\x9e\x21\xe9\x30\x20\x5c\xb8\x1d\x5c\xe4\x65\x83\x4f\x27\x0c\x04\xe2\x03\xec\x97\xc4\xf7\xf1\x90\xa1\x94\xb5\x0e\x49\x46\xcd\xf3\x0b\xd7\x7e\xcd\x53\x8a\xe4\x64\xd4\xdf\x6a\x4d\xf7\x4f\xf9\xd6\x25\xec\xe8\x7f\x8e\x5a\x53\x15\x79\x8d\x8b\xc1\x94\xc2\x96\x15\xb6\x6e\x78\xbd\x87\xac\xfc\x0c\x00\x00\xff\xff\xd5\xef\x0a\x26\x91\x02\x00\x00")
func templatesInfoHtmlBytes() ([]byte, error) {
return bindataRead(
_templatesInfoHtml,
"templates/info.html",
)
}
func templatesInfoHtml() (*asset, error) {
bytes, err := templatesInfoHtmlBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "templates/info.html", size: 657, mode: os.FileMode(420), modTime: time.Unix(1566292097, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
// Asset loads and returns the asset for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func Asset(name string) ([]byte, error) {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
}
return a.bytes, nil
}
return nil, fmt.Errorf("Asset %s not found", name)
}
// MustAsset is like Asset but panics when Asset would return an error.
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
a, err := Asset(name)
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
return a
}
// AssetInfo loads and returns the asset info for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func AssetInfo(name string) (os.FileInfo, error) {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
}
return a.info, nil
}
return nil, fmt.Errorf("AssetInfo %s not found", name)
}
// AssetNames returns the names of the assets.
func AssetNames() []string {
names := make([]string, 0, len(_bindata))
for name := range _bindata {
names = append(names, name)
}
return names
}
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){
"templates/info.html": templatesInfoHtml,
}
// AssetDir returns the file names below a certain
// directory embedded in the file by go-bindata.
// For example if you run go-bindata on data/... and data contains the
// following hierarchy:
// data/
// foo.txt
// img/
// a.png
// b.png
// then AssetDir("data") would return []string{"foo.txt", "img"}
// AssetDir("data/img") would return []string{"a.png", "b.png"}
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
// AssetDir("") will return []string{"data"}.
func AssetDir(name string) ([]string, error) {
node := _bintree
if len(name) != 0 {
cannonicalName := strings.Replace(name, "\\", "/", -1)
pathList := strings.Split(cannonicalName, "/")
for _, p := range pathList {
node = node.Children[p]
if node == nil {
return nil, fmt.Errorf("Asset %s not found", name)
}
}
}
if node.Func != nil {
return nil, fmt.Errorf("Asset %s not found", name)
}
rv := make([]string, 0, len(node.Children))
for childName := range node.Children {
rv = append(rv, childName)
}
return rv, nil
}
type bintree struct {
Func func() (*asset, error)
Children map[string]*bintree
}
var _bintree = &bintree{nil, map[string]*bintree{
"templates": &bintree{nil, map[string]*bintree{
"info.html": &bintree{templatesInfoHtml, map[string]*bintree{}},
}},
}}
// RestoreAsset restores an asset under the given directory
func RestoreAsset(dir, name string) error {
data, err := Asset(name)
if err != nil {
return err
}
info, err := AssetInfo(name)
if err != nil {
return err
}
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil {
return err
}
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
if err != nil {
return err
}
return nil
}
// RestoreAssets restores an asset under the given directory recursively
func RestoreAssets(dir, name string) error {
children, err := AssetDir(name)
// File
if err != nil {
return RestoreAsset(dir, name)
}
// Dir
for _, child := range children {
err = RestoreAssets(dir, filepath.Join(name, child))
if err != nil {
return err
}
}
return nil
}
func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
}