From 573c8d2b53cbc189af310bf69f0a88395ae9bb58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Sat, 26 Dec 2015 13:56:00 +0100 Subject: [PATCH] Unified/Inline Diff-View Selectable --- routers/repo/commit.go | 2 ++ templates/repo/diff_box.tmpl | 19 +++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 10c2f8a1c..11d9fcbe3 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -168,6 +168,7 @@ func Diff(ctx *middleware.Context) { } } + ctx.Data["Style"] = ctx.Query("style") == "unified"; ctx.Data["Username"] = userName ctx.Data["Reponame"] = repoName ctx.Data["IsImageFile"] = commit.IsImageFile @@ -213,6 +214,7 @@ func CompareDiff(ctx *middleware.Context) { } commits = models.ValidateCommitsWithEmails(commits) + ctx.Data["Style"] = ctx.Query("style") == "unified"; ctx.Data["CommitRepoLink"] = ctx.Repo.RepoLink ctx.Data["Commits"] = commits ctx.Data["CommitCount"] = commits.Len() diff --git a/templates/repo/diff_box.tmpl b/templates/repo/diff_box.tmpl index bfcad4a1b..08afad145 100644 --- a/templates/repo/diff_box.tmpl +++ b/templates/repo/diff_box.tmpl @@ -6,10 +6,8 @@ {{.i18n.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}}
-
- - -
+ + {{ if .Style }}Inline{{else}}Unified{{end}}
@@ -36,10 +34,11 @@ -
- {{ template "repo/diff_box_unified.tmpl" . }} -
-
- {{ template "repo/diff_box_inline.tmpl" . }} -
+ {{if .Style}} + {{ template "repo/diff_box_unified" . }} + {{else}} + {{ template "repo/diff_box_inline" . }} + {{end}} + {{end}}