diff --git a/modules/context/org.go b/modules/context/org.go index d068646577..018b76de43 100644 --- a/modules/context/org.go +++ b/modules/context/org.go @@ -11,6 +11,8 @@ import ( "code.gitea.io/gitea/models/perm" "code.gitea.io/gitea/models/unit" user_model "code.gitea.io/gitea/models/user" + "code.gitea.io/gitea/modules/markup" + "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/structs" ) @@ -255,6 +257,19 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { ctx.Data["CanReadProjects"] = ctx.Org.CanReadUnit(ctx, unit.TypeProjects) ctx.Data["CanReadPackages"] = ctx.Org.CanReadUnit(ctx, unit.TypePackages) ctx.Data["CanReadCode"] = ctx.Org.CanReadUnit(ctx, unit.TypeCode) + + ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID) + if len(ctx.ContextUser.Description) != 0 { + content, err := markdown.RenderString(&markup.RenderContext{ + Metas: map[string]string{"mode": "document"}, + Ctx: ctx, + }, ctx.ContextUser.Description) + if err != nil { + ctx.ServerError("RenderString", err) + return + } + ctx.Data["RenderedDescription"] = content + } } // OrgAssignment returns a middleware to handle organization assignment diff --git a/routers/web/org/home.go b/routers/web/org/home.go index 8bf02b2c42..36f543dc45 100644 --- a/routers/web/org/home.go +++ b/routers/web/org/home.go @@ -11,7 +11,6 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/organization" repo_model "code.gitea.io/gitea/models/repo" - user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" @@ -46,17 +45,6 @@ func Home(ctx *context.Context) { ctx.Data["PageIsUserProfile"] = true ctx.Data["Title"] = org.DisplayName() - if len(org.Description) != 0 { - desc, err := markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, - Metas: map[string]string{"mode": "document"}, - }, org.Description) - if err != nil { - ctx.ServerError("RenderString", err) - return - } - ctx.Data["RenderedDescription"] = desc - } var orderBy db.SearchOrderBy ctx.Data["SortType"] = ctx.FormString("sort") @@ -131,18 +119,12 @@ func Home(ctx *context.Context) { return } - var isFollowing bool - if ctx.Doer != nil { - isFollowing = user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID) - } - ctx.Data["Repos"] = repos ctx.Data["Total"] = count ctx.Data["Members"] = members ctx.Data["Teams"] = ctx.Org.Teams ctx.Data["DisableNewPullMirrors"] = setting.Mirror.DisableNewPull ctx.Data["PageIsViewRepositories"] = true - ctx.Data["IsFollowing"] = isFollowing err = shared_user.LoadHeaderCount(ctx) if err != nil { diff --git a/routers/web/shared/user/header.go b/routers/web/shared/user/header.go index 6830bdb8a9..07026e484f 100644 --- a/routers/web/shared/user/header.go +++ b/routers/web/shared/user/header.go @@ -17,8 +17,6 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/markup" - "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" ) @@ -36,7 +34,6 @@ func prepareContextForCommonProfile(ctx *context.Context) { func PrepareContextForProfileBigAvatar(ctx *context.Context) { prepareContextForCommonProfile(ctx) - ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID) ctx.Data["IsBlocked"] = ctx.Doer != nil && user_model.IsBlocked(ctx, ctx.Doer.ID, ctx.ContextUser.ID) ctx.Data["ShowUserEmail"] = setting.UI.ShowUserEmail && ctx.ContextUser.Email != "" && ctx.IsSigned && !ctx.ContextUser.KeepEmailPrivate ctx.Data["ContextUserLocationMapURL"] = setting.Service.UserLocationMapURL + url.QueryEscape(ctx.ContextUser.Location) @@ -49,18 +46,6 @@ func PrepareContextForProfileBigAvatar(ctx *context.Context) { } ctx.Data["OpenIDs"] = openIDs - if len(ctx.ContextUser.Description) != 0 { - content, err := markdown.RenderString(&markup.RenderContext{ - Metas: map[string]string{"mode": "document"}, - Ctx: ctx, - }, ctx.ContextUser.Description) - if err != nil { - ctx.ServerError("RenderString", err) - return - } - ctx.Data["RenderedDescription"] = content - } - showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID) orgs, err := db.Find[organization.Organization](ctx, organization.FindOrgOptions{ UserID: ctx.ContextUser.ID, diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index 1a9a9cf603..4eec0e9905 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -355,6 +355,7 @@ func Action(ctx *context.Context) { ctx.HTML(http.StatusOK, tplProfileBigAvatar) return } else if ctx.ContextUser.IsOrganization() { + ctx.Data["Org"] = ctx.ContextUser ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID) ctx.HTML(http.StatusOK, tplFollowUnfollow) return diff --git a/templates/org/header.tmpl b/templates/org/header.tmpl index 7b912c1c56..8423fd7d3b 100644 --- a/templates/org/header.tmpl +++ b/templates/org/header.tmpl @@ -1,18 +1,32 @@ -{{with .Org}} -
-
-
-
- {{ctx.AvatarUtils.Avatar . 100}} - {{.DisplayName}} - - {{if .Visibility.IsLimited}}
{{ctx.Locale.Tr "org.settings.visibility.limited_shortname"}}
{{end}} - {{if .Visibility.IsPrivate}}
{{ctx.Locale.Tr "org.settings.visibility.private_shortname"}}
{{end}} -
-
-
+
+ {{ctx.AvatarUtils.Avatar .Org 100 "org-avatar"}} +
+
+ {{.Org.DisplayName}} + + {{if .Org.Visibility.IsLimited}}{{ctx.Locale.Tr "org.settings.visibility.limited_shortname"}}{{end}} + {{if .Org.Visibility.IsPrivate}}{{ctx.Locale.Tr "org.settings.visibility.private_shortname"}}{{end}} + + + {{if .EnableFeed}} + + {{svg "octicon-rss" 24}} + + {{end}} + {{if .IsSigned}} + {{template "org/follow_unfollow" .}} + {{end}} + +
+ {{if .RenderedDescription}}
{{.RenderedDescription | Str2html}}
{{end}} +
+ {{if .Org.Location}}
{{svg "octicon-location"}} {{.Org.Location}}
{{end}} + {{if .Org.Website}}
{{svg "octicon-link"}} {{.Org.Website}}
{{end}} + {{if .IsSigned}} + {{if .Org.Email}}
{{svg "octicon-mail"}} {{.Org.Email}}
{{end}} + {{end}}
-{{end}} +
{{template "org/menu" .}} diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index fd2326ffd5..1c8a083aed 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -5,38 +5,7 @@ {{template "base/alert" .}}
{{end}} -
- {{ctx.AvatarUtils.Avatar .Org 140 "org-avatar"}} -
-
- {{.Org.DisplayName}} - - {{if .Org.Visibility.IsLimited}}{{ctx.Locale.Tr "org.settings.visibility.limited_shortname"}}{{end}} - {{if .Org.Visibility.IsPrivate}}{{ctx.Locale.Tr "org.settings.visibility.private_shortname"}}{{end}} - -
- {{if $.RenderedDescription}}
{{$.RenderedDescription|Str2html}}
{{end}} -
- {{if .Org.Location}}
{{svg "octicon-location"}} {{.Org.Location}}
{{end}} - {{if .Org.Website}}
{{svg "octicon-link"}} {{.Org.Website}}
{{end}} - {{if $.IsSigned}} - {{if .Org.Email}}
{{svg "octicon-mail"}} {{.Org.Email}}
{{end}} - {{end}} -
-
- -
- - {{template "org/menu" .}} + {{template "org/header" .}}
diff --git a/templates/org/member/members.tmpl b/templates/org/member/members.tmpl index 03509ec93e..64f1aaa7d2 100644 --- a/templates/org/member/members.tmpl +++ b/templates/org/member/members.tmpl @@ -1,5 +1,5 @@ {{template "base/head" .}} -
+
{{template "org/header" .}}
{{template "base/alert" .}} diff --git a/templates/org/menu.tmpl b/templates/org/menu.tmpl index 8a97711ce2..f07b26865a 100644 --- a/templates/org/menu.tmpl +++ b/templates/org/menu.tmpl @@ -15,24 +15,24 @@ {{end}} {{if and .IsPackageEnabled .CanReadPackages}} - + {{svg "octicon-package"}} {{ctx.Locale.Tr "packages.title"}} {{end}} {{if and .IsRepoIndexerEnabled .CanReadCode}} - - {{svg "octicon-code"}} {{ctx.Locale.Tr "org.code"}} + + {{svg "octicon-code"}} {{ctx.Locale.Tr "org.code"}} {{end}} {{if .NumMembers}} - {{svg "octicon-person"}} {{ctx.Locale.Tr "org.members"}} + {{svg "octicon-person"}} {{ctx.Locale.Tr "org.members"}}
{{.NumMembers}}
{{end}} {{if .IsOrganizationMember}} - {{svg "octicon-people"}} {{ctx.Locale.Tr "org.teams"}} + {{svg "octicon-people"}} {{ctx.Locale.Tr "org.teams"}} {{if .NumTeams}}
{{.NumTeams}}
{{end}} diff --git a/templates/org/projects/list.tmpl b/templates/org/projects/list.tmpl index 689091e5e0..97cc6cf66c 100644 --- a/templates/org/projects/list.tmpl +++ b/templates/org/projects/list.tmpl @@ -1,10 +1,9 @@ {{template "base/head" .}} {{if .ContextUser.IsOrganization}} -
- {{template "shared/user/org_profile_avatar" .}} +
+ {{template "org/header" .}}
- {{template "user/overview/header" .}} - {{template "projects/list" .}} + {{template "projects/list" .}}
{{else}} diff --git a/templates/package/settings.tmpl b/templates/package/settings.tmpl index 6ef62753e2..10e26c7010 100644 --- a/templates/package/settings.tmpl +++ b/templates/package/settings.tmpl @@ -1,8 +1,14 @@ {{template "base/head" .}} -
- {{template "shared/user/org_profile_avatar" .}} +
+ {{if .ContextUser.IsOrganization}} + {{template "org/header" .}} + {{else}} + {{template "shared/user/org_profile_avatar" .}} + {{end}}
- {{template "user/overview/header" .}} + {{if not .ContextUser.IsOrganization}} + {{template "user/overview/header" .}} + {{end}} {{template "base/alert" .}}

{{.PackageDescriptor.Package.Name}} ({{.PackageDescriptor.Version.Version}}) / {{ctx.Locale.Tr "repo.settings"}}

diff --git a/templates/user/code.tmpl b/templates/user/code.tmpl index da9a3c3a24..f71f55c474 100644 --- a/templates/user/code.tmpl +++ b/templates/user/code.tmpl @@ -1,9 +1,8 @@ {{template "base/head" .}} {{if .ContextUser.IsOrganization}} -
- {{template "shared/user/org_profile_avatar" .}} +
+ {{template "org/header" .}}
- {{template "user/overview/header" .}} {{template "code/searchcombo" .}}
diff --git a/templates/user/overview/header.tmpl b/templates/user/overview/header.tmpl index c0cbe2561c..4fdaa70d87 100644 --- a/templates/user/overview/header.tmpl +++ b/templates/user/overview/header.tmpl @@ -10,7 +10,7 @@
{{.RepoCount}}
{{end}} - {{if or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadProjects)}} + {{if or .ContextUser.IsIndividual .CanReadProjects}} {{svg "octicon-project-symlink"}} {{ctx.Locale.Tr "user.projects"}} {{if .ProjectCount}} @@ -18,55 +18,30 @@ {{end}} {{end}} - {{if and .IsPackageEnabled (or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadPackages))}} + {{if and .IsPackageEnabled (or .ContextUser.IsIndividual .CanReadPackages)}} {{svg "octicon-package"}} {{ctx.Locale.Tr "packages.title"}} {{end}} - {{if and .IsRepoIndexerEnabled (or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadCode))}} + {{if and .IsRepoIndexerEnabled (or .ContextUser.IsIndividual .CanReadCode)}} {{svg "octicon-code"}} {{ctx.Locale.Tr "user.code"}} {{end}} - {{if .ContextUser.IsOrganization}} - {{if .NumMembers}} - - {{svg "octicon-person"}} {{ctx.Locale.Tr "org.members"}} -
{{.NumMembers}}
-
- {{end}} - {{if .IsOrganizationMember}} - - {{svg "octicon-people"}} {{ctx.Locale.Tr "org.teams"}} - {{if .NumTeams}} -
{{.NumTeams}}
- {{end}} -
- {{end}} - - {{if .IsOrganizationOwner}} - - {{end}} - {{else}} - - {{svg "octicon-rss"}} {{ctx.Locale.Tr "user.activity"}} + + {{svg "octicon-rss"}} {{ctx.Locale.Tr "user.activity"}} + + {{if not .DisableStars}} + + {{svg "octicon-star"}} {{ctx.Locale.Tr "user.starred"}} + {{if .ContextUser.NumStars}} +
{{.ContextUser.NumStars}}
+ {{end}} +
+ {{else}} + + {{svg "octicon-eye"}} {{ctx.Locale.Tr "user.watched"}} - {{if not .DisableStars}} - - {{svg "octicon-star"}} {{ctx.Locale.Tr "user.starred"}} - {{if .ContextUser.NumStars}} -
{{.ContextUser.NumStars}}
- {{end}} -
- {{else}} - - {{svg "octicon-eye"}} {{ctx.Locale.Tr "user.watched"}} - - {{end}} {{end}}
diff --git a/templates/user/overview/package_versions.tmpl b/templates/user/overview/package_versions.tmpl index 6f740e0e7c..f6f963aecb 100644 --- a/templates/user/overview/package_versions.tmpl +++ b/templates/user/overview/package_versions.tmpl @@ -1,10 +1,9 @@ {{template "base/head" .}} {{if .ContextUser.IsOrganization}} -
- {{template "shared/user/org_profile_avatar" .}} +
+ {{template "org/header" .}}
- {{template "user/overview/header" .}} - {{template "package/shared/versionlist" .}} + {{template "package/shared/versionlist" .}}
{{else}} diff --git a/templates/user/overview/packages.tmpl b/templates/user/overview/packages.tmpl index 4fd17696d1..30ff871cb2 100644 --- a/templates/user/overview/packages.tmpl +++ b/templates/user/overview/packages.tmpl @@ -1,10 +1,9 @@ {{template "base/head" .}} {{if .ContextUser.IsOrganization}} -
- {{template "shared/user/org_profile_avatar" .}} +
+ {{template "org/header" .}}
- {{template "user/overview/header" .}} - {{template "package/shared/list" .}} + {{template "package/shared/list" .}}
{{else}} diff --git a/web_src/css/org.css b/web_src/css/org.css index 76512e0077..a1ef8e08ed 100644 --- a/web_src/css/org.css +++ b/web_src/css/org.css @@ -93,46 +93,44 @@ min-width: 300px; } -.organization.profile .org-avatar { - width: 100px; - height: 100px; +.page-content.organization .org-avatar { margin-right: 15px; } -.organization.profile #org-info { +.page-content.organization #org-info { overflow-wrap: anywhere; flex: 1; word-break: break-all; } -.organization.profile #org-info .ui.header { +.page-content.organization #org-info .ui.header { display: flex; align-items: center; font-size: 36px; margin-bottom: 0; } -.organization.profile #org-info .desc { +.page-content.organization #org-info .desc { font-size: 16px; margin-bottom: 10px; } -.organization.profile #org-info .meta { +.page-content.organization #org-info .meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; } -.organization.profile .ui.top.header .ui.right { +.page-content.organization .ui.top.header .ui.right { margin-top: 0; } -.organization.profile .teams .item { +.page-content.organization .teams .item { padding: 10px 15px; } -.organization.profile .members .ui.avatar { +.page-content.organization .members .ui.avatar { width: 48px; height: 48px; margin-right: 5px;