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