diff options
author | Odin Ugedal <odin@ugedal.com> | 2016-10-13 20:17:06 +0200 |
---|---|---|
committer | Odin Ugedal <odin@ugedal.com> | 2016-11-06 16:02:42 +0100 |
commit | 530f6c1da4fb1ead06e70300ccab07eb133551e8 (patch) | |
tree | fb950d52133299cb3bce70fb83376bd1e6949997 /routers | |
parent | 6e4252dad4d162fb582c012efecd29e9fdf5819c (diff) | |
download | gitea-530f6c1da4fb1ead06e70300ccab07eb133551e8.tar.gz gitea-530f6c1da4fb1ead06e70300ccab07eb133551e8.zip |
Fix rendering of non-markdown readme files
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/view.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/routers/repo/view.go b/routers/repo/view.go index ef180b773f..499cf2d470 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -88,6 +88,9 @@ func renderDirectory(ctx *context.Context, treeLink string) { ctx.Data["IsMarkdown"] = true buf = markdown.Render(buf, treeLink, ctx.Repo.Repository.ComposeMetas()) default: + // FIXME This is the only way to show non-markdown files + // instead of a broken "View Raw" link + ctx.Data["IsMarkdown"] = true buf = bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1) } ctx.Data["FileContent"] = string(buf) @@ -156,8 +159,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st readmeExist := isMarkdown || markdown.IsReadmeFile(blob.Name()) ctx.Data["ReadmeExist"] = readmeExist - if readmeExist { - // TODO: don't need to render if it's a README but not Markdown file. + if readmeExist && isMarkdown { ctx.Data["FileContent"] = string(markdown.Render(buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas())) } else { // Building code view blocks with line number on server side. |