diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index d7052914b6..dae2f90f1a 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -1,5 +1,6 @@ // Copyright 2015 The Gogs Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved. +// Copyright 2025 Gustavo "Guz" L. de Mello & The Lored.dev Contributors // SPDX-License-Identifier: MIT package user @@ -82,12 +83,8 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R // if there is a profile readme, default to "overview" page, otherwise, default to "repositories" page // if there is not a profile readme, the overview tab should be treated as the repositories tab tab := ctx.FormString("tab") - if tab == "" || tab == "overview" { - if profileReadme != nil { - tab = "overview" - } else { - tab = "repositories" - } + if tab == "" { + tab = "overview" } ctx.Data["TabName"] = tab ctx.Data["HasUserProfileReadme"] = profileReadme != nil @@ -160,41 +157,6 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R case "following": ctx.Data["Cards"] = following total = int(numFollowing) - case "activity": - // prepare heatmap data - if setting.Service.EnableUserHeatmap { - data, err := activities_model.GetUserHeatmapDataByUser(ctx, ctx.ContextUser, ctx.Doer) - if err != nil { - ctx.ServerError("GetUserHeatmapDataByUser", err) - return - } - ctx.Data["HeatmapData"] = data - ctx.Data["HeatmapTotalContributions"] = activities_model.GetTotalContributionsInHeatmap(data) - } - - date := ctx.FormString("date") - pagingNum = setting.UI.FeedPagingNum - showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID) - items, count, err := feed_service.GetFeeds(ctx, activities_model.GetFeedsOptions{ - RequestedUser: ctx.ContextUser, - Actor: ctx.Doer, - IncludePrivate: showPrivate, - OnlyPerformedBy: true, - IncludeDeleted: false, - Date: date, - ListOptions: db.ListOptions{ - PageSize: pagingNum, - Page: page, - }, - }) - if err != nil { - ctx.ServerError("GetFeeds", err) - return - } - ctx.Data["Feeds"] = items - ctx.Data["Date"] = date - - total = int(count) case "stars": ctx.Data["PageIsProfileStarList"] = true ctx.Data["ShowRepoOwnerOnList"] = true @@ -251,19 +213,56 @@ func prepareUserProfileTabData(ctx *context.Context, profileDbRepo *repo_model.R } total = int(count) - case "overview": - if bytes, err := profileReadme.GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil { - log.Error("failed to GetBlobContent: %v", err) - } else { - rctx := renderhelper.NewRenderContextRepoFile(ctx, profileDbRepo, renderhelper.RepoFileOptions{ - CurrentRefPath: path.Join("branch", util.PathEscapeSegments(profileDbRepo.DefaultBranch)), - }) - if profileContent, err := markdown.RenderString(rctx, bytes); err != nil { - log.Error("failed to RenderString: %v", err) + case "overview", "activity": + if profileReadme != nil && tab == "overview" { + if bytes, err := profileReadme.GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil { + log.Error("failed to GetBlobContent: %v", err) } else { - ctx.Data["ProfileReadmeContent"] = profileContent + rctx := renderhelper.NewRenderContextRepoFile(ctx, profileDbRepo, renderhelper.RepoFileOptions{ + CurrentRefPath: path.Join("branch", util.PathEscapeSegments(profileDbRepo.DefaultBranch)), + }) + if profileContent, err := markdown.RenderString(rctx, bytes); err != nil { + log.Error("failed to RenderString: %v", err) + } else { + ctx.Data["ProfileReadmeContent"] = profileContent + } } } + + // prepare heatmap data + if setting.Service.EnableUserHeatmap { + data, err := activities_model.GetUserHeatmapDataByUser(ctx, ctx.ContextUser, ctx.Doer) + if err != nil { + ctx.ServerError("GetUserHeatmapDataByUser", err) + return + } + ctx.Data["HeatmapData"] = data + ctx.Data["HeatmapTotalContributions"] = activities_model.GetTotalContributionsInHeatmap(data) + } + + date := ctx.FormString("date") + pagingNum = setting.UI.FeedPagingNum + showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID) + items, count, err := feed_service.GetFeeds(ctx, activities_model.GetFeedsOptions{ + RequestedUser: ctx.ContextUser, + Actor: ctx.Doer, + IncludePrivate: showPrivate, + OnlyPerformedBy: true, + IncludeDeleted: false, + Date: date, + ListOptions: db.ListOptions{ + PageSize: pagingNum, + Page: page, + }, + }) + if err != nil { + ctx.ServerError("GetFeeds", err) + return + } + ctx.Data["Feeds"] = items + ctx.Data["Date"] = date + + total = int(count) case "organizations": orgs, count, err := db.FindAndCount[organization.Organization](ctx, organization.FindOrgOptions{ UserID: ctx.ContextUser.ID, diff --git a/templates/user/overview/header.tmpl b/templates/user/overview/header.tmpl index f4664c704d..41c2546ee4 100644 --- a/templates/user/overview/header.tmpl +++ b/templates/user/overview/header.tmpl @@ -1,6 +1,6 @@
- {{if and .HasUserProfileReadme .ContextUser.IsIndividual}} + {{if and .ContextUser.IsIndividual}} {{svg "octicon-info"}} {{ctx.Locale.Tr "user.overview"}} @@ -30,9 +30,6 @@ {{end}} {{if .ContextUser.IsIndividual}} - - {{svg "octicon-rss"}} {{ctx.Locale.Tr "user.activity"}} - {{if not .DisableStars}} {{svg "octicon-star"}} {{ctx.Locale.Tr "user.starred"}} diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 74a53b937d..79bf1cafd0 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -26,7 +26,19 @@ {{else if eq .TabName "followers"}} {{template "repo/user_cards" .}} {{else if eq .TabName "overview"}} -
{{.ProfileReadmeContent}}
+ {{if .HasUserProfileReadme}} +
{{.ProfileReadmeContent}}
+ {{end}} + {{if (and (or .HeatmapData .Feeds) (not .ContextUser.KeepActivityPrivate))}} +
+ {{end}} + {{if .ContextUser.KeepActivityPrivate}} +
+

{{ctx.Locale.Tr "user.disabled_public_activity"}}

+
+ {{end}} + {{template "user/heatmap" .}} + {{template "user/dashboard/feeds" .}} {{else if eq .TabName "organizations"}} {{template "repo/user_cards" .}} {{else}}