Files
Atay-Makhzan/modules/svg/discover_nobindata.go
T

30 lines
634 B
Go
Raw Normal View History

2020-07-12 11:10:56 +02:00
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
2020-07-12 11:10:56 +02:00
2021-08-24 11:47:09 -05:00
//go:build !bindata
2020-07-12 11:10:56 +02:00
package svg
import (
"os"
2020-07-12 11:10:56 +02:00
"path/filepath"
"code.gitea.io/gitea/modules/setting"
)
// Discover returns a map of discovered SVG icons in the file system
func Discover() map[string]string {
svgs := make(map[string]string)
files, _ := filepath.Glob(filepath.Join(setting.StaticRootPath, "public", "img", "svg", "*.svg"))
2020-07-12 11:10:56 +02:00
for _, file := range files {
content, err := os.ReadFile(file)
2020-07-12 11:10:56 +02:00
if err == nil {
filename := filepath.Base(file)
2020-07-12 11:10:56 +02:00
svgs[filename[:len(filename)-4]] = string(content)
}
}
return svgs
}