From 5964c260aba2b60f0f18f3c6cf22212969e66442 Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Fri, 10 Nov 2023 01:04:38 +0000
Subject: [PATCH 1/7] improve search box
---
templates/explore/repo_search.tmpl | 38 +++++++++----------
templates/explore/repos.tmpl | 2 +-
templates/org/home.tmpl | 5 ++-
.../notification_subscriptions.tmpl | 2 +-
templates/user/profile.tmpl | 4 +-
5 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/templates/explore/repo_search.tmpl b/templates/explore/repo_search.tmpl
index 136d3f8e8197e..ea529c5b84615 100644
--- a/templates/explore/repo_search.tmpl
+++ b/templates/explore/repo_search.tmpl
@@ -1,13 +1,13 @@
-{{if and .PageIsExploreRepositories .OnlyShowRelevant}}
+{{if and .ctxData.PageIsExploreRepositories .ctxData.OnlyShowRelevant}}
{{template "explore/navbar" .}}
- {{template "explore/repo_search" .}}
+ {{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl
index 2bebcc0f87d7d..c02909ea82570 100644
--- a/templates/org/home.tmpl
+++ b/templates/org/home.tmpl
@@ -40,8 +40,11 @@
{{if .ProfileReadme}}
{{.ProfileReadme | Str2html}}
+ {{template "explore/repo_search" dict "ctxData" . "AutoFocus" false}}
+ {{else}}
+ {{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
{{end}}
- {{template "explore/repo_search" .}}
+
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
diff --git a/templates/user/notification/notification_subscriptions.tmpl b/templates/user/notification/notification_subscriptions.tmpl
index 7eb4c8ea446ac..26cc8ca2dea7f 100644
--- a/templates/user/notification/notification_subscriptions.tmpl
+++ b/templates/user/notification/notification_subscriptions.tmpl
@@ -69,7 +69,7 @@
{{template "shared/issuelist" dict "." . "listType" "dashboard"}}
{{end}}
{{else}}
- {{template "explore/repo_search" .}}
+ {{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
{{end}}
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl
index 426b5f042a583..84be680596374 100644
--- a/templates/user/profile.tmpl
+++ b/templates/user/profile.tmpl
@@ -20,7 +20,7 @@
{{template "user/dashboard/feeds" .}}
{{else if eq .TabName "stars"}}
- {{template "explore/repo_search" .}}
+ {{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
@@ -31,7 +31,7 @@
{{else if eq .TabName "overview"}}
{{.ProfileReadme | Str2html}}
{{else}}
- {{template "explore/repo_search" .}}
+ {{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
{{end}}
From 07e904d57bc6fe690604de87870609d74fbee6ea Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Fri, 10 Nov 2023 01:12:04 +0000
Subject: [PATCH 2/7] fix overview tab
---
templates/user/overview/header.tmpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/user/overview/header.tmpl b/templates/user/overview/header.tmpl
index 9b6458474e5aa..94d06234faa1e 100644
--- a/templates/user/overview/header.tmpl
+++ b/templates/user/overview/header.tmpl
@@ -1,5 +1,5 @@
From dbc1bdfd2847b5c187a6c3a9ccb16dfd6ec887c1 Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Fri, 10 Nov 2023 02:34:17 +0000
Subject: [PATCH 5/7] fix lint
---
routers/web/shared/user/header.go | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/routers/web/shared/user/header.go b/routers/web/shared/user/header.go
index 8e70c3d53fbe1..3a83722ef767d 100644
--- a/routers/web/shared/user/header.go
+++ b/routers/web/shared/user/header.go
@@ -88,17 +88,21 @@ func PrepareContextForProfileBigAvatar(ctx *context.Context) {
func FindUserProfileReadme(ctx *context.Context, doer *user_model.User) (profileGitRepo *git.Repository, profileReadmeBlob *git.Blob, profileClose func()) {
profileDbRepo, err := repo_model.GetRepositoryByName(ctx, ctx.ContextUser.ID, ".profile")
- perm, err := access_model.GetUserRepoPermission(ctx, profileDbRepo, doer)
- if err == nil && !profileDbRepo.IsEmpty && perm.CanRead(unit.TypeCode) {
- if profileGitRepo, err = git.OpenRepository(ctx, profileDbRepo.RepoPath()); err != nil {
- log.Error("FindUserProfileReadme failed to OpenRepository: %v", err)
- } else {
- if commit, err := profileGitRepo.GetBranchCommit(profileDbRepo.DefaultBranch); err != nil {
- log.Error("FindUserProfileReadme failed to GetBranchCommit: %v", err)
+ if err == nil {
+ perm, err := access_model.GetUserRepoPermission(ctx, profileDbRepo, doer)
+ if err == nil && !profileDbRepo.IsEmpty && perm.CanRead(unit.TypeCode) {
+ if profileGitRepo, err = git.OpenRepository(ctx, profileDbRepo.RepoPath()); err != nil {
+ log.Error("FindUserProfileReadme failed to OpenRepository: %v", err)
} else {
- profileReadmeBlob, _ = commit.GetBlobByPath("README.md")
+ if commit, err := profileGitRepo.GetBranchCommit(profileDbRepo.DefaultBranch); err != nil {
+ log.Error("FindUserProfileReadme failed to GetBranchCommit: %v", err)
+ } else {
+ profileReadmeBlob, _ = commit.GetBlobByPath("README.md")
+ }
}
}
+ } else if !repo_model.IsErrRepoNotExist(err) {
+ log.Error("FindUserProfileReadme failed to GetRepositoryByName: %v", err)
}
return profileGitRepo, profileReadmeBlob, func() {
if profileGitRepo != nil {
From 8ffefc99587ea4df55e43d8f82baeeaf4d7b2730 Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Mon, 13 Nov 2023 06:22:55 +0000
Subject: [PATCH 6/7] (maybe) a better way to set autofocus
---
templates/explore/repo_search.tmpl | 42 ++++++++++---------
templates/explore/repos.tmpl | 2 +-
templates/org/home.tmpl | 5 +--
.../notification_subscriptions.tmpl | 2 +-
templates/user/profile.tmpl | 4 +-
5 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/templates/explore/repo_search.tmpl b/templates/explore/repo_search.tmpl
index ea529c5b84615..ef760661828ac 100644
--- a/templates/explore/repo_search.tmpl
+++ b/templates/explore/repo_search.tmpl
@@ -1,13 +1,17 @@
-{{if and .ctxData.PageIsExploreRepositories .ctxData.OnlyShowRelevant}}
+{{if and .PageIsExploreRepositories .OnlyShowRelevant}}
{{template "explore/navbar" .}}
- {{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
+ {{template "explore/repo_search" .}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl
index 139c838bfb40b..2bebcc0f87d7d 100644
--- a/templates/org/home.tmpl
+++ b/templates/org/home.tmpl
@@ -40,11 +40,8 @@
{{if .ProfileReadme}}
{{.ProfileReadme | Str2html}}
- {{template "explore/repo_search" dict "ctxData" . "AutoFocus" false}}
- {{else}}
- {{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
{{end}}
-
+ {{template "explore/repo_search" .}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
diff --git a/templates/user/notification/notification_subscriptions.tmpl b/templates/user/notification/notification_subscriptions.tmpl
index 26cc8ca2dea7f..7eb4c8ea446ac 100644
--- a/templates/user/notification/notification_subscriptions.tmpl
+++ b/templates/user/notification/notification_subscriptions.tmpl
@@ -69,7 +69,7 @@
{{template "shared/issuelist" dict "." . "listType" "dashboard"}}
{{end}}
{{else}}
- {{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
+ {{template "explore/repo_search" .}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
{{end}}
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl
index 84be680596374..426b5f042a583 100644
--- a/templates/user/profile.tmpl
+++ b/templates/user/profile.tmpl
@@ -20,7 +20,7 @@
{{template "user/dashboard/feeds" .}}
{{else if eq .TabName "stars"}}
- {{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
+ {{template "explore/repo_search" .}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
@@ -31,7 +31,7 @@
{{else if eq .TabName "overview"}}
{{.ProfileReadme | Str2html}}
{{else}}
- {{template "explore/repo_search" dict "ctxData" . "AutoFocus" true}}
+ {{template "explore/repo_search" .}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
{{end}}
From 86106ff56aa2e1c2ed69750c4c1ecb1b8e9f703f Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Mon, 13 Nov 2023 19:52:28 +0900
Subject: [PATCH 7/7] Update templates/explore/repo_search.tmpl
Co-authored-by: silverwind
---
templates/explore/repo_search.tmpl | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/templates/explore/repo_search.tmpl b/templates/explore/repo_search.tmpl
index ef760661828ac..71c088ef241c4 100644
--- a/templates/explore/repo_search.tmpl
+++ b/templates/explore/repo_search.tmpl
@@ -3,11 +3,7 @@
- {{if .ProfileReadme}}
- {{template "shared/searchinput" dict "Value" .Keyword "AutoFocus" false}}
- {{else}}
- {{template "shared/searchinput" dict "Value" .Keyword "AutoFocus" true}}
- {{end}}
+ {{template "shared/searchinput" dict "Value" .Keyword "AutoFocus" (not .ProfileReadme)}}
{{if .PageIsExploreRepositories}}
{{else if .TabName}}