From c0168bfa0600fdc4db8168348d4a37eec74545d3 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 22 Dec 2024 21:06:21 +0800 Subject: [PATCH 1/2] fix --- routers/web/org/home.go | 9 ++++++--- templates/org/home.tmpl | 5 ++--- templates/org/menu.tmpl | 5 +++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/routers/web/org/home.go b/routers/web/org/home.go index f02c08ae7691a..5b4ef4419b93e 100644 --- a/routers/web/org/home.go +++ b/routers/web/org/home.go @@ -111,7 +111,7 @@ func home(ctx *context.Context, viewRepositories bool) { ctx.Data["DisableNewPullMirrors"] = setting.Mirror.DisableNewPull ctx.Data["ShowMemberAndTeamTab"] = ctx.Org.IsMember || len(members) > 0 - if !prepareOrgProfileReadme(ctx, viewRepositories) { + if !prepareOrgProfileRepo(ctx, viewRepositories) { ctx.Data["PageIsViewRepositories"] = true } @@ -168,15 +168,18 @@ func home(ctx *context.Context, viewRepositories bool) { ctx.HTML(http.StatusOK, tplOrgHome) } -func prepareOrgProfileReadme(ctx *context.Context, viewRepositories bool) bool { +func prepareOrgProfileRepo(ctx *context.Context, viewRepositories bool) bool { profileDbRepo, profileGitRepo, profileReadme, profileClose := shared_user.FindUserProfileReadme(ctx, ctx.Doer) defer profileClose() - ctx.Data["HasProfileReadme"] = profileReadme != nil if profileGitRepo == nil || profileReadme == nil || viewRepositories { return false } + ctx.Data["OrgProfileRepo"] = profileDbRepo + ctx.Data["HasProfileWiki"] = profileDbRepo.HasWiki() + ctx.Data["HasProfileReadme"] = true + if bytes, err := profileReadme.GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil { log.Error("failed to GetBlobContent: %v", err) } else { diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 4851b6997967b..f3e1613fd765e 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -16,13 +16,12 @@ {{if .ShowMemberAndTeamTab}}
{{if .CanCreateOrgRepo}} -
+
{{ctx.Locale.Tr "new_repo"}} {{if not .DisableNewPullMirrors}} {{ctx.Locale.Tr "new_migrate"}} {{end}}
-
{{end}} {{if .NumMembers}}

@@ -33,7 +32,7 @@ {{$isMember := .IsOrganizationMember}} {{range .Members}} {{if or $isMember (call $.IsPublicMember .ID)}} - {{ctx.AvatarUtils.Avatar . 48}} + {{ctx.AvatarUtils.Avatar . 24}} {{end}} {{end}}

diff --git a/templates/org/menu.tmpl b/templates/org/menu.tmpl index 29238f8d6bb9a..3d490f6787222 100644 --- a/templates/org/menu.tmpl +++ b/templates/org/menu.tmpl @@ -20,6 +20,11 @@ {{end}} {{end}} + {{if .HasProfileWiki}} + + {{svg "octicon-book"}} {{ctx.Locale.Tr "repo.wiki"}} + + {{end}} {{if and .IsPackageEnabled .CanReadPackages}} {{svg "octicon-package"}} {{ctx.Locale.Tr "packages.title"}} From 2b3155f2f00db95737467b03e6231885c2126896 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 31 Dec 2024 12:42:08 +0800 Subject: [PATCH 2/2] fix --- options/locale/locale_en-US.ini | 8 ++++---- routers/web/org/home.go | 3 +++ templates/org/home.tmpl | 11 +++++++++-- templates/org/menu.tmpl | 5 ----- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index ef66e9ce45ec4..dc0f8d3b2f2af 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1015,8 +1015,8 @@ new_repo_helper = A repository contains all project files, including revision hi owner = Owner owner_helper = Some organizations may not show up in the dropdown due to a maximum repository count limit. repo_name = Repository Name -repo_name_profile_public_hint= .profile is a special repository that you can use to add README.md to your public organization profile, visible to anyone. Make sure it’s public and initialize it with a README in the profile directory to get started. -repo_name_profile_private_hint = .profile-private is a special repository that you can use to add a README.md to your organization member profile, visible only to organization members. Make sure it’s private and initialize it with a README in the profile directory to get started. +repo_name_profile_public_hint= .profile is a special repository that you can use to add README.md and Wiki to your public organization profile, visible to anyone. Make sure it’s public and initialize it with a README in the profile directory to get started. +repo_name_profile_private_hint = .profile-private is a special repository that you can use to add a README.md and Wiki to your organization member profile, visible only to organization members. Make sure it’s private and initialize it with a README in the profile directory to get started. repo_name_helper = Good repository names use short, memorable and unique keywords. A repository named '.profile' or '.profile-private' could be used to add a README.md for the user/organization profile. repo_size = Repository Size template = Template @@ -2865,8 +2865,8 @@ teams.invite.by = Invited by %s teams.invite.description = Please click the button below to join the team. view_as_role = View as: %s -view_as_public_hint = You are viewing the README a public user. -view_as_member_hint = You are viewing the README a member of this organization. +view_as_public_hint = You are viewing the README/Wiki as a public user. +view_as_member_hint = You are viewing the README/Wiki as a member of this organization. [admin] maintenance = Maintenance diff --git a/routers/web/org/home.go b/routers/web/org/home.go index 277adb60ca0e7..6089dc1fd356d 100644 --- a/routers/web/org/home.go +++ b/routers/web/org/home.go @@ -179,6 +179,9 @@ func prepareOrgProfileReadme(ctx *context.Context, prepareResult *shared_user.Pr return false } + ctx.Data["HasOrgProfileWiki"] = profileRepo.HasWiki() + ctx.Data["OrgProfileRepo"] = profileRepo + readmeBytes, err := readmeBlob.GetBlobContent(setting.UI.MaxDisplayFileSize) if err != nil { log.Error("failed to GetBlobContent for profile %q (view as %q) readme: %v", profileRepo.FullName(), viewAs, err) diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 8bdfbf5ae6e6a..af45a62665042 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -16,12 +16,13 @@ {{if .ShowMemberAndTeamTab}}
{{if .CanCreateOrgRepo}} -
+
{{ctx.Locale.Tr "new_repo"}} {{if not .DisableNewPullMirrors}} {{ctx.Locale.Tr "new_migrate"}} {{end}}
+
{{end}} {{if and .ShowMemberAndTeamTab .ShowOrgProfileReadmeSelector}} @@ -43,6 +44,12 @@
{{if .IsViewingOrgAsMember}}{{ctx.Locale.Tr "org.view_as_member_hint"}}{{else}}{{ctx.Locale.Tr "org.view_as_public_hint"}}{{end}}
+ {{if .HasOrgProfileWiki}} + {{/* FIXME: the "view as" affects the "wiki link", it can't be in the menu tab. Need to figure out some better UI/UX solutions. */}} + + {{svg "octicon-book"}} {{ctx.Locale.Tr "repo.wiki"}} + + {{end}}
{{end}} @@ -55,7 +62,7 @@ {{$isMember := .IsOrganizationMember}} {{range .Members}} {{if or $isMember (call $.IsPublicMember .ID)}} - {{ctx.AvatarUtils.Avatar . 24}} + {{ctx.AvatarUtils.Avatar . 48}} {{end}} {{end}}
diff --git a/templates/org/menu.tmpl b/templates/org/menu.tmpl index 3e04c3cb14d20..4a8aee68a7d37 100644 --- a/templates/org/menu.tmpl +++ b/templates/org/menu.tmpl @@ -20,11 +20,6 @@ {{end}} {{end}} - {{if .HasProfileWiki}} - - {{svg "octicon-book"}} {{ctx.Locale.Tr "repo.wiki"}} - - {{end}} {{if and .IsPackageEnabled .CanReadPackages}} {{svg "octicon-package"}} {{ctx.Locale.Tr "packages.title"}}