Files
Atay-Makhzan/modules/fileicon/basic.go
T

32 lines
794 B
Go
Raw Normal View History

2025-03-10 15:57:17 +08:00
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package fileicon
import (
"html/template"
"code.gitea.io/gitea/modules/svg"
2025-04-29 10:51:32 +08:00
"code.gitea.io/gitea/modules/util"
2025-03-10 15:57:17 +08:00
)
2025-04-29 10:51:32 +08:00
func BasicEntryIconName(entry *EntryInfo) string {
2025-03-10 15:57:17 +08:00
svgName := "octicon-file"
switch {
2025-04-29 10:51:32 +08:00
case entry.EntryMode.IsLink():
2025-03-10 15:57:17 +08:00
svgName = "octicon-file-symlink-file"
2025-04-29 10:51:32 +08:00
if entry.SymlinkToMode.IsDir() {
2025-03-10 15:57:17 +08:00
svgName = "octicon-file-directory-symlink"
}
2025-04-29 10:51:32 +08:00
case entry.EntryMode.IsDir():
svgName = util.Iif(entry.IsOpen, "octicon-file-directory-open-fill", "octicon-file-directory-fill")
case entry.EntryMode.IsSubModule():
2025-03-10 15:57:17 +08:00
svgName = "octicon-file-submodule"
}
2025-04-29 10:51:32 +08:00
return svgName
}
func BasicEntryIconHTML(entry *EntryInfo) template.HTML {
return svg.RenderHTML(BasicEntryIconName(entry))
2025-03-10 15:57:17 +08:00
}