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
// 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.
package assettemplates
import (
"bytes"
"compress/gzip"
"io/ioutil"
"os"
"strings"
"bytes"
"compress/gzip"
"io/ioutil"
"os"
"strings"
)
func Asset(path string) ([]byte, error) {
body, ok := _rawAssets[path]
if !ok {
return nil, os.ErrNotExist
}
return decompress(body)
body, ok := _rawAssets[path]
if !ok {
return nil, os.ErrNotExist
}
return decompress(body)
}
func AssetDir(dir string) (map[string][]byte, error) {
var e error
files := make(map[string][]byte)
for path, body := range _rawAssets {
if strings.HasPrefix(path, dir) {
files[path], e = decompress(body)
if e != nil {
return nil, e
}
}
}
return files, nil
var e error
files := make(map[string][]byte)
for path, body := range _rawAssets {
if strings.HasPrefix(path, dir) {
files[path], e = decompress(body)
if e != nil {
return nil, e
}
}
}
return files, nil
}
func decompress(data []byte) ([]byte, error) {
buf := bytes.NewBuffer(data)
gr, e := gzip.NewReader(buf)
if e != nil {
return nil, e
}
defer gr.Close()
return ioutil.ReadAll(gr)
buf := bytes.NewBuffer(data)
gr, e := gzip.NewReader(buf)
if e != nil {
return nil, e
}
defer gr.Close()
return ioutil.ReadAll(gr)
}
var _rawAssets = map[string][]byte{

View File

@ -1,13 +1,13 @@
// +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.
package assettemplates
import (
"io/ioutil"
"path/filepath"
"io/ioutil"
"path/filepath"
)
func Asset(path string) ([]byte, error) {
@ -15,19 +15,34 @@ func Asset(path string) ([]byte, error) {
}
func AssetDir(dir string) (map[string][]byte, error) {
tmp, e := ioutil.ReadDir(dir)
if e != nil {
return nil, e
}
list := make(map[string][]byte)
dirs := []string{dir}
files := make(map[string][]byte)
for _, f := range tmp {
name := filepath.Join(dir, f.Name())
body, e := ioutil.ReadFile(name)
if e != nil {
return nil, e
}
files[name] = body
}
return files, nil
for len(dirs) > 0 {
d := dirs[0]
dirs = dirs[1:]
files, e := ioutil.ReadDir(d)
if e != nil {
return nil, e
}
for _, f := range files {
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
}