templates.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. package main
  2. import (
  3. "bytes"
  4. "compress/gzip"
  5. "io/ioutil"
  6. "net/http"
  7. "os"
  8. "path"
  9. "sync"
  10. "time"
  11. )
  12. type _escLocalFS struct{}
  13. var _escLocal _escLocalFS
  14. type _escStaticFS struct{}
  15. var _escStatic _escStaticFS
  16. type _escFile struct {
  17. compressed string
  18. size int64
  19. local string
  20. isDir bool
  21. data []byte
  22. once sync.Once
  23. name string
  24. }
  25. func (_escLocalFS) Open(name string) (http.File, error) {
  26. f, present := _escData[path.Clean(name)]
  27. if !present {
  28. return nil, os.ErrNotExist
  29. }
  30. return os.Open(f.local)
  31. }
  32. func (_escStaticFS) prepare(name string) (*_escFile, error) {
  33. f, present := _escData[path.Clean(name)]
  34. if !present {
  35. return nil, os.ErrNotExist
  36. }
  37. var err error
  38. f.once.Do(func() {
  39. f.name = path.Base(name)
  40. if f.size == 0 {
  41. return
  42. }
  43. var gr *gzip.Reader
  44. gr, err = gzip.NewReader(bytes.NewBufferString(f.compressed))
  45. if err != nil {
  46. return
  47. }
  48. f.data, err = ioutil.ReadAll(gr)
  49. })
  50. if err != nil {
  51. return nil, err
  52. }
  53. return f, nil
  54. }
  55. func (fs _escStaticFS) Open(name string) (http.File, error) {
  56. f, err := fs.prepare(name)
  57. if err != nil {
  58. return nil, err
  59. }
  60. return f.File()
  61. }
  62. func (f *_escFile) File() (http.File, error) {
  63. type httpFile struct {
  64. *bytes.Reader
  65. *_escFile
  66. }
  67. return &httpFile{
  68. Reader: bytes.NewReader(f.data),
  69. _escFile: f,
  70. }, nil
  71. }
  72. func (f *_escFile) Close() error {
  73. return nil
  74. }
  75. func (f *_escFile) Readdir(count int) ([]os.FileInfo, error) {
  76. return nil, nil
  77. }
  78. func (f *_escFile) Stat() (os.FileInfo, error) {
  79. return f, nil
  80. }
  81. func (f *_escFile) Name() string {
  82. return f.name
  83. }
  84. func (f *_escFile) Size() int64 {
  85. return f.size
  86. }
  87. func (f *_escFile) Mode() os.FileMode {
  88. return 0
  89. }
  90. func (f *_escFile) ModTime() time.Time {
  91. return time.Time{}
  92. }
  93. func (f *_escFile) IsDir() bool {
  94. return f.isDir
  95. }
  96. func (f *_escFile) Sys() interface{} {
  97. return f
  98. }
  99. // FS returns a http.Filesystem for the embedded assets. If useLocal is true,
  100. // the filesystem's contents are instead used.
  101. func FS(useLocal bool) http.FileSystem {
  102. if useLocal {
  103. return _escLocal
  104. }
  105. return _escStatic
  106. }
  107. // FSByte returns the named file from the embedded assets. If useLocal is
  108. // true, the filesystem's contents are instead used.
  109. func FSByte(useLocal bool, name string) ([]byte, error) {
  110. if useLocal {
  111. f, err := _escLocal.Open(name)
  112. if err != nil {
  113. return nil, err
  114. }
  115. return ioutil.ReadAll(f)
  116. }
  117. f, err := _escStatic.prepare(name)
  118. if err != nil {
  119. return nil, err
  120. }
  121. return f.data, nil
  122. }
  123. // FSMustByte is the same as FSByte, but panics if name is not present.
  124. func FSMustByte(useLocal bool, name string) []byte {
  125. b, err := FSByte(useLocal, name)
  126. if err != nil {
  127. panic(err)
  128. }
  129. return b
  130. }
  131. // FSString is the string version of FSByte.
  132. func FSString(useLocal bool, name string) (string, error) {
  133. b, err := FSByte(useLocal, name)
  134. return string(b), err
  135. }
  136. // FSMustString is the string version of FSMustByte.
  137. func FSMustString(useLocal bool, name string) string {
  138. return string(FSMustByte(useLocal, name))
  139. }
  140. var _escData = map[string]*_escFile{
  141. "/templates/status.html": {
  142. local: "templates/status.html",
  143. size: 3181,
  144. compressed: "" +
  145. "\x1f\x8b\b\x00\x00\tn\x88\x00\xff\xb4WMS\xeb6\x14]'\xbfB\xe3)\xbb\"\x13Jf\x1a\xeax\x03\f]4\x14\x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\xf6\xb9羽c\x01\xee\x11R\xa6\xb8\x94FQ̩u\xa9\x90\xeaU9\x91\xf5\x18\x99\xd1\x05\xe9\xc6\x1bu\xe5\x1d%\xbe\x95\x13\xf6\xf2\xf1ݲb\x91\x03\xb3\xd6\xdd\x1a\xf8ؑ\xda:\xd3\xd5Ou\xa6\xc2\x10\x15+\x17.\xfeo" +
  150. "e\x92%\xec\x0f\xe5\xc4\xd0\f\xa5\xb7\xecujP\xd8b\u007f\xec\xf2'\xf6v\xc8ǔ\x99\xb9T\xcbf\xd0\x02o\tv\x98\x81\xf2\x89\xcd\xfb\v\xde\x0f:k\xe3\x9d\x12\xe0\xce\x1a\x988\xc4}\xe2l\xe4\xfa\xed\xda\xc0\x1e\x19戮,j\xc1\xac\xb7\xc9\xd3\xe34G\xb2\x1a\xe2\xc5\xfd\x8b\x91\xab\xbf1kxu_\x8f\t\xfd\xb7x\xdb\xed" +
  151. "\xec\xb4bb\x01\xe8%\xa7\x84X\xcc&\xb0\xdaV\xf2:a2ej\v>\x1e\x16\xb3\xc5\xed\xe8\xd9\x1c>\xe0\xa0\xcc_ᠠ(\xc9A\xa7o\xf5\xe6\x04\xb0\xa6\x91~\xabџ\xcc\x19v\xe0\f\xba\x90j\xfd\xa4E\xf4\x9d\xfdx\xfa\x88\xf2;.t\x17\xf5Mީb\x0e\xf6\xebJl̈́u_$\xd7\xc2hg\xbd\x82\xfb\x17\x9b" +
  152. "A:\xb5\x9f\x1a֍7ق\x8aM\x9d\v\x91\x9b\xccK:B\xbdVc֝\x19\xbaк\xf9+.l^\x8bָG\xf3\x10W\xd6\xcb.J\xae&o\x11\xee\x94-\x17\xfav\v\x82\xdbx\xc5 W\x9d&Д}\xe3\xb0Su\xe7\x01N\x15\x9e\x05?\xa2\xbc\x1aﳤ\xf7\xcbѾo\xee\xdbf\xf6a\x8c\xdd\xd2\xfe\x97\xd1" +
  153. "\xff\x11\x00\x00\xff\xff\xb0\x9dR\xc9m\f\x00\x00",
  154. },
  155. "/": {
  156. isDir: true,
  157. local: "/",
  158. },
  159. "/templates": {
  160. isDir: true,
  161. local: "/templates",
  162. },
  163. }