You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
6.0 KiB

9 years ago
  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.TotalAddition .Diff.TotalDeletion | 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 .IsBin}}
  18. <span class="add" data-line="{{.Addition}}">{{.Addition}}</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="{{.Deletion}}">{{.Deletion}}</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 {{DiffTypeToStr .GetType}} poping up" data-content="{{DiffTypeToStr .GetType}}" 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. {{$highlightClass := $file.GetHighlightClass}}
  37. <div class="diff-file-box diff-box file-content" id="diff-{{.Index}}">
  38. <h4 class="ui top attached normal header">
  39. <div class="diff-counter count ui left">
  40. {{if $file.IsBin}}
  41. {{$.i18n.Tr "repo.diff.bin"}}
  42. {{else if not $file.IsRenamed}}
  43. <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
  44. <span class="bar">
  45. <span class="pull-left add"></span>
  46. <span class="pull-left del"></span>
  47. </span>
  48. <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
  49. {{end}}
  50. </div>
  51. <span class="file">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}</span>
  52. <div class="ui right">
  53. {{if $file.IsDeleted}}
  54. <a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  55. {{else}}
  56. <a class="ui basic tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  57. {{end}}
  58. </div>
  59. </h4>
  60. <div class="ui attached table segment">
  61. {{if not $file.IsRenamed}}
  62. {{$isImage := (call $.IsImageFile $file.Name)}}
  63. {{if and $isImage}}
  64. <div class="center">
  65. <img src="{{$.RawPath}}/{{EscapePound .Name}}">
  66. </div>
  67. {{else}}
  68. <div class="file-body file-code code-view code-diff">
  69. <table>
  70. <tbody>
  71. {{if $.IsSplitStyle}}
  72. {{range $j, $section := .Sections}}
  73. {{range $k, $line := .Lines}}
  74. <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
  75. <td class="lines-num lines-num-old">
  76. <span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
  77. </td>
  78. <td class="lines-code halfwidth">
  79. <pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></pre>
  80. </td>
  81. <td class="lines-num lines-num-new">
  82. <span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
  83. </td>
  84. <td class="lines-code halfwidth">
  85. <pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></pre>
  86. </td>
  87. </tr>
  88. {{end}}
  89. {{end}}
  90. {{else}}
  91. {{range $j, $section := .Sections}}
  92. {{range $k, $line := .Lines}}
  93. <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
  94. {{if eq .GetType 4}}
  95. <td colspan="2" class="lines-num">
  96. {{/* {{if gt $j 0}}<span class="fold octicon octicon-fold"></span>{{end}} */}}
  97. </td>
  98. {{else}}
  99. <td class="lines-num lines-num-old">
  100. <span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
  101. </td>
  102. <td class="lines-num lines-num-new">
  103. <span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
  104. </td>
  105. {{end}}
  106. <td class="lines-code">
  107. <pre><code class="{{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{$section.GetComputedInlineDiffFor $line}}</code></pre>
  108. </td>
  109. </tr>
  110. {{end}}
  111. {{end}}
  112. {{end}}
  113. </tbody>
  114. </table>
  115. </div>
  116. {{end}}
  117. {{end}}
  118. </div>
  119. </div>
  120. <br>
  121. {{end}}
  122. {{if .IsSplitStyle}}
  123. <script>
  124. (function() {
  125. $('.add-code').each(function() {
  126. var prev = $(this).prev();
  127. if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
  128. while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
  129. prev = prev.prev();
  130. }
  131. prev.children().eq(3).html($(this).children().eq(3).html());
  132. prev.children().eq(2).html($(this).children().eq(2).html());
  133. prev.children().eq(3).addClass('add-code');
  134. prev.children().eq(2).addClass('add-code');
  135. $(this).remove();
  136. }
  137. });
  138. }());
  139. </script>
  140. {{end}}
  141. {{end}}