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 736B

12345678910111213141516171819202122232425262728293031
  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. // +build !bindata
  6. package svg
  7. import (
  8. "io/ioutil"
  9. "path/filepath"
  10. "code.gitea.io/gitea/modules/setting"
  11. )
  12. // Discover returns a map of discovered SVG icons in the file system
  13. func Discover() map[string]string {
  14. svgs := make(map[string]string)
  15. files, _ := filepath.Glob(filepath.Join(setting.StaticRootPath, "public", "img", "svg", "*.svg"))
  16. for _, file := range files {
  17. content, err := ioutil.ReadFile(file)
  18. if err == nil {
  19. filename := filepath.Base(file)
  20. svgs[filename[:len(filename)-4]] = string(content)
  21. }
  22. }
  23. return svgs
  24. }