Update template assets.

This commit is contained in:
A. Svensson 2016-05-03 18:47:15 +02:00
parent 46e47c4ef7
commit b740896359
2 changed files with 61 additions and 46 deletions

View File

@ -1,48 +1,48 @@
// +build embed // +build embed
// Automagically generated by yaber v0.1 (https://github.com/lmas/yaber), // Automagically generated by yaber v0.2 (https://github.com/lmas/yaber),
// please avoid editting this file as it might be regenerated again. // please avoid editting this file as it might be regenerated again.
package assettemplates package assettemplates
import ( import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"io/ioutil" "io/ioutil"
"os" "os"
"strings" "strings"
) )
func Asset(path string) ([]byte, error) { func Asset(path string) ([]byte, error) {
body, ok := _rawAssets[path] body, ok := _rawAssets[path]
if !ok { if !ok {
return nil, os.ErrNotExist return nil, os.ErrNotExist
} }
return decompress(body) return decompress(body)
} }
func AssetDir(dir string) (map[string][]byte, error) { func AssetDir(dir string) (map[string][]byte, error) {
var e error var e error
files := make(map[string][]byte) files := make(map[string][]byte)
for path, body := range _rawAssets { for path, body := range _rawAssets {
if strings.HasPrefix(path, dir) { if strings.HasPrefix(path, dir) {
files[path], e = decompress(body) files[path], e = decompress(body)
if e != nil { if e != nil {
return nil, e return nil, e
} }
} }
} }
return files, nil return files, nil
} }
func decompress(data []byte) ([]byte, error) { func decompress(data []byte) ([]byte, error) {
buf := bytes.NewBuffer(data) buf := bytes.NewBuffer(data)
gr, e := gzip.NewReader(buf) gr, e := gzip.NewReader(buf)
if e != nil { if e != nil {
return nil, e return nil, e
} }
defer gr.Close() defer gr.Close()
return ioutil.ReadAll(gr) return ioutil.ReadAll(gr)
} }
var _rawAssets = map[string][]byte{ var _rawAssets = map[string][]byte{

View File

@ -1,13 +1,13 @@
// +build !embed // +build !embed
// Automagically generated by yaber v0.1 (https://github.com/lmas/yaber), // Automagically generated by yaber v0.2 (https://github.com/lmas/yaber),
// please avoid editting this file as it might be regenerated again. // please avoid editting this file as it might be regenerated again.
package assettemplates package assettemplates
import ( import (
"io/ioutil" "io/ioutil"
"path/filepath" "path/filepath"
) )
func Asset(path string) ([]byte, error) { func Asset(path string) ([]byte, error) {
@ -15,19 +15,34 @@ func Asset(path string) ([]byte, error) {
} }
func AssetDir(dir string) (map[string][]byte, error) { func AssetDir(dir string) (map[string][]byte, error) {
tmp, e := ioutil.ReadDir(dir) list := make(map[string][]byte)
if e != nil { dirs := []string{dir}
return nil, e
}
files := make(map[string][]byte) for len(dirs) > 0 {
for _, f := range tmp { d := dirs[0]
name := filepath.Join(dir, f.Name()) dirs = dirs[1:]
body, e := ioutil.ReadFile(name) files, e := ioutil.ReadDir(d)
if e != nil { if e != nil {
return nil, e return nil, e
} }
files[name] = body
} for _, f := range files {
return files, nil fpath := filepath.Join(d, f.Name())
if f.IsDir() {
dirs = append(dirs, fpath)
continue
}
if !f.Mode().IsRegular() {
continue
}
fbody, e := ioutil.ReadFile(fpath)
if e != nil {
return nil, e
}
list[fpath] = fbody
}
}
return list, nil
} }