summaryrefslogtreecommitdiffstats
path: root/modules/options/static.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-06-03 05:43:47 +0800
committerLauris BH <lauris@nix.lv>2019-06-03 00:43:47 +0300
commit83b90e41999d30e4abb46f6bf0f1c3359cfd4d04 (patch)
tree4a15e9a42a850534a00346116da84153600a3027 /modules/options/static.go
parent8eba27c79257c6bc68cefbdffbb36d3596e6d3ee (diff)
downloadgitea-83b90e41999d30e4abb46f6bf0f1c3359cfd4d04.tar.gz
gitea-83b90e41999d30e4abb46f6bf0f1c3359cfd4d04.zip
Use vfsgen instead of go-bindata (#7080)
* use vfsgen instead of go-bindata * fix templates * fix fmt * vendor vsfgen
Diffstat (limited to 'modules/options/static.go')
-rw-r--r--modules/options/static.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/modules/options/static.go b/modules/options/static.go
index 3301f45171..629901f740 100644
--- a/modules/options/static.go
+++ b/modules/options/static.go
@@ -41,7 +41,7 @@ func Dir(name string) ([]string, error) {
result = append(result, files...)
}
- files, err := AssetDir(path.Join("..", "..", "options", name))
+ files, err := AssetDir(name)
if err != nil {
return []string{}, fmt.Errorf("Failed to read embedded directory. %v", err)
@@ -52,6 +52,24 @@ func Dir(name string) ([]string, error) {
return directories.AddAndGet(name, result), nil
}
+func AssetDir(dirName string) ([]string, error) {
+ d, err := Assets.Open(dirName)
+ if err != nil {
+ return nil, err
+ }
+ defer d.Close()
+
+ files, err := d.Readdir(-1)
+ if err != nil {
+ return nil, err
+ }
+ var results = make([]string, 0, len(files))
+ for _, file := range files {
+ results = append(results, file.Name())
+ }
+ return results, nil
+}
+
// Locale reads the content of a specific locale from bindata or custom path.
func Locale(name string) ([]byte, error) {
return fileFromDir(path.Join("locale", name))
@@ -85,5 +103,11 @@ func fileFromDir(name string) ([]byte, error) {
return ioutil.ReadFile(customPath)
}
- return Asset(name)
+ f, err := Assets.Open(name)
+ if err != nil {
+ return nil, err
+ }
+ defer f.Close()
+
+ return ioutil.ReadAll(f)
}