summaryrefslogtreecommitdiffstats
path: root/routers/repo/repo.go
diff options
context:
space:
mode:
authorslene <vslene@gmail.com>2014-03-28 00:30:20 +0800
committerslene <vslene@gmail.com>2014-03-28 00:30:20 +0800
commit346db02d89ae0337956607eec43a0cd3f184fda8 (patch)
tree5caaf3f50191b211f44b5ff8253df5856afab50c /routers/repo/repo.go
parent16cb1e974ca2e34384cd7882886f46f860ea5640 (diff)
downloadgitea-346db02d89ae0337956607eec43a0cd3f184fda8.tar.gz
gitea-346db02d89ae0337956607eec43a0cd3f184fda8.zip
fix image display
Diffstat (limited to 'routers/repo/repo.go')
-rw-r--r--routers/repo/repo.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index 3c8d24a6a6..4573a3e48c 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -120,15 +120,20 @@ func Single(ctx *middleware.Context, params martini.Params) {
data := blob.Contents()
_, isTextFile := base.IsTextFile(data)
+ _, isImageFile := base.IsImageFile(data)
ctx.Data["FileIsText"] = isTextFile
- readmeExist := base.IsMarkdownFile(repoFile.Name) || base.IsReadmeFile(repoFile.Name)
- ctx.Data["ReadmeExist"] = readmeExist
- if readmeExist {
- ctx.Data["FileContent"] = string(base.RenderMarkdown(data, ""))
+ if isImageFile {
+ ctx.Data["IsImageFile"] = true
} else {
- if isTextFile {
- ctx.Data["FileContent"] = string(data)
+ readmeExist := base.IsMarkdownFile(repoFile.Name) || base.IsReadmeFile(repoFile.Name)
+ ctx.Data["ReadmeExist"] = readmeExist
+ if readmeExist {
+ ctx.Data["FileContent"] = string(base.RenderMarkdown(data, ""))
+ } else {
+ if isTextFile {
+ ctx.Data["FileContent"] = string(data)
+ }
}
}
}
@@ -236,9 +241,9 @@ func SingleDownload(ctx *middleware.Context, params martini.Params) {
data := blob.Contents()
contentType, isTextFile := base.IsTextFile(data)
+ _, isImageFile := base.IsImageFile(data)
ctx.Res.Header().Set("Content-Type", contentType)
if !isTextFile {
- ctx.Res.Header().Set("Content-Type", contentType)
ctx.Res.Header().Set("Content-Disposition", "attachment; filename="+filepath.Base(treename))
ctx.Res.Header().Set("Content-Transfer-Encoding", "binary")
}