diff --git a/public/css/gogs.css b/public/css/gogs.css
index 1ed66997d..27f3211e7 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -735,6 +735,18 @@ pre.raw {
line-height: 1.5;
overflow: auto;
}
+pre.wrap {
+ white-space: pre-wrap;
+ /* CSS 3 */
+ white-space: -moz-pre-wrap;
+ /* Mozilla, since 1999 */
+ white-space: -pre-wrap;
+ /* Opera 4-6 */
+ white-space: -o-pre-wrap;
+ /* Opera 7 */
+ word-wrap: break-word;
+ /* Internet Explorer 5.5+ */
+}
.full.height {
padding: 0;
margin: 0 0 -80px 0;
@@ -2325,6 +2337,10 @@ footer .container .links > *:first-child {
background: #fafafa;
width: 1%;
}
+.repository .diff-file-box .file-body.file-code .lines-num span.fold {
+ display: block;
+ text-align: center;
+}
.repository .diff-file-box .file-body.file-code .lines-num-old {
border-right: 1px solid #DDD;
}
@@ -2350,16 +2366,33 @@ footer .container .links > *:first-child {
padding-top: 4px;
padding-bottom: 4px;
}
+.repository .diff-file-box .code-diff tbody tr.tag-code td.halfwidth {
+ width: 50%;
+}
+.repository .diff-file-box .code-diff tbody tr.del-code td.add-code {
+ background-color: #eaffea !important;
+ border-color: #c1e9c1 !important;
+}
+.repository .diff-file-box .code-diff tbody tr.del-code td.add-code pre {
+ background-color: #eaffea !important;
+ border-color: #c1e9c1 !important;
+}
.repository .diff-file-box .code-diff tbody tr.del-code td,
.repository .diff-file-box .code-diff tbody tr.del-code pre {
background-color: #ffecec !important;
border-color: #f1c0c0 !important;
}
+.repository .diff-file-box .code-diff tbody tr.del-code td.halfwidth {
+ width: 50%;
+}
.repository .diff-file-box .code-diff tbody tr.add-code td,
.repository .diff-file-box .code-diff tbody tr.add-code pre {
background-color: #eaffea !important;
border-color: #c1e9c1 !important;
}
+.repository .diff-file-box .code-diff tbody tr.add-code td.halfwidth {
+ width: 50%;
+}
.repository .diff-file-box.file-content img {
max-width: 100%;
padding: 5px 5px 0 5px;
diff --git a/public/less/_base.less b/public/less/_base.less
index ab2785ff5..c07c81db4 100644
--- a/public/less/_base.less
+++ b/public/less/_base.less
@@ -19,6 +19,13 @@ pre {
line-height: 1.5;
overflow: auto;
}
+ &.wrap {
+ white-space: pre-wrap; /* CSS 3 */
+ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word; /* Internet Explorer 5.5+ */
+ }
}
.full.height {
padding: 0;
diff --git a/public/less/_repository.less b/public/less/_repository.less
index 9891886e8..441832daf 100644
--- a/public/less/_repository.less
+++ b/public/less/_repository.less
@@ -668,6 +668,11 @@
color: #A7A7A7;
background: #fafafa;
width: 1%;
+
+ span.fold {
+ display: block;
+ text-align: center;
+ }
}
.lines-num-old {
border-right: 1px solid #DDD;
@@ -698,6 +703,9 @@
padding-top: 4px;
padding-bottom: 4px;
}
+ td.halfwidth {
+ width: 50%;
+ }
// td.selected-line, td.selected-line pre {
// background-color: #ffffdd !important;
// }
@@ -708,10 +716,23 @@
// }
// }
&.del-code {
+ td.add-code {
+ background-color: #eaffea !important;
+ border-color: #c1e9c1 !important;
+ pre {
+ background-color: #eaffea !important;
+ border-color: #c1e9c1 !important;
+
+ }
+ }
td, pre {
background-color: #ffecec !important;
border-color: #f1c0c0 !important;
}
+
+ td.halfwidth {
+ width: 50%;
+ }
// td.selected-line, td.selected-line pre {
// background-color: #ffffdd !important;
// }
@@ -721,6 +742,9 @@
background-color: #eaffea !important;
border-color: #c1e9c1 !important;
}
+ td.halfwidth {
+ width: 50%;
+ }
// td.selected-line, td.selected-line pre {
// background-color: #ffffdd !important;
// }
diff --git a/routers/repo/commit.go b/routers/repo/commit.go
index 10c2f8a1c..997c16183 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") == "split"
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") == "split"
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 036d4a649..c408fd492 100644
--- a/templates/repo/diff_box.tmpl
+++ b/templates/repo/diff_box.tmpl
@@ -6,6 +6,7 @@
{{.i18n.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}}
@@ -32,63 +33,9 @@
- {{range $i, $file := .Diff.Files}}
-
-
-
- {{if not $file.IsRenamed}}
- {{$isImage := (call $.IsImageFile $file.Name)}}
- {{if and $isImage}}
-
-
-
- {{else}}
-
-
-
- {{range .Sections}}
- {{range $k, $line := .Lines}}
-
-
- {{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}
- |
-
- {{if $line.RightIdx}}{{$line.RightIdx}}{{end}}
- |
-
- {{$line.Content}}
- |
-
- {{end}}
- {{end}}
-
-
-
- {{end}}
- {{end}}
-
-
-
+ {{if .Style}}
+ {{ template "repo/diff_box_split" . }}
+ {{else}}
+ {{ template "repo/diff_box_inline" . }}
{{end}}
{{end}}
diff --git a/templates/repo/diff_box_inline.tmpl b/templates/repo/diff_box_inline.tmpl
new file mode 100644
index 000000000..2dea01383
--- /dev/null
+++ b/templates/repo/diff_box_inline.tmpl
@@ -0,0 +1,74 @@
+{{range $i, $file := .Diff.Files}}
+
+
+
+ {{if not $file.IsRenamed}}
+ {{$isImage := (call $.IsImageFile $file.Name)}}
+ {{if and $isImage}}
+
+
+
+ {{else}}
+
+
+
+ {{range $j, $section := .Sections}}
+ {{range $k, $line := .Lines}}
+
+ {{if eq .Type 4}}
+
+ {{if gt $j 0}}{{end}}
+ |
+ {{else}}
+
+ {{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}
+ |
+
+ {{if $line.RightIdx}}{{$line.RightIdx}}{{end}}
+ |
+ {{end}}
+
+ {{$line.Content}}
+ |
+
+ {{end}}
+ {{end}}
+
+
+
+
+ {{end}}
+ {{end}}
+
+
+
+{{end}}
diff --git a/templates/repo/diff_box_split.tmpl b/templates/repo/diff_box_split.tmpl
new file mode 100644
index 000000000..0234fd130
--- /dev/null
+++ b/templates/repo/diff_box_split.tmpl
@@ -0,0 +1,98 @@
+{{range $i, $file := .Diff.Files}}
+
+
+
+ {{if not $file.IsRenamed}}
+ {{$isImage := (call $.IsImageFile $file.Name)}}
+ {{if and $isImage}}
+
+
+
+ {{else}}
+
+
+
+ {{range $j, $section := .Sections}}
+ {{range $k, $line := .Lines}}
+
+ {{if eq .Type 4}}
+
+
+ |
+
+ {{$line.Content}}
+ |
+
+
+ |
+
+ {{$line.Content}}
+ |
+ {{else}}
+
+ {{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}
+ |
+
+ {{if $line.LeftIdx}}{{$line.Content}}{{end}}
+ |
+
+ {{if $line.RightIdx}}{{$line.RightIdx}}{{end}}
+ |
+
+ {{if $line.RightIdx}}{{$line.Content}}{{end}}
+ |
+ {{end}}
+
+ {{end}}
+ {{end}}
+
+
+
+
+ {{end}}
+ {{end}}
+
+
+
+{{end}}