gitea源码

basic.go 794B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2025 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package fileicon
  4. import (
  5. "html/template"
  6. "code.gitea.io/gitea/modules/svg"
  7. "code.gitea.io/gitea/modules/util"
  8. )
  9. func BasicEntryIconName(entry *EntryInfo) string {
  10. svgName := "octicon-file"
  11. switch {
  12. case entry.EntryMode.IsLink():
  13. svgName = "octicon-file-symlink-file"
  14. if entry.SymlinkToMode.IsDir() {
  15. svgName = "octicon-file-directory-symlink"
  16. }
  17. case entry.EntryMode.IsDir():
  18. svgName = util.Iif(entry.IsOpen, "octicon-file-directory-open-fill", "octicon-file-directory-fill")
  19. case entry.EntryMode.IsSubModule():
  20. svgName = "octicon-file-submodule"
  21. }
  22. return svgName
  23. }
  24. func BasicEntryIconHTML(entry *EntryInfo) template.HTML {
  25. return svg.RenderHTML(BasicEntryIconName(entry))
  26. }