aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/org/home.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-11-24 16:18:57 +0800
committerGitHub <noreply@github.com>2024-11-24 16:18:57 +0800
commit633785a5f3fe00789a6cba7cc0db1333de1e9c52 (patch)
tree2a2703ee9ed41c9caa508bd72c3fb5b52716af16 /routers/web/org/home.go
parentfa175c16949f09757ae85db6697cec327c44cba9 (diff)
downloadgitea-633785a5f3fe00789a6cba7cc0db1333de1e9c52.tar.gz
gitea-633785a5f3fe00789a6cba7cc0db1333de1e9c52.zip
Refactor markup render system (#32612)
This PR removes (almost) all path tricks, and introduces "renderhelper" package. Now we can clearly see the rendering behaviors for comment/file/wiki, more details are in "renderhelper" tests. Fix #31411 , fix #18592, fix #25632 and maybe more problems. (ps: fix #32608 by the way)
Diffstat (limited to 'routers/web/org/home.go')
-rw-r--r--routers/web/org/home.go16
1 files changed, 5 insertions, 11 deletions
diff --git a/routers/web/org/home.go b/routers/web/org/home.go
index d0ac82b1b0..f02c08ae76 100644
--- a/routers/web/org/home.go
+++ b/routers/web/org/home.go
@@ -11,10 +11,10 @@ import (
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/organization"
+ "code.gitea.io/gitea/models/renderhelper"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
@@ -180,16 +180,10 @@ func prepareOrgProfileReadme(ctx *context.Context, viewRepositories bool) bool {
if bytes, err := profileReadme.GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil {
log.Error("failed to GetBlobContent: %v", err)
} else {
- if profileContent, err := markdown.RenderString(markup.NewRenderContext(ctx).
- WithGitRepo(profileGitRepo).
- WithLinks(markup.Links{
- // Pass repo link to markdown render for the full link of media elements.
- // The profile of default branch would be shown.
- Base: profileDbRepo.Link(),
- BranchPath: path.Join("branch", util.PathEscapeSegments(profileDbRepo.DefaultBranch)),
- }).
- WithMetas(markup.ComposeSimpleDocumentMetas()),
- bytes); err != nil {
+ rctx := renderhelper.NewRenderContextRepoFile(ctx, profileDbRepo, renderhelper.RepoFileOptions{
+ CurrentRefPath: path.Join("branch", util.PathEscapeSegments(profileDbRepo.DefaultBranch)),
+ })
+ if profileContent, err := markdown.RenderString(rctx, bytes); err != nil {
log.Error("failed to RenderString: %v", err)
} else {
ctx.Data["ProfileReadme"] = profileContent