You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

discover_nobindata.go 706B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. //go:build !bindata
  5. package svg
  6. import (
  7. "os"
  8. "path/filepath"
  9. "code.gitea.io/gitea/modules/setting"
  10. )
  11. // Discover returns a map of discovered SVG icons in the file system
  12. func Discover() map[string]string {
  13. svgs := make(map[string]string)
  14. files, _ := filepath.Glob(filepath.Join(setting.StaticRootPath, "public", "img", "svg", "*.svg"))
  15. for _, file := range files {
  16. content, err := os.ReadFile(file)
  17. if err == nil {
  18. filename := filepath.Base(file)
  19. svgs[filename[:len(filename)-4]] = string(content)
  20. }
  21. }
  22. return svgs
  23. }