aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/view.go
diff options
context:
space:
mode:
authorlunnyxiao <xiaolunwen@gmail.com>2014-09-17 12:03:03 +0800
committerlunnyxiao <xiaolunwen@gmail.com>2014-09-17 12:03:03 +0800
commited84adb679f3de70b2bffaead20a87711c38ee3a (patch)
treeff303000a735b237c8f45bbcc8018da185beb114 /routers/repo/view.go
parentefb68a0a96574a334a3ec791c0a7f2bc6b96d006 (diff)
downloadgitea-ed84adb679f3de70b2bffaead20a87711c38ee3a.tar.gz
gitea-ed84adb679f3de70b2bffaead20a87711c38ee3a.zip
toutf8 improved & add max git diff lines
Diffstat (limited to 'routers/repo/view.go')
-rw-r--r--routers/repo/view.go20
1 files changed, 1 insertions, 19 deletions
diff --git a/routers/repo/view.go b/routers/repo/view.go
index f98eee037d..e42894ae73 100644
--- a/routers/repo/view.go
+++ b/routers/repo/view.go
@@ -11,12 +11,9 @@ import (
"path/filepath"
"strings"
- "github.com/saintfish/chardet"
-
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/log"
- "github.com/gogits/gogs/modules/mahonia"
"github.com/gogits/gogs/modules/middleware"
)
@@ -24,21 +21,6 @@ const (
HOME base.TplName = "repo/home"
)
-func toUtf8(content []byte) (error, string) {
- detector := chardet.NewTextDetector()
- result, err := detector.DetectBest(content)
- if err != nil {
- return err, ""
- }
-
- if result.Charset == "utf8" {
- return nil, string(content)
- }
-
- decoder := mahonia.NewDecoder(result.Charset)
- return nil, decoder.ConvertString(string(content))
-}
-
func Home(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Repo.Repository.Name
@@ -117,7 +99,7 @@ func Home(ctx *middleware.Context) {
if readmeExist {
ctx.Data["FileContent"] = string(base.RenderMarkdown(buf, ""))
} else {
- if err, content := toUtf8(buf); err != nil {
+ if err, content := base.ToUtf8WithErr(buf); err != nil {
if err != nil {
log.Error(4, "Convert content encoding: %s", err)
}