Browse Source

display large file

for-closed-social
slene 10 years ago
parent
commit
e323604d78
1 changed files with 4 additions and 5 deletions
  1. +4
    -5
      routers/repo/repo.go

+ 4
- 5
routers/repo/repo.go View File

@ -176,9 +176,10 @@ func Single(ctx *middleware.Context, params martini.Params) {
_, isImageFile := base.IsImageFile(buf) _, isImageFile := base.IsImageFile(buf)
ctx.Data["FileIsText"] = isTextFile ctx.Data["FileIsText"] = isTextFile
if isImageFile {
switch {
case isImageFile:
ctx.Data["IsImageFile"] = true ctx.Data["IsImageFile"] = true
} else {
case isTextFile:
d, _ := ioutil.ReadAll(dataRc) d, _ := ioutil.ReadAll(dataRc)
buf = append(buf, d...) buf = append(buf, d...)
readmeExist := base.IsMarkdownFile(blob.Name()) || base.IsReadmeFile(blob.Name()) readmeExist := base.IsMarkdownFile(blob.Name()) || base.IsReadmeFile(blob.Name())
@ -186,9 +187,7 @@ func Single(ctx *middleware.Context, params martini.Params) {
if readmeExist { if readmeExist {
ctx.Data["FileContent"] = string(base.RenderMarkdown(buf, "")) ctx.Data["FileContent"] = string(base.RenderMarkdown(buf, ""))
} else { } else {
if isTextFile {
ctx.Data["FileContent"] = string(buf)
}
ctx.Data["FileContent"] = string(buf)
} }
} }
} }

Loading…
Cancel
Save