|
|
@ -19,6 +19,7 @@ import ( |
|
|
|
"github.com/gogits/gogs/modules/context" |
|
|
|
"github.com/gogits/gogs/modules/context" |
|
|
|
"github.com/gogits/gogs/modules/log" |
|
|
|
"github.com/gogits/gogs/modules/log" |
|
|
|
"github.com/gogits/gogs/modules/markdown" |
|
|
|
"github.com/gogits/gogs/modules/markdown" |
|
|
|
|
|
|
|
"github.com/gogits/gogs/modules/setting" |
|
|
|
"github.com/gogits/gogs/modules/template" |
|
|
|
"github.com/gogits/gogs/modules/template" |
|
|
|
"github.com/gogits/gogs/modules/template/highlight" |
|
|
|
"github.com/gogits/gogs/modules/template/highlight" |
|
|
|
) |
|
|
|
) |
|
|
@ -104,20 +105,25 @@ func Home(ctx *context.Context) { |
|
|
|
case isImageFile: |
|
|
|
case isImageFile: |
|
|
|
ctx.Data["IsImageFile"] = true |
|
|
|
ctx.Data["IsImageFile"] = true |
|
|
|
case isTextFile: |
|
|
|
case isTextFile: |
|
|
|
d, _ := ioutil.ReadAll(dataRc) |
|
|
|
if blob.Size() >= setting.MaxDisplayFileSize { |
|
|
|
buf = append(buf, d...) |
|
|
|
ctx.Data["IsFileTooLarge"] = true |
|
|
|
readmeExist := markdown.IsMarkdownFile(blob.Name()) || markdown.IsReadmeFile(blob.Name()) |
|
|
|
|
|
|
|
ctx.Data["ReadmeExist"] = readmeExist |
|
|
|
|
|
|
|
if readmeExist { |
|
|
|
|
|
|
|
ctx.Data["FileContent"] = string(markdown.Render(buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas())) |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if err, content := template.ToUtf8WithErr(buf); err != nil { |
|
|
|
ctx.Data["IsFileTooLarge"] = false |
|
|
|
if err != nil { |
|
|
|
d, _ := ioutil.ReadAll(dataRc) |
|
|
|
log.Error(4, "Convert content encoding: %s", err) |
|
|
|
buf = append(buf, d...) |
|
|
|
} |
|
|
|
readmeExist := markdown.IsMarkdownFile(blob.Name()) || markdown.IsReadmeFile(blob.Name()) |
|
|
|
ctx.Data["FileContent"] = string(buf) |
|
|
|
ctx.Data["ReadmeExist"] = readmeExist |
|
|
|
|
|
|
|
if readmeExist { |
|
|
|
|
|
|
|
ctx.Data["FileContent"] = string(markdown.Render(buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas())) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ctx.Data["FileContent"] = content |
|
|
|
if err, content := template.ToUtf8WithErr(buf); err != nil { |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
log.Error(4, "Convert content encoding: %s", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ctx.Data["FileContent"] = string(buf) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ctx.Data["FileContent"] = content |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|