Browse Source

Fix rendering of non-markdown readme files

Odin Ugedal 3 years ago
parent
commit
530f6c1da4
1 changed files with 4 additions and 2 deletions
  1. 4 2
      routers/repo/view.go

+ 4 - 2
routers/repo/view.go

@@ -88,6 +88,9 @@ func renderDirectory(ctx *context.Context, treeLink string) {
88 88
 				ctx.Data["IsMarkdown"] = true
89 89
 				buf = markdown.Render(buf, treeLink, ctx.Repo.Repository.ComposeMetas())
90 90
 			default:
91
+				// FIXME This is the only way to show non-markdown files
92
+				// instead of a broken "View Raw" link
93
+				ctx.Data["IsMarkdown"] = true
91 94
 				buf = bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1)
92 95
 			}
93 96
 			ctx.Data["FileContent"] = string(buf)
@@ -156,8 +159,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
156 159
 
157 160
 		readmeExist := isMarkdown || markdown.IsReadmeFile(blob.Name())
158 161
 		ctx.Data["ReadmeExist"] = readmeExist
159
-		if readmeExist {
160
-			// TODO: don't need to render if it's a README but not Markdown file.
162
+		if readmeExist && isMarkdown {
161 163
 			ctx.Data["FileContent"] = string(markdown.Render(buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
162 164
 		} else {
163 165
 			// Building code view blocks with line number on server side.