1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Use repo as of renderctx's member rather than a repoPath on metas (#29222)

Use a `gitrepo.Repository` in the markup's RenderContext but not store
the repository's path.
This commit is contained in:
Lunny Xiao
2024-05-30 15:04:01 +08:00
committed by GitHub
parent d612a24e3e
commit 015efcd8bf
19 changed files with 135 additions and 48 deletions

View File

@@ -9,6 +9,7 @@ import (
"net/http"
"strings"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
@@ -66,7 +67,9 @@ func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPr
}
meta := map[string]string{}
var repoCtx *repo_model.Repository
if repo != nil && repo.Repository != nil {
repoCtx = repo.Repository
if mode == "comment" {
meta = repo.Repository.ComposeMetas(ctx)
} else {
@@ -78,7 +81,8 @@ func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPr
}
if err := markup.Render(&markup.RenderContext{
Ctx: ctx,
Ctx: ctx,
Repo: repoCtx,
Links: markup.Links{
AbsolutePrefix: true,
Base: urlPrefix,