|
|
@ -191,6 +191,9 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) { |
|
|
|
ctx.Data["title"] = pageName |
|
|
|
ctx.Data["title"] = pageName |
|
|
|
ctx.Data["RequireHighlightJS"] = true |
|
|
|
ctx.Data["RequireHighlightJS"] = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isSideBar := pageName == "_Sidebar" |
|
|
|
|
|
|
|
isFooter := pageName == "_Footer" |
|
|
|
|
|
|
|
|
|
|
|
// lookup filename in wiki - get filecontent, gitTree entry , real filename
|
|
|
|
// lookup filename in wiki - get filecontent, gitTree entry , real filename
|
|
|
|
data, entry, pageFilename, noEntry := wikiContentsByName(ctx, commit, pageName) |
|
|
|
data, entry, pageFilename, noEntry := wikiContentsByName(ctx, commit, pageName) |
|
|
|
if noEntry { |
|
|
|
if noEntry { |
|
|
@ -203,20 +206,30 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) { |
|
|
|
return nil, nil |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sidebarContent, _, _, _ := wikiContentsByName(ctx, commit, "_Sidebar") |
|
|
|
var sidebarContent []byte |
|
|
|
if ctx.Written() { |
|
|
|
if !isSideBar { |
|
|
|
if wikiRepo != nil { |
|
|
|
sidebarContent, _, _, _ = wikiContentsByName(ctx, commit, "_Sidebar") |
|
|
|
wikiRepo.Close() |
|
|
|
if ctx.Written() { |
|
|
|
|
|
|
|
if wikiRepo != nil { |
|
|
|
|
|
|
|
wikiRepo.Close() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
} |
|
|
|
return nil, nil |
|
|
|
} else { |
|
|
|
|
|
|
|
sidebarContent = data |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
footerContent, _, _, _ := wikiContentsByName(ctx, commit, "_Footer") |
|
|
|
var footerContent []byte |
|
|
|
if ctx.Written() { |
|
|
|
if !isFooter { |
|
|
|
if wikiRepo != nil { |
|
|
|
footerContent, _, _, _ = wikiContentsByName(ctx, commit, "_Footer") |
|
|
|
wikiRepo.Close() |
|
|
|
if ctx.Written() { |
|
|
|
|
|
|
|
if wikiRepo != nil { |
|
|
|
|
|
|
|
wikiRepo.Close() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
} |
|
|
|
return nil, nil |
|
|
|
} else { |
|
|
|
|
|
|
|
footerContent = data |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rctx := &markup.RenderContext{ |
|
|
|
rctx := &markup.RenderContext{ |
|
|
@ -237,27 +250,35 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) { |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["EscapeStatus"], ctx.Data["content"] = charset.EscapeControlString(buf.String()) |
|
|
|
ctx.Data["EscapeStatus"], ctx.Data["content"] = charset.EscapeControlString(buf.String()) |
|
|
|
|
|
|
|
|
|
|
|
buf.Reset() |
|
|
|
if !isSideBar { |
|
|
|
if err := markdown.Render(rctx, bytes.NewReader(sidebarContent), &buf); err != nil { |
|
|
|
buf.Reset() |
|
|
|
if wikiRepo != nil { |
|
|
|
if err := markdown.Render(rctx, bytes.NewReader(sidebarContent), &buf); err != nil { |
|
|
|
wikiRepo.Close() |
|
|
|
if wikiRepo != nil { |
|
|
|
|
|
|
|
wikiRepo.Close() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ctx.ServerError("Render", err) |
|
|
|
|
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.ServerError("Render", err) |
|
|
|
ctx.Data["sidebarPresent"] = sidebarContent != nil |
|
|
|
return nil, nil |
|
|
|
ctx.Data["sidebarEscapeStatus"], ctx.Data["sidebarContent"] = charset.EscapeControlString(buf.String()) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ctx.Data["sidebarPresent"] = false |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["sidebarPresent"] = sidebarContent != nil |
|
|
|
|
|
|
|
ctx.Data["sidebarEscapeStatus"], ctx.Data["sidebarContent"] = charset.EscapeControlString(buf.String()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset() |
|
|
|
if !isFooter { |
|
|
|
if err := markdown.Render(rctx, bytes.NewReader(footerContent), &buf); err != nil { |
|
|
|
buf.Reset() |
|
|
|
if wikiRepo != nil { |
|
|
|
if err := markdown.Render(rctx, bytes.NewReader(footerContent), &buf); err != nil { |
|
|
|
wikiRepo.Close() |
|
|
|
if wikiRepo != nil { |
|
|
|
|
|
|
|
wikiRepo.Close() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ctx.ServerError("Render", err) |
|
|
|
|
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.ServerError("Render", err) |
|
|
|
ctx.Data["footerPresent"] = footerContent != nil |
|
|
|
return nil, nil |
|
|
|
ctx.Data["footerEscapeStatus"], ctx.Data["footerContent"] = charset.EscapeControlString(buf.String()) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ctx.Data["footerPresent"] = false |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["footerPresent"] = footerContent != nil |
|
|
|
|
|
|
|
ctx.Data["footerEscapeStatus"], ctx.Data["footerContent"] = charset.EscapeControlString(buf.String()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get commit count - wiki revisions
|
|
|
|
// get commit count - wiki revisions
|
|
|
|
commitsCount, _ := wikiRepo.FileCommitsCount("master", pageFilename) |
|
|
|
commitsCount, _ := wikiRepo.FileCommitsCount("master", pageFilename) |
|
|
|