diff options
author | zeripath <art27@cantab.net> | 2022-02-05 18:26:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-05 18:26:12 +0000 |
commit | 933e819165acde362d5d9ab72c3bcf7c9b399ae6 (patch) | |
tree | 568d96ccb85c142ad7df8b2acbc356019ba473b7 /routers/web/web.go | |
parent | aa23f477b7f66273f7e9551282230386b7de2d8a (diff) | |
download | gitea-933e819165acde362d5d9ab72c3bcf7c9b399ae6.tar.gz gitea-933e819165acde362d5d9ab72c3bcf7c9b399ae6.zip |
Ensure that blob-excerpt links work for wiki (#18587)
It appears that the blob-excerpt links do not work on the wiki - likely since their
introduction.
This PR adds support for the wiki on these links.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'routers/web/web.go')
-rw-r--r-- | routers/web/web.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/routers/web/web.go b/routers/web/web.go index 545194aabd..60a379aef8 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -5,6 +5,7 @@ package web import ( + gocontext "context" "net/http" "os" "path" @@ -956,7 +957,25 @@ func RegisterRoutes(m *web.Route) { m.Group("/blob_excerpt", func() { m.Get("/{sha}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.ExcerptBlob) - }, repo.MustBeNotEmpty, context.RepoRef(), reqRepoCodeReader) + }, func(ctx *context.Context) (cancel gocontext.CancelFunc) { + if ctx.FormBool("wiki") { + ctx.Data["PageIsWiki"] = true + repo.MustEnableWiki(ctx) + return + } + + reqRepoCodeReader(ctx) + if ctx.Written() { + return + } + cancel = context.RepoRef()(ctx) + if ctx.Written() { + return + } + + repo.MustBeNotEmpty(ctx) + return + }) m.Group("/pulls/{index}", func() { m.Get(".diff", repo.DownloadPullDiff) |