aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-02-07 11:49:11 -0500
committerUnknwon <u@gogs.io>2016-02-07 11:49:11 -0500
commitf15a2f9b25bbec130915fec5b33c7e49dc7cf57d (patch)
tree1ba3aa079c4f931a6fef87693cf83e731a323bcc /routers
parent3b102a71a2cef4a3cdb748bbc6e0499fdec5e3b4 (diff)
parent2bfb8bb5fdebb4ae02c83a271e8eb24bc68afec1 (diff)
downloadgitea-f15a2f9b25bbec130915fec5b33c7e49dc7cf57d.tar.gz
gitea-f15a2f9b25bbec130915fec5b33c7e49dc7cf57d.zip
Merge pull request #2528 from andreynering/diff-sintax-highlight-733
Enable syntax highlighting on diff view
Diffstat (limited to 'routers')
-rw-r--r--routers/install.go4
-rw-r--r--routers/repo/commit.go1
-rw-r--r--routers/repo/pull.go2
-rw-r--r--routers/repo/view.go3
4 files changed, 7 insertions, 3 deletions
diff --git a/routers/install.go b/routers/install.go
index b311355bf8..fc9e5ec5e1 100644
--- a/routers/install.go
+++ b/routers/install.go
@@ -28,7 +28,7 @@ import (
"github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/setting"
"github.com/gogits/gogs/modules/ssh"
- "github.com/gogits/gogs/modules/template"
+ "github.com/gogits/gogs/modules/template/highlight"
"github.com/gogits/gogs/modules/user"
)
@@ -56,7 +56,7 @@ func NewServices() {
// GlobalInit is for global configuration reload-able.
func GlobalInit() {
setting.NewContext()
- template.NewContext()
+ highlight.NewContext()
log.Trace("Custom path: %s", setting.CustomPath)
log.Trace("Log path: %s", setting.LogRootPath)
models.LoadConfigs()
diff --git a/routers/repo/commit.go b/routers/repo/commit.go
index c3fc4d177a..781c3da946 100644
--- a/routers/repo/commit.go
+++ b/routers/repo/commit.go
@@ -183,6 +183,7 @@ func Diff(ctx *middleware.Context) {
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", parents[0])
}
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitID)
+ ctx.Data["RequireHighlightJS"] = true
ctx.HTML(200, DIFF)
}
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index e3500716d3..3240461c84 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -362,6 +362,7 @@ func ViewPullFiles(ctx *middleware.Context) {
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "src", endCommitID)
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "src", startCommitID)
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "raw", endCommitID)
+ ctx.Data["RequireHighlightJS"] = true
ctx.HTML(200, PULL_FILES)
}
@@ -538,6 +539,7 @@ func CompareAndPullRequest(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.pulls.compare_changes")
ctx.Data["PageIsComparePull"] = true
ctx.Data["IsDiffCompare"] = true
+ ctx.Data["RequireHighlightJS"] = true
renderAttachmentSettings(ctx)
headUser, headRepo, headGitRepo, prInfo, baseBranch, headBranch := ParseCompareInfo(ctx)
diff --git a/routers/repo/view.go b/routers/repo/view.go
index 25e312b1c1..6a4ad64642 100644
--- a/routers/repo/view.go
+++ b/routers/repo/view.go
@@ -19,6 +19,7 @@ import (
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/template"
+ "github.com/gogits/gogs/modules/template/highlight"
)
const (
@@ -79,7 +80,7 @@ func Home(ctx *middleware.Context) {
ctx.Data["FileSize"] = blob.Size()
ctx.Data["IsFile"] = true
ctx.Data["FileName"] = blob.Name()
- ctx.Data["HighlightClass"] = template.FileNameToHighlightClass(blob.Name())
+ ctx.Data["HighlightClass"] = highlight.FileNameToHighlightClass(blob.Name())
ctx.Data["FileLink"] = rawLink + "/" + treename
buf := make([]byte, 1024)