@ -64,17 +64,17 @@ func userProfile(ctx *context.Context) {
ctx . Data [ "HeatmapTotalContributions" ] = activities_model . GetTotalContributionsInHeatmap ( data )
}
profileGitRepo , profileReadmeBlob , profileClose := shared_user . FindUserProfileReadme ( ctx , ctx . Doer )
profileDbRepo , profile GitRepo , profileReadmeBlob , profileClose := shared_user . FindUserProfileReadme ( ctx , ctx . Doer )
defer profileClose ( )
showPrivate := ctx . IsSigned && ( ctx . Doer . IsAdmin || ctx . Doer . ID == ctx . ContextUser . ID )
prepareUserProfileTabData ( ctx , showPrivate , profileGitRepo , profileReadmeBlob )
prepareUserProfileTabData ( ctx , showPrivate , profileDbRepo , profile GitRepo , profileReadmeBlob )
// call PrepareContextForProfileBigAvatar later to avoid re-querying the NumFollowers & NumFollowing
shared_user . PrepareContextForProfileBigAvatar ( ctx )
ctx . HTML ( http . StatusOK , tplProfile )
}
func prepareUserProfileTabData ( ctx * context . Context , showPrivate bool , profileGitRepo * git . Repository , profileReadme * git . Blob ) {
func prepareUserProfileTabData ( ctx * context . Context , showPrivate bool , profileDbRepo * repo_model . Repository , profile GitRepo * git . Repository , profileReadme * git . Blob ) {
// 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" )
@ -233,10 +233,18 @@ func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileGi
if bytes , err := profileReadme . GetBlobContent ( setting . UI . MaxDisplayFileSize ) ; err != nil {
log . Error ( "failed to GetBlobContent: %v" , err )
} else {
// Give the URLPrefix to the markdown render for the full link of media element.
// the media link usually be like /[user]/[repoName]/media/branch/[branchName],
// Eg. /Tom/.profile/media/branch/main
// The branch shown on the profile page is the default branch, this need to be in sync with doc, see:
// https://docs.gitea.com/usage/profile-readme
prefix := profileDbRepo . Link ( ) + "/src/branch/" + util . PathEscapeSegments ( profileDbRepo . DefaultBranch )
if profileContent , err := markdown . RenderString ( & markup . RenderContext {
Ctx : ctx ,
GitRepo : profileGitRepo ,
Metas : map [ string ] string { "mode" : "document" } ,
Ctx : ctx ,
GitRepo : profileGitRepo ,
URLPrefix : prefix ,
Metas : map [ string ] string { "mode" : "document" } ,
} , bytes ) ; err != nil {
log . Error ( "failed to RenderString: %v" , err )
} else {