mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-15 15:46:49 +02:00
blob: use NewTruncatedReader for markdown
This commit is contained in:
parent
c78f56e7cb
commit
dd79f0ce2b
5 changed files with 167 additions and 9 deletions
|
@ -175,10 +175,12 @@ func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repositor
|
|||
return
|
||||
}
|
||||
|
||||
if bytes, err := profileReadme.GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil {
|
||||
log.Error("failed to GetBlobContent: %v", err)
|
||||
if rc, _, err := profileReadme.NewTruncatedReader(setting.UI.MaxDisplayFileSize); err != nil {
|
||||
log.Error("failed to NewTruncatedReader: %v", err)
|
||||
} else {
|
||||
if profileContent, err := markdown.RenderString(&markup.RenderContext{
|
||||
defer rc.Close()
|
||||
|
||||
if profileContent, err := markdown.RenderReader(&markup.RenderContext{
|
||||
Ctx: ctx,
|
||||
GitRepo: profileGitRepo,
|
||||
Links: markup.Links{
|
||||
|
@ -188,7 +190,7 @@ func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repositor
|
|||
BranchPath: path.Join("branch", util.PathEscapeSegments(profileDbRepo.DefaultBranch)),
|
||||
},
|
||||
Metas: map[string]string{"mode": "document"},
|
||||
}, bytes); err != nil {
|
||||
}, rc); err != nil {
|
||||
log.Error("failed to RenderString: %v", err)
|
||||
} else {
|
||||
ctx.Data["ProfileReadme"] = profileContent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue