diff options
author | Sl@ny <webmaster@slany.work> | 2016-12-28 17:35:52 +0100 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2016-12-28 18:09:52 +0100 |
commit | c22f9114c7e0874e99fd1504131423517905c9c1 (patch) | |
tree | ed70854ca628597d961fbf44acf61f1c9f8e6f16 | |
parent | 331316894e391beb29fdebf9d8088973759bba1c (diff) | |
download | gitea-c22f9114c7e0874e99fd1504131423517905c9c1.tar.gz gitea-c22f9114c7e0874e99fd1504131423517905c9c1.zip |
Implementation of Folder Jumping
-rw-r--r-- | modules/templates/helper.go | 11 | ||||
-rw-r--r-- | public/css/index.css | 3 | ||||
-rw-r--r-- | public/less/_repository.less | 3 | ||||
-rw-r--r-- | templates/repo/view_list.tmpl | 17 | ||||
-rw-r--r-- | vendor/code.gitea.io/git/tree_entry.go | 19 | ||||
-rw-r--r-- | vendor/vendor.json | 6 |
6 files changed, 54 insertions, 5 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go index c256455399..f65b8c6856 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -117,6 +117,17 @@ func NewFuncMap() []template.FuncMap { } return "tab-size-8" }, + "SubJumpablePath": func(str string) []string { + var path []string + index := strings.LastIndex(str, "/") + if index != -1 && index != len(str) { + path = append(path, string(str[0:index+1])) + path = append(path, string(str[index+1:])) + } else { + path = append(path, str) + } + return path + }, }} } diff --git a/public/css/index.css b/public/css/index.css index a05802118f..d64c71ca2a 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -1272,6 +1272,9 @@ footer .ui.language .menu { .repository.file.list #repo-files-table tr:hover { background-color: #ffffEE; } +.repository.file.list #repo-files-table .jumpable-path { + color: #888; +} .repository.file.list #file-content .header .icon { font-size: 1em; margin-top: -2px; diff --git a/public/less/_repository.less b/public/less/_repository.less index 07274880fd..259aa26399 100644 --- a/public/less/_repository.less +++ b/public/less/_repository.less @@ -205,6 +205,9 @@ tr:hover { background-color: #ffffEE; } + .jumpable-path { + color: #888; + } } #file-content { diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index f1cbf58a4a..82167de64a 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -43,8 +43,21 @@ </td> {{else}} <td class="name"> - <span class="octicon octicon-file-{{if or $entry.IsDir}}directory{{else}}text{{end}}"></span> - <a href="{{EscapePound $.TreeLink}}/{{EscapePound $entry.Name}}">{{$entry.Name}}</a> + {{if $entry.IsDir}} + {{$subJumpablePathName := $entry.GetSubJumpablePathName}} + {{$subJumpablePath := SubJumpablePath $subJumpablePathName}} + <span class="octicon octicon-file-directory"></span> + <a href="{{EscapePound $.TreeLink}}/{{EscapePound $subJumpablePathName}}"> + {{if eq (len $subJumpablePath) 2}} + <span class="jumpable-path">{{index $subJumpablePath 0}}</span>{{index $subJumpablePath 1}} + {{else}} + {{index $subJumpablePath 0}} + {{end}} + </a> + {{else}} + <span class="octicon octicon-file-text"></span> + <a href="{{EscapePound $.TreeLink}}/{{EscapePound $entry.Name}}">{{$entry.Name}}</a> + {{end}} </td> {{end}} <td class="message collapsing has-emoji"> diff --git a/vendor/code.gitea.io/git/tree_entry.go b/vendor/code.gitea.io/git/tree_entry.go index 1754316731..3f68d9868e 100644 --- a/vendor/code.gitea.io/git/tree_entry.go +++ b/vendor/code.gitea.io/git/tree_entry.go @@ -94,6 +94,25 @@ func (te *TreeEntry) Blob() *Blob { } } +// GetSubJumpablePathName return the full path of subdirectory jumpable ( contains only one directory ) +func (te *TreeEntry) GetSubJumpablePathName() string { + if te.IsSubModule() || !te.IsDir() { + return "" + } + tree, err := te.ptree.SubTree(te.name) + if err != nil { + return te.name + } + entries, _ := tree.ListEntries() + if len(entries) == 1 && entries[0].IsDir() { + name := entries[0].GetSubJumpablePathName() + if name != "" { + return te.name + "/" + name + } + } + return te.name +} + // Entries a list of entry type Entries []*TreeEntry diff --git a/vendor/vendor.json b/vendor/vendor.json index b440e48fbb..4382892edd 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -3,10 +3,10 @@ "ignore": "test", "package": [ { - "checksumSHA1": "OWuUWQ8sWC8n+eTQttx+3vfES8g=", + "checksumSHA1": "mIaKLz6373W+jDLjgE/Yzt/exeo=", "path": "code.gitea.io/git", - "revision": "634abd6a61c350a95f6b146c3a5fc323282608ae", - "revisionTime": "2016-12-22T08:49:21Z" + "revision": "3d0fa331865619d2f3a7a0fcf23670a389310954", + "revisionTime": "2016-12-28T14:57:51Z" }, { "checksumSHA1": "dnGaLR7sd9D5YpQZP4QUGZiEq+c=", |