|
90 | 90 | {{ctx.Locale.Tr "repo.use_template"}} |
91 | 91 | </a> |
92 | 92 | {{end}} |
93 | | - {{if (not $isHomepage)}} |
| 93 | + {{if $isHomepage}} |
| 94 | + {{/* only show the "code search" on the repo home page, it only does global search, |
| 95 | + so do not show it when viewing file or directory to avoid misleading users (it doesn't search in a directory) */}} |
| 96 | + <form class="ignore-dirty" action="{{.RepoLink}}/search" method="get"> |
| 97 | + <div class="ui small action input"> |
| 98 | + <input name="q" placeholder="{{ctx.Locale.Tr "search.code_kind"}}"> |
| 99 | + {{template "shared/search/button"}} |
| 100 | + </div> |
| 101 | + </form> |
| 102 | + {{else}} |
94 | 103 | <span class="breadcrumb repo-path tw-ml-1"> |
95 | 104 | <a class="section" href="{{.RepoLink}}/src/{{.BranchNameSubURL}}" title="{{.Repository.Name}}">{{StringUtils.EllipsisString .Repository.Name 30}}</a> |
96 | 105 | {{- range $i, $v := .TreeNames -}} |
|
103 | 112 | {{- end -}} |
104 | 113 | </span> |
105 | 114 | {{end}} |
106 | | - |
107 | | - <form class="ignore-dirty" action="{{.RepoLink}}/search" method="get"> |
108 | | - <div class="ui small action input"> |
109 | | - <input name="q" value="{{.Keyword}}" placeholder="{{ctx.Locale.Tr "search.code_kind"}}"> |
110 | | - {{template "shared/search/button"}} |
111 | | - </div> |
112 | | - </form> |
113 | 115 | </div> |
114 | 116 | <div class="tw-flex tw-items-center"> |
115 | 117 | <!-- Only show clone panel in repository home page --> |
|
136 | 138 | </div> |
137 | 139 | {{template "repo/cite/cite_modal" .}} |
138 | 140 | {{end}} |
139 | | - {{if and (not $isHomepage) (not .IsViewFile) (not .IsBlame)}} |
| 141 | + {{if and (not $isHomepage) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home), TODO: split the templates, avoid using "if" tricks */}} |
140 | 142 | <a class="ui button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}"> |
141 | 143 | {{svg "octicon-history" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.file_history"}} |
142 | 144 | </a> |
|
147 | 149 | {{template "repo/view_file" .}} |
148 | 150 | {{else if .IsBlame}} |
149 | 151 | {{template "repo/blame" .}} |
150 | | - {{else}} |
| 152 | + {{else}}{{/* IsViewDirectory */}} |
151 | 153 | {{template "repo/view_list" .}} |
152 | 154 | {{end}} |
153 | 155 | </div> |
|
0 commit comments