#3559 fix template error
This commit is contained in:
parent
c2afdf2192
commit
dadd35b636
5 changed files with 10 additions and 11 deletions
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.9.97.0830"
|
||||
const APP_VER = "0.9.97.0831"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
|
|
@ -518,7 +518,11 @@ func IsLetter(ch rune) bool {
|
|||
return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= 0x80 && unicode.IsLetter(ch)
|
||||
}
|
||||
|
||||
// IsTextFile returns true if file content format is plain text or empty.
|
||||
func IsTextFile(data []byte) bool {
|
||||
if len(data) == 0 {
|
||||
return true
|
||||
}
|
||||
return strings.Index(http.DetectContentType(data), "text/") != -1
|
||||
}
|
||||
|
||||
|
|
|
@ -64,9 +64,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
|||
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := dataRc.Read(buf)
|
||||
if n > 0 {
|
||||
buf = buf[:n]
|
||||
}
|
||||
buf = buf[:n]
|
||||
|
||||
// Only text file are editable online.
|
||||
if !base.IsTextFile(buf) {
|
||||
|
|
|
@ -64,6 +64,7 @@ func renderDirectory(ctx *context.Context, treeLink string) {
|
|||
}
|
||||
|
||||
if readmeFile != nil {
|
||||
ctx.Data["RawFileLink"] = ""
|
||||
ctx.Data["ReadmeInList"] = true
|
||||
ctx.Data["ReadmeExist"] = true
|
||||
|
||||
|
@ -75,9 +76,7 @@ func renderDirectory(ctx *context.Context, treeLink string) {
|
|||
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := dataRc.Read(buf)
|
||||
if n > 0 {
|
||||
buf = buf[:n]
|
||||
}
|
||||
buf = buf[:n]
|
||||
|
||||
isTextFile := base.IsTextFile(buf)
|
||||
ctx.Data["FileIsText"] = isTextFile
|
||||
|
@ -134,9 +133,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
|
|||
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := dataRc.Read(buf)
|
||||
if n > 0 {
|
||||
buf = buf[:n]
|
||||
}
|
||||
buf = buf[:n]
|
||||
|
||||
isTextFile := base.IsTextFile(buf)
|
||||
ctx.Data["IsTextFile"] = isTextFile
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.9.97.0830
|
||||
0.9.97.0831
|
Reference in a new issue