Skip to content

Commit

Permalink
make template simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Jan 15, 2025
1 parent 20198ea commit 2d644fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
15 changes: 5 additions & 10 deletions templates/repo/home.tmpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
{{template "base/head" .}}
{{$treeNamesLen := len .TreeNames}}
{{$isTreePathRoot := eq $treeNamesLen 0}}
{{$showSidebar := and $isTreePathRoot (not .HideRepoInfo) (not .IsBlame)}}
{{$hasTreeSidebar := not $isTreePathRoot}}
{{$showTreeSidebar := .RepoPreferences.ShowFileViewTreeSidebar}}
{{$hideTreeSidebar := not $showTreeSidebar}}
{{$showSidebar := and (not .TreeNames) (not .HideRepoInfo) (not .IsBlame)}}
<div role="main" aria-label="{{.Title}}" class="page-content repository file list {{if .IsBlame}}blame{{end}}">
{{template "repo/header" .}}
<div class="ui container {{if or $hasTreeSidebar .IsBlame}}fluid padded{{end}}">
<div class="ui container {{if or .TreeNames .IsBlame}}fluid padded{{end}}">
{{template "base/alert" .}}

{{if .Repository.IsArchived}}
Expand All @@ -22,9 +17,9 @@

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

<div class="{{Iif $showSidebar "repo-grid-filelist-sidebar" (Iif $showTreeSidebar "repo-grid-tree-sidebar" "repo-grid-filelist-only")}}">
{{if $hasTreeSidebar}}
<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>
<div class="{{Iif $showSidebar "repo-grid-filelist-sidebar" (Iif .RepoPreferences.ShowFileViewTreeSidebar "repo-grid-tree-sidebar" "repo-grid-filelist-only")}}">
{{if .TreeNames}}
<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>
{{end}}

<div class="repo-home-filelist">
Expand Down
11 changes: 4 additions & 7 deletions templates/repo/home_content.tmpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{{$treeNamesLen := len .TreeNames}}
{{$isTreePathRoot := eq $treeNamesLen 0}}
{{$isTreePathRoot := not .TreeNames}}
{{$showSidebar := and $isTreePathRoot (not .HideRepoInfo) (not .IsBlame)}}
{{$hasTreeSidebar := not $isTreePathRoot}}
{{$showTreeSidebar := .RepoPreferences.ShowFileViewTreeSidebar}}

{{template "repo/sub_menu" .}}
<div class="repo-button-row">
<div class="repo-button-row-left">
{{if $hasTreeSidebar}}
<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"}}">
{{if not $isTreePathRoot}}
<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"}}">
{{svg "octicon-sidebar-collapse" 20 "icon"}}
</button>
{{end}}
Expand Down Expand Up @@ -58,7 +55,7 @@
{{end}}

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

0 comments on commit 2d644fb

Please sign in to comment.