From 2bfb8bb5fdebb4ae02c83a271e8eb24bc68afec1 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 31 Jan 2016 14:19:02 -0200 Subject: Enable sintax highlighting on diff view. Close #733 --- models/git_diff.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'models/git_diff.go') diff --git a/models/git_diff.go b/models/git_diff.go index e8bfe610..9796ef59 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -26,6 +26,7 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/process" + "github.com/gogits/gogs/modules/template/highlight" ) type DiffLineType uint8 @@ -160,12 +161,20 @@ type DiffFile struct { IsBin bool IsRenamed bool Sections []*DiffSection + HighlightClass string } func (diffFile *DiffFile) GetType() int { return int(diffFile.Type) } +func (diffFile *DiffFile) GetHighlightClass() string { + if diffFile.HighlightClass == "" { + diffFile.HighlightClass = highlight.FileNameToHighlightClass(diffFile.Name) + } + return diffFile.HighlightClass +} + type Diff struct { TotalAddition, TotalDeletion int Files []*DiffFile -- cgit v1.2.3