Skip to content

Commit dee2f54

Browse files
committed
remove unused template variables
1 parent 32b1762 commit dee2f54

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

routers/repo/view.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,11 @@ func renderDirectory(ctx *context.Context, treeLink string) {
9494
d, _ := ioutil.ReadAll(dataRc)
9595
buf = append(buf, d...)
9696
ctx.Data["IsRenderedHTML"] = true
97-
newbuf := markup.Render(readmeFile.Name(), buf, treeLink, ctx.Repo.Repository.ComposeMetas())
98-
if newbuf != nil {
99-
ctx.Data["IsMarkup"] = true
97+
if markup.Type(readmeFile.Name()) != "" {
98+
ctx.Data["FileContent"] = string(markup.Render(readmeFile.Name(), buf, treeLink, ctx.Repo.Repository.ComposeMetas()))
10099
} else {
101-
// FIXME This is the only way to show non-markdown files
102-
// instead of a broken "View Raw" link
103-
ctx.Data["IsMarkup"] = false
104-
newbuf = bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1)
100+
ctx.Data["FileContent"] = string(bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1))
105101
}
106-
ctx.Data["FileContent"] = string(newbuf)
107102
}
108103
}
109104

@@ -196,15 +191,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
196191
d, _ := ioutil.ReadAll(dataRc)
197192
buf = append(buf, d...)
198193

199-
tp := markup.Type(blob.Name())
200-
isSupportedMarkup := tp != ""
201-
ctx.Data["IsMarkup"] = isSupportedMarkup
202194
readmeExist := markup.IsReadmeFile(blob.Name())
203195
ctx.Data["ReadmeExist"] = readmeExist
204-
ctx.Data["IsRenderedHTML"] = true
205-
if isSupportedMarkup {
196+
if markup.Type(blob.Name()) != "" {
197+
ctx.Data["IsRenderedHTML"] = true
206198
ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
207199
} else if readmeExist {
200+
ctx.Data["IsRenderedHTML"] = true
208201
ctx.Data["FileContent"] = string(bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1))
209202
} else {
210203
// Building code view blocks with line number on server side.

0 commit comments

Comments
 (0)