0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-19 12:50:52 +02:00

make template simpler

This commit is contained in:
Lunny Xiao 2025-01-14 21:47:59 -08:00
parent 20198ea5a2
commit 2d644fb4ce
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 9 additions and 17 deletions

View File

@ -1,13 +1,8 @@
{{template "base/head" .}} {{template "base/head" .}}
{{$treeNamesLen := len .TreeNames}} {{$showSidebar := and (not .TreeNames) (not .HideRepoInfo) (not .IsBlame)}}
{{$isTreePathRoot := eq $treeNamesLen 0}}
{{$showSidebar := and $isTreePathRoot (not .HideRepoInfo) (not .IsBlame)}}
{{$hasTreeSidebar := not $isTreePathRoot}}
{{$showTreeSidebar := .RepoPreferences.ShowFileViewTreeSidebar}}
{{$hideTreeSidebar := not $showTreeSidebar}}
<div role="main" aria-label="{{.Title}}" class="page-content repository file list {{if .IsBlame}}blame{{end}}"> <div role="main" aria-label="{{.Title}}" class="page-content repository file list {{if .IsBlame}}blame{{end}}">
{{template "repo/header" .}} {{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" .}} {{template "base/alert" .}}
{{if .Repository.IsArchived}} {{if .Repository.IsArchived}}
@ -22,9 +17,9 @@
{{template "repo/code/recently_pushed_new_branches" .}} {{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")}}"> <div class="{{Iif $showSidebar "repo-grid-filelist-sidebar" (Iif .RepoPreferences.ShowFileViewTreeSidebar "repo-grid-tree-sidebar" "repo-grid-filelist-only")}}">
{{if $hasTreeSidebar}} {{if .TreeNames}}
<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="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}} {{end}}
<div class="repo-home-filelist"> <div class="repo-home-filelist">

View File

@ -1,14 +1,11 @@
{{$treeNamesLen := len .TreeNames}} {{$isTreePathRoot := not .TreeNames}}
{{$isTreePathRoot := eq $treeNamesLen 0}}
{{$showSidebar := and $isTreePathRoot (not .HideRepoInfo) (not .IsBlame)}} {{$showSidebar := and $isTreePathRoot (not .HideRepoInfo) (not .IsBlame)}}
{{$hasTreeSidebar := not $isTreePathRoot}}
{{$showTreeSidebar := .RepoPreferences.ShowFileViewTreeSidebar}}
{{template "repo/sub_menu" .}} {{template "repo/sub_menu" .}}
<div class="repo-button-row"> <div class="repo-button-row">
<div class="repo-button-row-left"> <div class="repo-button-row-left">
{{if $hasTreeSidebar}} {{if not $isTreePathRoot}}
<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"}}"> <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"}} {{svg "octicon-sidebar-collapse" 20 "icon"}}
</button> </button>
{{end}} {{end}}
@ -58,7 +55,7 @@
{{end}} {{end}}
{{if not $isTreePathRoot}} {{if not $isTreePathRoot}}
{{$treeNameIdxLast := Eval $treeNamesLen "-" 1}} {{$treeNameIdxLast := Eval (len .TreeNames) "-" 1}}
<span class="breadcrumb repo-path tw-ml-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> <a class="section" href="{{.RepoLink}}/src/{{.RefTypeNameSubURL}}" title="{{.Repository.Name}}">{{StringUtils.EllipsisString .Repository.Name 30}}</a>
{{- range $i, $v := .TreeNames -}} {{- range $i, $v := .TreeNames -}}