summaryrefslogtreecommitdiffstats
path: root/templates/repo
diff options
context:
space:
mode:
authorAndrey Nering <andrey.nering@gmail.com>2016-06-29 12:11:00 -0300
committer无闻 <u@gogs.io>2016-06-29 23:11:00 +0800
commit743d22669a49b743f1963dc579294a092c4980c1 (patch)
treedcb537495d87ae31e1b041d999a72c3dfc27b89a /templates/repo
parent84841c8c4b257bd627fcc033112237d40e3a329a (diff)
downloadgitea-743d22669a49b743f1963dc579294a092c4980c1.tar.gz
gitea-743d22669a49b743f1963dc579294a092c4980c1.zip
Re-work MAX_DIFF_LINES: supress diff per file, not the whole diff (#3174)
Diffstat (limited to 'templates/repo')
-rw-r--r--templates/repo/diff_box.tmpl186
1 files changed, 107 insertions, 79 deletions
diff --git a/templates/repo/diff_box.tmpl b/templates/repo/diff_box.tmpl
index 455f07002c..cfb3466cd3 100644
--- a/templates/repo/diff_box.tmpl
+++ b/templates/repo/diff_box.tmpl
@@ -34,92 +34,120 @@
</div>
{{range $i, $file := .Diff.Files}}
- {{$highlightClass := $file.GetHighlightClass}}
- <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}} &rarr; {{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 .GetType}}-code nl-{{$k}} ol-{{$k}}">
- <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><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></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><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></pre>
- </td>
- </tr>
+ {{if $file.IsIncomplete}}
+ <div class="diff-file-box diff-box file-content">
+ <h4 class="ui top attached normal header">
+ {{$.i18n.Tr "repo.diff.file_supressed"}}
+ <div class="diff-counter count ui left">
+ {{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">{{$file.Name}}</span>
+ </h4>
+ </div>
+ {{else}}
+ {{$highlightClass := $file.GetHighlightClass}}
+ <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}} &rarr; {{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 .GetType}}-code nl-{{$k}} ol-{{$k}}">
+ <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><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></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><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></pre>
+ </td>
+ </tr>
+ {{end}}
{{end}}
- {{end}}
- {{else}}
- {{range $j, $section := .Sections}}
- {{range $k, $line := .Lines}}
- <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
- {{if eq .GetType 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><code class="{{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{$section.GetComputedInlineDiffFor $line}}</code></pre>
- </td>
- </tr>
+ {{else}}
+ {{range $j, $section := .Sections}}
+ {{range $k, $line := .Lines}}
+ <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
+ {{if eq .GetType 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><code class="{{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{$section.GetComputedInlineDiffFor $line}}</code></pre>
+ </td>
+ </tr>
+ {{end}}
{{end}}
{{end}}
- {{end}}
- </tbody>
- </table>
- </div>
+ </tbody>
+ </table>
+ </div>
+ {{end}}
{{end}}
- {{end}}
+ </div>
</div>
- </div>
+ {{end}}
<br>
{{end}}
+
+ {{if .Diff.IsIncomplete}}
+ <div class="diff-file-box diff-box file-content">
+ <h4 class="ui top attached normal header">
+ {{$.i18n.Tr "repo.diff.too_many_files"}}
+ </h4>
+ </div>
+ {{end}}
+
{{if .IsSplitStyle}}
<script>
(function() {