1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-04 08:17:24 -05:00

Merge pull request #95 from odinuge/readmeTxt

Fix rendering of non-markdown readme files
This commit is contained in:
Matthias Loibl 2016-11-06 19:54:46 +01:00 committed by GitHub
commit 92c48dabe3

View File

@ -88,6 +88,9 @@ func renderDirectory(ctx *context.Context, treeLink string) {
ctx.Data["IsMarkdown"] = true ctx.Data["IsMarkdown"] = true
buf = markdown.Render(buf, treeLink, ctx.Repo.Repository.ComposeMetas()) buf = markdown.Render(buf, treeLink, ctx.Repo.Repository.ComposeMetas())
default: 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) buf = bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1)
} }
ctx.Data["FileContent"] = string(buf) 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()) readmeExist := isMarkdown || markdown.IsReadmeFile(blob.Name())
ctx.Data["ReadmeExist"] = readmeExist ctx.Data["ReadmeExist"] = readmeExist
if readmeExist { if readmeExist && isMarkdown {
// TODO: don't need to render if it's a README but not Markdown file.
ctx.Data["FileContent"] = string(markdown.Render(buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas())) ctx.Data["FileContent"] = string(markdown.Render(buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
} else { } else {
// Building code view blocks with line number on server side. // Building code view blocks with line number on server side.