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.

box.tmpl 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. {{if .DiffNotAvailable}}
  2. <div class="diff-detail-box diff-box ui sticky">
  3. <div>
  4. <div class="ui right">
  5. {{if .PageIsPullFiles}}
  6. {{template "repo/diff/whitespace_dropdown" .}}
  7. {{else}}
  8. <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>
  9. {{end}}
  10. <a class="ui tiny basic toggle button" data-target="#diff-files">{{.i18n.Tr "repo.diff.show_diff_stats"}}</a>
  11. {{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}}
  12. {{template "repo/diff/new_review" .}}
  13. {{end}}
  14. </div>
  15. </div>
  16. </div>
  17. <h4>{{.i18n.Tr "repo.diff.data_not_available"}}</h4>
  18. {{else}}
  19. <div class="diff-detail-box diff-box ui sticky">
  20. <div>
  21. <i class="fa fa-retweet"></i>
  22. {{.i18n.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}}
  23. <div class="ui right">
  24. {{if .PageIsPullFiles}}
  25. {{template "repo/diff/whitespace_dropdown" .}}
  26. {{else}}
  27. <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>
  28. {{end}}
  29. <a class="ui tiny basic toggle button" data-target="#diff-files">{{.i18n.Tr "repo.diff.show_diff_stats"}}</a>
  30. {{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}}
  31. {{template "repo/diff/new_review" .}}
  32. {{end}}
  33. </div>
  34. </div>
  35. <ol class="detail-files hide" id="diff-files">
  36. {{range .Diff.Files}}
  37. <li>
  38. <div class="diff-counter count pull-right">
  39. {{if not .IsBin}}
  40. <span class="add" data-line="{{.Addition}}">{{.Addition}}</span>
  41. <span class="bar">
  42. <div class="pull-left add"></div>
  43. <div class="pull-left del"></div>
  44. </span>
  45. <span class="del" data-line="{{.Deletion}}">{{.Deletion}}</span>
  46. {{else}}
  47. <span>{{$.i18n.Tr "repo.diff.bin"}}</span>
  48. {{end}}
  49. </div>
  50. <!-- todo finish all file status, now modify, add, delete and rename -->
  51. <span class="status {{DiffTypeToStr .GetType}} poping up" data-content="{{DiffTypeToStr .GetType}}" data-variation="inverted tiny" data-position="right center">&nbsp;</span>
  52. <a class="file" href="#diff-{{.Index}}">{{.Name}}</a>
  53. </li>
  54. {{end}}
  55. </ol>
  56. </div>
  57. {{range $i, $file := .Diff.Files}}
  58. {{if $file.IsIncomplete}}
  59. <div class="diff-file-box diff-box file-content">
  60. <h4 class="ui top attached normal header rounded">
  61. <div class="diff-counter count ui left">
  62. {{if not $file.IsRenamed}}
  63. <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
  64. <span class="bar">
  65. <div class="pull-left add"></div>
  66. <div class="pull-left del"></div>
  67. </span>
  68. <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
  69. {{end}}
  70. </div>
  71. <span class="file">{{$file.Name}}</span>
  72. <div>{{$.i18n.Tr "repo.diff.file_suppressed"}}</div>
  73. {{if not $file.IsSubmodule}}
  74. {{if $file.IsDeleted}}
  75. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  76. {{else}}
  77. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  78. {{end}}
  79. {{end}}
  80. </h4>
  81. </div>
  82. {{else}}
  83. <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}" id="diff-{{.Index}}">
  84. <h4 class="ui top attached normal header">
  85. <div class="diff-counter count">
  86. {{if $file.IsBin}}
  87. {{$.i18n.Tr "repo.diff.bin"}}
  88. {{else if not $file.IsRenamed}}
  89. <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
  90. <span class="bar">
  91. <div class="pull-left add"></div>
  92. <div class="pull-left del"></div>
  93. </span>
  94. <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
  95. {{end}}
  96. </div>
  97. <span class="file">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}</span>
  98. {{if not $file.IsSubmodule}}
  99. {{if $file.IsDeleted}}
  100. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  101. {{else}}
  102. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  103. {{end}}
  104. {{end}}
  105. </h4>
  106. <div class="ui attached unstackable table segment">
  107. {{if ne $file.Type 4}}
  108. {{$isImage := (call $.IsImageFile $file.Name)}}
  109. {{if and $isImage}}
  110. <div class="center">
  111. <img src="{{$.RawPath}}/{{EscapePound .Name}}">
  112. </div>
  113. {{else}}
  114. <div class="file-body file-code code-view code-diff {{if $.IsSplitStyle}}code-diff-split{{else}}code-diff-unified{{end}}">
  115. <table>
  116. <tbody>
  117. {{if $.IsSplitStyle}}
  118. {{$highlightClass := $file.GetHighlightClass}}
  119. {{range $j, $section := $file.Sections}}
  120. {{range $k, $line := $section.Lines}}
  121. <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
  122. <td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}">
  123. <span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}"></span>
  124. </td>
  125. <td class="lines-type-marker">
  126. <pre>{{if $line.LeftIdx}}<span class="line-type-marker" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</pre>
  127. </td>
  128. <td class="lines-code lines-code-old halfwidth">
  129. {{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 2))}}
  130. <a class="ui green button add-code-comment add-code-comment-left" data-path="{{$file.Name}}" data-side="left" data-idx="{{$line.LeftIdx}}">+</a>
  131. {{end}}
  132. <pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></pre>
  133. </td>
  134. <td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}">
  135. <span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}"></span>
  136. </td>
  137. <td class="lines-type-marker">
  138. <pre>{{if $line.RightIdx}}<span class="line-type-marker" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</pre>
  139. </td>
  140. <td class="lines-code lines-code-new halfwidth">
  141. {{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 3))}}
  142. <a class="ui green button add-code-comment add-code-comment-right" data-path="{{$file.Name}}" data-side="right" data-idx="{{$line.RightIdx}}">+</a>
  143. {{end}}
  144. <pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></pre>
  145. </td>
  146. </tr>
  147. {{if gt (len $line.Comments) 0}}
  148. <tr class="add-code-comment">
  149. <td class="lines-num"></td>
  150. <td class="lines-type-marker"></td>
  151. <td class="add-comment-left">
  152. {{if eq $line.GetCommentSide "previous"}}
  153. <div class="field comment-code-cloud">
  154. <div class="comment-list">
  155. <ui class="ui comments">
  156. {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
  157. </ui>
  158. </div>
  159. {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
  160. </div>
  161. {{end}}
  162. </td>
  163. <td class="lines-num"></td>
  164. <td class="lines-type-marker"></td>
  165. <td class="add-comment-right">
  166. {{if eq $line.GetCommentSide "proposed"}}
  167. <div class="field comment-code-cloud">
  168. <div class="comment-list">
  169. <ui class="ui comments">
  170. {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
  171. </ui>
  172. </div>
  173. {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
  174. </div>
  175. {{end}}
  176. </td>
  177. </tr>
  178. {{end}}
  179. {{end}}
  180. {{end}}
  181. {{else}}
  182. {{template "repo/diff/section_unified" dict "file" . "root" $}}
  183. {{end}}
  184. </tbody>
  185. </table>
  186. </div>
  187. {{end}}
  188. {{end}}
  189. </div>
  190. </div>
  191. {{end}}
  192. <br>
  193. {{end}}
  194. {{if .Diff.IsIncomplete}}
  195. <div class="diff-file-box diff-box file-content">
  196. <h4 class="ui top attached normal header">
  197. {{$.i18n.Tr "repo.diff.too_many_files"}}
  198. </h4>
  199. </div>
  200. {{end}}
  201. {{if not $.Repository.IsArchived}}
  202. <div id="pull_review_add_comment" class="hide">
  203. {{template "repo/diff/new_comment" dict "root" .}}
  204. </div>
  205. <div class="hide" id="edit-content-form">
  206. <div class="ui comment form">
  207. <div class="ui top attached tabular menu">
  208. <a class="active write item">{{$.i18n.Tr "write"}}</a>
  209. <a class="preview item" data-url="{{$.Repository.APIURL}}/markdown" data-context="{{$.RepoLink}}">{{$.i18n.Tr "preview"}}</a>
  210. </div>
  211. <div class="ui bottom attached active write tab segment">
  212. <textarea tabindex="1" name="content"></textarea>
  213. </div>
  214. <div class="ui bottom attached tab preview segment markdown">
  215. {{$.i18n.Tr "loading"}}
  216. </div>
  217. <div class="text right edit buttons">
  218. <div class="ui basic blue cancel button" tabindex="3">{{.i18n.Tr "repo.issues.cancel"}}</div>
  219. <div class="ui green save button" tabindex="2">{{.i18n.Tr "repo.issues.save"}}</div>
  220. </div>
  221. </div>
  222. </div>
  223. {{end}}
  224. {{if .IsSplitStyle}}
  225. <script>
  226. document.addEventListener('DOMContentLoaded', function() {
  227. $('tr.add-code').each(function() {
  228. var prev = $(this).prev();
  229. if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
  230. while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
  231. prev = prev.prev();
  232. }
  233. prev.children().eq(2).html($(this).children().eq(2).html());
  234. prev.children().eq(3).html($(this).children().eq(3).html());
  235. prev.children().eq(0).addClass('del-code');
  236. prev.children().eq(1).addClass('del-code');
  237. prev.children().eq(2).addClass('add-code');
  238. prev.children().eq(3).addClass('add-code');
  239. $(this).remove();
  240. }
  241. });
  242. });
  243. </script>
  244. {{end}}
  245. {{end}}