diff options
Diffstat (limited to 'modules/base')
-rw-r--r-- | modules/base/tool.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go index 16ac4dbff1..2dfd8ffec0 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -23,6 +23,7 @@ import ( "unicode" "unicode/utf8" + "code.gitea.io/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" @@ -559,3 +560,25 @@ func IsPDFFile(data []byte) bool { func IsVideoFile(data []byte) bool { return strings.Index(http.DetectContentType(data), "video/") != -1 } + +// EntryIcon returns the octicon class for displaying files/directories +func EntryIcon(entry *git.TreeEntry) string { + switch { + case entry.IsLink(): + te, err := entry.FollowLink() + if err != nil { + log.Debug(err.Error()) + return "file-symlink-file" + } + if te.IsDir() { + return "file-symlink-directory" + } + return "file-symlink-file" + case entry.IsDir(): + return "file-directory" + case entry.IsSubModule(): + return "file-submodule" + } + + return "file-text" +} |