2023-01-20 04:42:33 -07:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
2023-05-08 22:57:24 -07:00
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
2023-01-20 04:42:33 -07:00
|
|
|
"code.gitea.io/gitea/modules/context"
|
2023-05-08 22:57:24 -07:00
|
|
|
"code.gitea.io/gitea/modules/git"
|
2023-01-20 04:42:33 -07:00
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
)
|
|
|
|
|
|
|
|
func RenderUserHeader(ctx *context.Context) {
|
2023-03-10 08:18:20 -07:00
|
|
|
ctx.Data["IsProjectEnabled"] = true
|
|
|
|
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
|
2023-01-20 04:42:33 -07:00
|
|
|
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
|
|
|
ctx.Data["ContextUser"] = ctx.ContextUser
|
2023-05-08 22:57:24 -07:00
|
|
|
tab := ctx.FormString("tab")
|
|
|
|
ctx.Data["TabName"] = tab
|
|
|
|
repo, err := repo_model.GetRepositoryByName(ctx.ContextUser.ID, ".profile")
|
|
|
|
if err == nil && !repo.IsEmpty {
|
|
|
|
gitRepo, err := git.OpenRepository(ctx, repo.RepoPath())
|
|
|
|
if err != nil {
|
|
|
|
ctx.ServerError("OpenRepository", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer gitRepo.Close()
|
|
|
|
commit, err := gitRepo.GetBranchCommit(repo.DefaultBranch)
|
|
|
|
if err != nil {
|
|
|
|
ctx.ServerError("GetBranchCommit", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
blob, err := commit.GetBlobByPath("README.md")
|
|
|
|
if err == nil && blob != nil {
|
|
|
|
ctx.Data["ProfileReadme"] = true
|
|
|
|
}
|
|
|
|
}
|
2023-01-20 04:42:33 -07:00
|
|
|
}
|