} | } | ||||
return "tab-size-8" | 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 | |||||
}, | |||||
}} | }} | ||||
} | } | ||||
.repository.file.list #repo-files-table tr:hover { | .repository.file.list #repo-files-table tr:hover { | ||||
background-color: #ffffEE; | background-color: #ffffEE; | ||||
} | } | ||||
.repository.file.list #repo-files-table .jumpable-path { | |||||
color: #888; | |||||
} | |||||
.repository.file.list #file-content .header .icon { | .repository.file.list #file-content .header .icon { | ||||
font-size: 1em; | font-size: 1em; | ||||
margin-top: -2px; | margin-top: -2px; |
tr:hover { | tr:hover { | ||||
background-color: #ffffEE; | background-color: #ffffEE; | ||||
} | } | ||||
.jumpable-path { | |||||
color: #888; | |||||
} | |||||
} | } | ||||
#file-content { | #file-content { |
</td> | </td> | ||||
{{else}} | {{else}} | ||||
<td class="name"> | <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> | </td> | ||||
{{end}} | {{end}} | ||||
<td class="message collapsing has-emoji"> | <td class="message collapsing has-emoji"> |
} | } | ||||
} | } | ||||
// 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 | // Entries a list of entry | ||||
type Entries []*TreeEntry | type Entries []*TreeEntry | ||||
"ignore": "test", | "ignore": "test", | ||||
"package": [ | "package": [ | ||||
{ | { | ||||
"checksumSHA1": "OWuUWQ8sWC8n+eTQttx+3vfES8g=", | |||||
"checksumSHA1": "mIaKLz6373W+jDLjgE/Yzt/exeo=", | |||||
"path": "code.gitea.io/git", | "path": "code.gitea.io/git", | ||||
"revision": "634abd6a61c350a95f6b146c3a5fc323282608ae", | |||||
"revisionTime": "2016-12-22T08:49:21Z" | |||||
"revision": "3d0fa331865619d2f3a7a0fcf23670a389310954", | |||||
"revisionTime": "2016-12-28T14:57:51Z" | |||||
}, | }, | ||||
{ | { | ||||
"checksumSHA1": "dnGaLR7sd9D5YpQZP4QUGZiEq+c=", | "checksumSHA1": "dnGaLR7sd9D5YpQZP4QUGZiEq+c=", |