aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorTris Forster <tris.git@tfconsulting.com.au>2018-05-01 17:04:36 +1000
committerLauris BH <lauris@nix.lv>2018-05-01 10:04:36 +0300
commit85d14cc229263c5788cac9370ac60e9582f9de6c (patch)
treecd8b7d9505335f86eddfdd3379afb21f414c00c0 /modules
parent1928920a08e038e1ec0f631b2f84f5610638209f (diff)
downloadgitea-85d14cc229263c5788cac9370ac60e9582f9de6c.tar.gz
gitea-85d14cc229263c5788cac9370ac60e9582f9de6c.zip
Symlink icons (#1416) (#3826)
* Updated vendor code for code.gitea.io/git * Display symlinks correctly for files and directories * Added symlink tests * Applied silverwinds stylesheet patch Signed-off-by: Tris Forster <tris.git@shoddynet.org>
Diffstat (limited to 'modules')
-rw-r--r--modules/base/tool.go23
-rw-r--r--modules/templates/helper.go1
2 files changed, 24 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"
+}
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 8dfa6dec8a..74e775cc63 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -75,6 +75,7 @@ func NewFuncMap() []template.FuncMap {
"RawTimeSince": base.RawTimeSince,
"FileSize": base.FileSize,
"Subtract": base.Subtract,
+ "EntryIcon": base.EntryIcon,
"Add": func(a, b int) int {
return a + b
},