mirror of https://github.com/go-gitea/gitea.git
merged split/unified templates
parent
8fe5d887ae
commit
3870a7a3c8
|
@ -33,9 +33,124 @@
|
|||
</ol>
|
||||
</div>
|
||||
|
||||
{{range $i, $file := .Diff.Files}}
|
||||
<div class="diff-file-box diff-box file-content" id="diff-{{.Index}}">
|
||||
<h4 class="ui top attached normal header">
|
||||
<div class="diff-counter count ui left">
|
||||
{{if $file.IsBin}}
|
||||
{{$.i18n.Tr "repo.diff.bin"}}
|
||||
{{else if not $file.IsRenamed}}
|
||||
<span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
|
||||
<span class="bar">
|
||||
<span class="pull-left add"></span>
|
||||
<span class="pull-left del"></span>
|
||||
</span>
|
||||
<span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<span class="file">{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}</span>
|
||||
<div class="ui right">
|
||||
{{if $file.IsDeleted}}
|
||||
<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
|
||||
{{else}}
|
||||
<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</h4>
|
||||
<div class="ui attached table segment">
|
||||
{{if not $file.IsRenamed}}
|
||||
{{$isImage := (call $.IsImageFile $file.Name)}}
|
||||
{{if and $isImage}}
|
||||
<div class="center">
|
||||
<img src="{{$.RawPath}}/{{EscapePound .Name}}">
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="file-body file-code code-view code-diff">
|
||||
<table>
|
||||
<tbody>
|
||||
{{if $.IsSplitStyle}}
|
||||
{{range $j, $section := .Sections}}
|
||||
{{range $k, $line := .Lines}}
|
||||
<tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$k}} ol-{{$k}}">
|
||||
{{if eq .Type 4}}
|
||||
<td class="lines-num lines-num-old">
|
||||
<span class="{{if gt $j 0}}fold octicon octicon-fold{{end}}"></span>
|
||||
</td>
|
||||
<td class="lines-code halfwidth">
|
||||
<pre class="wrap">{{$line.Content}}</pre>
|
||||
</td>
|
||||
<td class="lines-num lines-num-old">
|
||||
<span class="{{if gt $j 0}}fold octicon octicon-fold{{end}}"></span>
|
||||
</td>
|
||||
<td class="lines-code halfwidth">
|
||||
<pre class="wrap">{{$line.Content}}</pre>
|
||||
</td>
|
||||
{{else}}
|
||||
<td class="lines-num lines-num-old">
|
||||
<span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
|
||||
</td>
|
||||
<td class="lines-code halfwidth">
|
||||
<pre class="wrap">{{if $line.LeftIdx}}{{$line.Content}}{{end}}</pre>
|
||||
</td>
|
||||
<td class="lines-num lines-num-new">
|
||||
<span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
|
||||
</td>
|
||||
<td class="lines-code halfwidth">
|
||||
<pre class="wrap">{{if $line.RightIdx}}{{$line.Content}}{{end}}</pre>
|
||||
</td>
|
||||
{{end}}
|
||||
</tr>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{else}}
|
||||
{{range $j, $section := .Sections}}
|
||||
{{range $k, $line := .Lines}}
|
||||
<tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$k}} ol-{{$k}}">
|
||||
{{if eq .Type 4}}
|
||||
<td colspan="2" class="lines-num">
|
||||
{{if gt $j 0}}<span class="fold octicon octicon-fold"></span>{{end}}
|
||||
</td>
|
||||
{{else}}
|
||||
<td class="lines-num lines-num-old">
|
||||
<span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
|
||||
</td>
|
||||
<td class="lines-num lines-num-new">
|
||||
<span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
|
||||
</td>
|
||||
{{end}}
|
||||
<td class="lines-code">
|
||||
<pre>{{$line.Content}}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
{{end}}
|
||||
{{if .IsSplitStyle}}
|
||||
{{ template "repo/diff_box_split" . }}
|
||||
{{else}}
|
||||
{{ template "repo/diff_box_unified" . }}
|
||||
<script>
|
||||
(function() {
|
||||
$('.add-code').each(function() {
|
||||
var prev = $(this).prev();
|
||||
if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
|
||||
while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
|
||||
prev = prev.prev();
|
||||
}
|
||||
prev.children().eq(3).html($(this).children().eq(3).html());
|
||||
prev.children().eq(2).html($(this).children().eq(2).html());
|
||||
prev.children().eq(3).addClass('add-code');
|
||||
prev.children().eq(2).addClass('add-code');
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
}());
|
||||
</script>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
{{range $i, $file := .Diff.Files}}
|
||||
<div class="diff-file-box diff-box file-content" id="diff-{{.Index}}">
|
||||
<h4 class="ui top attached normal header">
|
||||
<div class="diff-counter count ui left">
|
||||
{{if $file.IsBin}}
|
||||
{{$.i18n.Tr "repo.diff.bin"}}
|
||||
{{else if not $file.IsRenamed}}
|
||||
<span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
|
||||
<span class="bar">
|
||||
<span class="pull-left add"></span>
|
||||
<span class="pull-left del"></span>
|
||||
</span>
|
||||
<span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<span class="file">{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}</span>
|
||||
<div class="ui right">
|
||||
{{if $file.IsDeleted}}
|
||||
<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
|
||||
{{else}}
|
||||
<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</h4>
|
||||
<div class="ui attached table segment">
|
||||
{{if not $file.IsRenamed}}
|
||||
{{$isImage := (call $.IsImageFile $file.Name)}}
|
||||
{{if and $isImage}}
|
||||
<div class="center">
|
||||
<img src="{{$.RawPath}}/{{EscapePound .Name}}">
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="file-body file-code code-view code-diff">
|
||||
<table>
|
||||
<tbody>
|
||||
{{range $j, $section := .Sections}}
|
||||
{{range $k, $line := .Lines}}
|
||||
<tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$k}} ol-{{$k}}">
|
||||
{{if eq .Type 4}}
|
||||
<td class="lines-num lines-num-old">
|
||||
<span class="{{if gt $j 0}}fold octicon octicon-fold{{end}}"></span>
|
||||
</td>
|
||||
<td class="lines-code halfwidth">
|
||||
<pre class="wrap">{{$line.Content}}</pre>
|
||||
</td>
|
||||
<td class="lines-num lines-num-old">
|
||||
<span class="{{if gt $j 0}}fold octicon octicon-fold{{end}}"></span>
|
||||
</td>
|
||||
<td class="lines-code halfwidth">
|
||||
<pre class="wrap">{{$line.Content}}</pre>
|
||||
</td>
|
||||
{{else}}
|
||||
<td class="lines-num lines-num-old">
|
||||
<span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
|
||||
</td>
|
||||
<td class="lines-code halfwidth">
|
||||
<pre class="wrap">{{if $line.LeftIdx}}{{$line.Content}}{{end}}</pre>
|
||||
</td>
|
||||
<td class="lines-num lines-num-new">
|
||||
<span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
|
||||
</td>
|
||||
<td class="lines-code halfwidth">
|
||||
<pre class="wrap">{{if $line.RightIdx}}{{$line.Content}}{{end}}</pre>
|
||||
</td>
|
||||
{{end}}
|
||||
</tr>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
(function() {
|
||||
$('.add-code').each(function() {
|
||||
var prev = $(this).prev();
|
||||
if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
|
||||
while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
|
||||
prev = prev.prev();
|
||||
}
|
||||
prev.children().eq(3).html($(this).children().eq(3).html());
|
||||
prev.children().eq(2).html($(this).children().eq(2).html());
|
||||
prev.children().eq(3).addClass('add-code');
|
||||
prev.children().eq(2).addClass('add-code');
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
}());
|
||||
</script>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
{{end}}
|
|
@ -1,65 +0,0 @@
|
|||
{{range $i, $file := .Diff.Files}}
|
||||
<div class="diff-file-box diff-box file-content" id="diff-{{.Index}}">
|
||||
<h4 class="ui top attached normal header">
|
||||
<div class="diff-counter count ui left">
|
||||
{{if $file.IsBin}}
|
||||
{{$.i18n.Tr "repo.diff.bin"}}
|
||||
{{else if not $file.IsRenamed}}
|
||||
<span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
|
||||
<span class="bar">
|
||||
<span class="pull-left add"></span>
|
||||
<span class="pull-left del"></span>
|
||||
</span>
|
||||
<span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
|
||||
{{end}}
|
||||
</div>
|
||||
<span class="file">{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}</span>
|
||||
<div class="ui right">
|
||||
{{if $file.IsDeleted}}
|
||||
<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
|
||||
{{else}}
|
||||
<a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</h4>
|
||||
<div class="ui attached table segment">
|
||||
{{if not $file.IsRenamed}}
|
||||
{{$isImage := (call $.IsImageFile $file.Name)}}
|
||||
{{if and $isImage}}
|
||||
<div class="center">
|
||||
<img src="{{$.RawPath}}/{{EscapePound .Name}}">
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="file-body file-code code-view code-diff">
|
||||
<table>
|
||||
<tbody>
|
||||
{{range $j, $section := .Sections}}
|
||||
{{range $k, $line := .Lines}}
|
||||
<tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$k}} ol-{{$k}}">
|
||||
{{if eq .Type 4}}
|
||||
<td colspan="2" class="lines-num">
|
||||
{{if gt $j 0}}<span class="fold octicon octicon-fold"></span>{{end}}
|
||||
</td>
|
||||
{{else}}
|
||||
<td class="lines-num lines-num-old">
|
||||
<span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
|
||||
</td>
|
||||
<td class="lines-num lines-num-new">
|
||||
<span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
|
||||
</td>
|
||||
{{end}}
|
||||
<td class="lines-code">
|
||||
<pre>{{$line.Content}}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
{{end}}
|
Loading…
Reference in New Issue