box.tmpl 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. {{if .DiffNotAvailable}}
  2. <h4>{{.i18n.Tr "repo.diff.data_not_available"}}</h4>
  3. {{else}}
  4. <div class="diff-detail-box diff-box">
  5. <div>
  6. <i class="fa fa-retweet"></i>
  7. {{.i18n.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAdditions .Diff.TotalDeletions | Str2HTML}}
  8. <div class="ui right">
  9. <a class="ui tiny basic toggle button" href="?style={{if .IsSplitStyle}}unified{{else}}split{{end}}">{{ if .IsSplitStyle }}{{.i18n.Tr "repo.diff.show_unified_view"}}{{else}}{{.i18n.Tr "repo.diff.show_split_view"}}{{end}}</a>
  10. <a class="ui tiny basic toggle button" data-target="#diff-files">{{.i18n.Tr "repo.diff.show_diff_stats"}}</a>
  11. </div>
  12. </div>
  13. <ol class="detail-files hide" id="diff-files">
  14. {{range .Diff.Files}}
  15. <li>
  16. <div class="diff-counter count pull-right">
  17. {{if not .IsBinary}}
  18. <span class="add" data-line="{{.NumAdditions}}">{{.NumAdditions}}</span>
  19. <span class="bar">
  20. <span class="pull-left add"></span>
  21. <span class="pull-left del"></span>
  22. </span>
  23. <span class="del" data-line="{{.NumDeletions}}">{{.NumDeletions}}</span>
  24. {{else}}
  25. <span>{{$.i18n.Tr "repo.diff.bin"}}</span>
  26. {{end}}
  27. </div>
  28. <!-- todo finish all file status, now modify, add, delete and rename -->
  29. <span class="status {{DiffFileTypeToStr .Type}} poping up" data-content="{{DiffFileTypeToStr .Type}}" data-variation="inverted tiny" data-position="right center">&nbsp;</span>
  30. <a class="file" href="#diff-{{.Index}}">{{.Name}}</a>
  31. </li>
  32. {{end}}
  33. </ol>
  34. </div>
  35. {{range $i, $file := .Diff.Files}}
  36. {{if $file.IsIncomplete}}
  37. <div class="diff-file-box diff-box file-content">
  38. <h4 class="ui top attached normal header">
  39. {{$.i18n.Tr "repo.diff.file_suppressed"}}
  40. <div class="diff-counter count ui left">
  41. <span class="add" data-line="{{.NumAdditions}}">+ {{.NumAdditions}}</span>
  42. <span class="bar">
  43. <span class="pull-left add"></span>
  44. <span class="pull-left del"></span>
  45. </span>
  46. <span class="del" data-line="{{.NumDeletions}}">- {{.NumDeletions}}</span>
  47. </div>
  48. <span class="file">{{$file.Name}}</span>
  49. </h4>
  50. </div>
  51. {{else}}
  52. <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}" id="diff-{{.Index}}">
  53. <h4 class="ui top attached normal header">
  54. <div class="diff-counter count ui left">
  55. {{if $file.IsBinary}}
  56. {{$.i18n.Tr "repo.diff.bin"}}
  57. {{else}}
  58. <span class="add" data-line="{{.NumAdditions}}">+ {{.NumAdditions}}</span>
  59. <span class="bar">
  60. <span class="pull-left add"></span>
  61. <span class="pull-left del"></span>
  62. </span>
  63. <span class="del" data-line="{{.NumDeletions}}">- {{.NumDeletions}}</span>
  64. {{end}}
  65. </div>
  66. <span class="file">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}</span>
  67. {{if not $file.IsSubmodule}}
  68. <div class="ui right">
  69. {{if $file.IsDeleted}}
  70. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  71. {{else if $.SourcePath}} {{/* No SourcePath we assume the source repository no longer exists */}}
  72. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  73. {{end}}
  74. </div>
  75. {{end}}
  76. </h4>
  77. <div class="ui unstackable attached table segment">
  78. {{$isImage := false}}
  79. {{if $file.IsDeleted}}
  80. {{$isImage = (call $.IsImageFileByIndex $file.Index)}}
  81. {{else}}
  82. {{$isImage = (call $.IsImageFile $file.Name)}}
  83. {{end}}
  84. {{if $isImage}}
  85. <div class="center">
  86. {{if $file.IsDeleted}}
  87. <img src="{{$.BeforeRawPath}}/{{EscapePound .Name}}">
  88. {{else}}
  89. <img src="{{$.RawPath}}/{{EscapePound .Name}}">
  90. {{end}}
  91. </div>
  92. {{else}}
  93. <div class="file-body file-code code-view code-diff">
  94. <table>
  95. <tbody>
  96. {{if $.IsSplitStyle}}
  97. {{$highlightClass := $file.HighlightClass}}
  98. {{range $j, $section := $file.Sections}}
  99. {{range $k, $line := $section.Lines}}
  100. <tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$k}} ol-{{$k}}">
  101. {{if eq .Type 4}}
  102. <td class="lines-num"></td>
  103. <td colspan="3" class="lines-code">
  104. <pre><code class="{{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{$section.ComputedInlineDiffFor $line}}</code></pre>
  105. </td>
  106. {{else}}
  107. <td class="lines-num lines-num-old" {{if $line.LeftLine}} id="diff-{{Sha1 $file.Index}}L{{$line.LeftLine}}" data-line-number="{{$line.LeftLine}}"{{end}}>
  108. </td>
  109. <td class="lines-code halfwidth">
  110. <pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.LeftLine}}{{$section.ComputedInlineDiffFor $line}}{{end}}</code></pre>
  111. </td>
  112. <td class="lines-num lines-num-new" {{if $line.RightLine}} id="diff-{{Sha1 $file.Index}}R{{$line.RightLine}}" data-line-number="{{$line.RightLine}}"{{end}}>
  113. </td>
  114. <td class="lines-code halfwidth">
  115. <pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.RightLine}}{{$section.ComputedInlineDiffFor $line}}{{end}}</code></pre>
  116. </td>
  117. {{end}}
  118. </tr>
  119. {{end}}
  120. {{end}}
  121. {{else}}
  122. {{template "repo/diff/section_unified" .}}
  123. {{end}}
  124. </tbody>
  125. </table>
  126. </div>
  127. {{end}}
  128. </div>
  129. </div>
  130. {{end}}
  131. <br>
  132. {{end}}
  133. {{if .Diff.IsIncomplete}}
  134. <div class="diff-file-box diff-box file-content">
  135. <h4 class="ui top attached normal header">
  136. {{$.i18n.Tr "repo.diff.too_many_files"}}
  137. </h4>
  138. </div>
  139. {{end}}
  140. {{if .IsSplitStyle}}
  141. <script>
  142. (function() {
  143. $('.add-code').each(function() {
  144. var prev = $(this).prev();
  145. if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
  146. while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
  147. prev = prev.prev();
  148. }
  149. prev.children().eq(3).html($(this).children().eq(3).html());
  150. prev.children().eq(2).html($(this).children().eq(2).html());
  151. prev.children().eq(3).addClass('add-code');
  152. prev.children().eq(2).addClass('add-code');
  153. $(this).remove();
  154. }
  155. });
  156. }());
  157. </script>
  158. {{end}}
  159. {{end}}