Skip to content

Commit 2d644fb

Browse files
committed
make template simpler
1 parent 20198ea commit 2d644fb

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

templates/repo/home.tmpl

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
{{template "base/head" .}}
2-
{{$treeNamesLen := len .TreeNames}}
3-
{{$isTreePathRoot := eq $treeNamesLen 0}}
4-
{{$showSidebar := and $isTreePathRoot (not .HideRepoInfo) (not .IsBlame)}}
5-
{{$hasTreeSidebar := not $isTreePathRoot}}
6-
{{$showTreeSidebar := .RepoPreferences.ShowFileViewTreeSidebar}}
7-
{{$hideTreeSidebar := not $showTreeSidebar}}
2+
{{$showSidebar := and (not .TreeNames) (not .HideRepoInfo) (not .IsBlame)}}
83
<div role="main" aria-label="{{.Title}}" class="page-content repository file list {{if .IsBlame}}blame{{end}}">
94
{{template "repo/header" .}}
10-
<div class="ui container {{if or $hasTreeSidebar .IsBlame}}fluid padded{{end}}">
5+
<div class="ui container {{if or .TreeNames .IsBlame}}fluid padded{{end}}">
116
{{template "base/alert" .}}
127

138
{{if .Repository.IsArchived}}
@@ -22,9 +17,9 @@
2217

2318
{{template "repo/code/recently_pushed_new_branches" .}}
2419

25-
<div class="{{Iif $showSidebar "repo-grid-filelist-sidebar" (Iif $showTreeSidebar "repo-grid-tree-sidebar" "repo-grid-filelist-only")}}">
26-
{{if $hasTreeSidebar}}
27-
<div class="repo-view-file-tree-sidebar not-mobile {{if $hideTreeSidebar}}tw-hidden{{end}}" {{if .IsSigned}} data-is-signed {{end}}>{{template "repo/view_file_tree_sidebar" .}}</div>
20+
<div class="{{Iif $showSidebar "repo-grid-filelist-sidebar" (Iif .RepoPreferences.ShowFileViewTreeSidebar "repo-grid-tree-sidebar" "repo-grid-filelist-only")}}">
21+
{{if .TreeNames}}
22+
<div class="repo-view-file-tree-sidebar not-mobile {{if not .RepoPreferences.ShowFileViewTreeSidebar}}tw-hidden{{end}}" {{if .IsSigned}} data-is-signed {{end}}>{{template "repo/view_file_tree_sidebar" .}}</div>
2823
{{end}}
2924

3025
<div class="repo-home-filelist">

templates/repo/home_content.tmpl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
{{$treeNamesLen := len .TreeNames}}
2-
{{$isTreePathRoot := eq $treeNamesLen 0}}
1+
{{$isTreePathRoot := not .TreeNames}}
32
{{$showSidebar := and $isTreePathRoot (not .HideRepoInfo) (not .IsBlame)}}
4-
{{$hasTreeSidebar := not $isTreePathRoot}}
5-
{{$showTreeSidebar := .RepoPreferences.ShowFileViewTreeSidebar}}
63

74
{{template "repo/sub_menu" .}}
85
<div class="repo-button-row">
96
<div class="repo-button-row-left">
10-
{{if $hasTreeSidebar}}
11-
<button class="show-tree-sidebar-button ui compact basic button icon not-mobile {{if $showTreeSidebar}}tw-hidden{{end}}" title="{{ctx.Locale.Tr "repo.diff.show_file_tree"}}">
7+
{{if not $isTreePathRoot}}
8+
<button class="show-tree-sidebar-button ui compact basic button icon not-mobile {{if .RepoPreferences.ShowFileViewTreeSidebar}}tw-hidden{{end}}" title="{{ctx.Locale.Tr "repo.diff.show_file_tree"}}">
129
{{svg "octicon-sidebar-collapse" 20 "icon"}}
1310
</button>
1411
{{end}}
@@ -58,7 +55,7 @@
5855
{{end}}
5956

6057
{{if not $isTreePathRoot}}
61-
{{$treeNameIdxLast := Eval $treeNamesLen "-" 1}}
58+
{{$treeNameIdxLast := Eval (len .TreeNames) "-" 1}}
6259
<span class="breadcrumb repo-path tw-ml-1">
6360
<a class="section" href="{{.RepoLink}}/src/{{.RefTypeNameSubURL}}" title="{{.Repository.Name}}">{{StringUtils.EllipsisString .Repository.Name 30}}</a>
6461
{{- range $i, $v := .TreeNames -}}

0 commit comments

Comments
 (0)