]> source.dussan.org Git - gitea.git/commitdiff
Implementation of Folder Jumping
authorSl@ny <webmaster@slany.work>
Wed, 28 Dec 2016 16:35:52 +0000 (17:35 +0100)
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>
Wed, 28 Dec 2016 17:09:52 +0000 (18:09 +0100)
modules/templates/helper.go
public/css/index.css
public/less/_repository.less
templates/repo/view_list.tmpl
vendor/code.gitea.io/git/tree_entry.go
vendor/vendor.json

index c2564553992b069548ec85247f31abbbdf4d0658..f65b8c6856c91bfa066557747f182913a9829f1d 100644 (file)
@@ -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
+               },
        }}
 }
 
index a05802118fcfb33d4070a9c424b2e5deb5204177..d64c71ca2a94b755e570a893fba7eeffb9b41068 100644 (file)
@@ -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;
index 07274880fd46b38e5655c8034511785929f59be3..259aa2639979920c0f4229ba77b11e6d99ee91a6 100644 (file)
                        tr:hover {
                                background-color: #ffffEE;
                        }
+            .jumpable-path {
+                color: #888;
+            }
                }
 
                #file-content {
index f1cbf58a4a6fbb0fe3ddb7376e55ba7b04d3d5bc..82167de64ab268a9f039b61b22dcf36055948fb2 100644 (file)
                                        </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">
index 17543167313cc22b91500e2394894f1d1a16c511..3f68d9868ee8986258b7d1a862d10d4c0f32f3fa 100644 (file)
@@ -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
 
index b440e48fbbe5a5f6f826f57baa811ea12db0d3e5..4382892eddfa8b596a4c44aa58715b0e9ec76fba 100644 (file)
@@ -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=",