2023-01-20 11:42:33 +00:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
2023-05-09 05:57:24 +00:00
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
2023-01-20 11:42:33 +00:00
|
|
|
"code.gitea.io/gitea/modules/context"
|
2023-05-09 05:57:24 +00:00
|
|
|
"code.gitea.io/gitea/modules/git"
|
2023-01-20 11:42:33 +00:00
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
)
|
|
|
|
|
|
|
|
func RenderUserHeader(ctx *context.Context) {
|
2023-03-10 15:18:20 +00:00
|
|
|
ctx.Data["IsProjectEnabled"] = true
|
|
|
|
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
|
2023-01-20 11:42:33 +00:00
|
|
|
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
|
|
|
ctx.Data["ContextUser"] = ctx.ContextUser
|
2023-05-09 05:57:24 +00: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 11:42:33 +00:00
|
|
|
}
|