Skip to content

Commit cb38c04

Browse files
author
Aly Sewelam
committed
Handle .org files in Sidebar and footer of wiki
Used Git filename to properly handle .org files
1 parent cb93344 commit cb38c04

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

routers/web/repo/wiki.go

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -316,26 +316,38 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
316316
}
317317

318318
if !isSideBar {
319-
sidebarContent, _, _, _ := wikiContentsByName(ctx, commit, "_Sidebar")
319+
sidebarContent, sidebarEntry, sidebarFilename, _ := wikiContentsByName(ctx, commit, "_Sidebar")
320320
if ctx.Written() {
321321
return nil, nil
322322
}
323-
ctx.Data["WikiSidebarEscapeStatus"], ctx.Data["WikiSidebarHTML"], err = renderFn(sidebarContent)
324-
if err != nil {
325-
ctx.ServerError("Render", err)
326-
return nil, nil
323+
if sidebarEntry != nil && sidebarContent != nil {
324+
// Use the git filename returned by wikiContentsByName, which correctly handles .org files
325+
if sidebarFilename == "" {
326+
sidebarFilename = sidebarEntry.Name()
327+
}
328+
ctx.Data["WikiSidebarEscapeStatus"], ctx.Data["WikiSidebarHTML"], err = renderFn(sidebarContent, sidebarFilename)
329+
if err != nil {
330+
ctx.ServerError("Render", err)
331+
return nil, nil
332+
}
327333
}
328334
}
329335

330336
if !isFooter {
331-
footerContent, _, _, _ := wikiContentsByName(ctx, commit, "_Footer")
337+
footerContent, footerEntry, footerFilename, _ := wikiContentsByName(ctx, commit, "_Footer")
332338
if ctx.Written() {
333339
return nil, nil
334340
}
335-
ctx.Data["WikiFooterEscapeStatus"], ctx.Data["WikiFooterHTML"], err = renderFn(footerContent)
336-
if err != nil {
337-
ctx.ServerError("Render", err)
338-
return nil, nil
341+
if footerEntry != nil && footerContent != nil {
342+
// Use git filename here too to handle .org files correctly
343+
if footerFilename == "" {
344+
footerFilename = footerEntry.Name()
345+
}
346+
ctx.Data["WikiFooterEscapeStatus"], ctx.Data["WikiFooterHTML"], err = renderFn(footerContent, footerFilename)
347+
if err != nil {
348+
ctx.ServerError("Render", err)
349+
return nil, nil
350+
}
339351
}
340352
}
341353

0 commit comments

Comments
 (0)