From ceede0faf6b14c0108b62ed9fa9568c2684f6ee5 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 24 Apr 2024 13:26:54 +0800 Subject: [PATCH 1/3] fix --- routers/web/repo/commit.go | 2 -- routers/web/repo/compare.go | 1 - routers/web/repo/pull.go | 1 - templates/repo/home.tmpl | 22 ++++++++++++---------- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index 8543fa44cc712..a2c6ac33e8f8e 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -212,8 +212,6 @@ func SearchCommits(ctx *context.Context) { // FileHistory show a file's reversions func FileHistory(ctx *context.Context) { - ctx.Data["IsRepoToolbarCommits"] = true - fileName := ctx.Repo.TreePath if len(fileName) == 0 { Commits(ctx) diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 035a92f22830c..a55426dab5055 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -800,7 +800,6 @@ func CompareDiff(ctx *context.Context) { } ctx.Data["Title"] = "Comparing " + base.ShortSha(beforeCommitID) + separator + base.ShortSha(afterCommitID) - ctx.Data["IsRepoToolbarCommits"] = true ctx.Data["IsDiffCompare"] = true _, templateErrs := setTemplateIfExists(ctx, pullRequestTemplateKey, pullRequestTemplateCandidates) diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 71f25db11bef1..c4f795dfc0179 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -1225,7 +1225,6 @@ func CompareAndPullRequestPost(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.pulls.compare_changes") ctx.Data["PageIsComparePull"] = true ctx.Data["IsDiffCompare"] = true - ctx.Data["IsRepoToolbarCommits"] = true ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled upload.AddUploadContext(ctx, "comment") diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 7b37ac10118db..09aafcdc95757 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -90,7 +90,16 @@ {{ctx.Locale.Tr "repo.use_template"}} {{end}} - {{if (not $isHomepage)}} + {{if $isHomepage}} + {{/* only show the "code search" on the repo home page, it only does global search, + so do not show it when viewing file or directory to avoid misleading users (it doesn't search in a directory) */}} +
+
+ + {{template "shared/search/button"}} +
+
+ {{else}} {{StringUtils.EllipsisString .Repository.Name 30}} {{- range $i, $v := .TreeNames -}} @@ -103,13 +112,6 @@ {{- end -}} {{end}} - -
-
- - {{template "shared/search/button"}} -
-
@@ -136,7 +138,7 @@
{{template "repo/cite/cite_modal" .}} {{end}} - {{if and (not $isHomepage) (not .IsViewFile) (not .IsBlame)}} + {{if and (not $isHomepage) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home) */}} {{svg "octicon-history" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.file_history"}} @@ -147,7 +149,7 @@ {{template "repo/view_file" .}} {{else if .IsBlame}} {{template "repo/blame" .}} - {{else}} + {{else}}{{/* IsViewDirectory */}} {{template "repo/view_list" .}} {{end}} From 35e5bf6f06536e33273ca75df659578ee2aa6ee9 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 24 Apr 2024 13:39:43 +0800 Subject: [PATCH 2/3] remove non-existing Keyword --- templates/repo/home.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 09aafcdc95757..639143da8950f 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -95,7 +95,7 @@ so do not show it when viewing file or directory to avoid misleading users (it doesn't search in a directory) */}}
- + {{template "shared/search/button"}}
From b3829ad25c75db883e18ac64155cc06cf7ec9e86 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 26 Apr 2024 18:53:36 +0800 Subject: [PATCH 3/3] Update templates/repo/home.tmpl --- templates/repo/home.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 639143da8950f..eb9eb9c14932f 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -138,7 +138,7 @@ {{template "repo/cite/cite_modal" .}} {{end}} - {{if and (not $isHomepage) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home) */}} + {{if and (not $isHomepage) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home), TODO: split the templates, avoid using "if" tricks */}} {{svg "octicon-history" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.file_history"}}