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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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}}"><span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}"></span></td>
  123. <td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
  124. <td class="lines-code lines-code-old halfwidth">{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 2))}}<a class="ui green button add-code-comment add-code-comment-left" data-path="{{$file.Name}}" data-side="left" data-idx="{{$line.LeftIdx}}">+</a>{{end}}<span class="mono wrap{{if $highlightClass}} language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
  125. <td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}"></span></td>
  126. <td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
  127. <td class="lines-code lines-code-new halfwidth">{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 3))}}<a class="ui green button add-code-comment add-code-comment-right" data-path="{{$file.Name}}" data-side="right" data-idx="{{$line.RightIdx}}">+</a>{{end}}<span class="mono wrap{{if $highlightClass}} language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
  128. </tr>
  129. {{if gt (len $line.Comments) 0}}
  130. <tr class="add-code-comment">
  131. <td class="lines-num"></td>
  132. <td class="lines-type-marker"></td>
  133. <td class="add-comment-left">
  134. {{if eq $line.GetCommentSide "previous"}}
  135. <div class="field comment-code-cloud">
  136. <div class="comment-list">
  137. <ui class="ui comments">
  138. {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
  139. </ui>
  140. </div>
  141. {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
  142. </div>
  143. {{end}}
  144. </td>
  145. <td class="lines-num"></td>
  146. <td class="lines-type-marker"></td>
  147. <td class="add-comment-right">
  148. {{if eq $line.GetCommentSide "proposed"}}
  149. <div class="field comment-code-cloud">
  150. <div class="comment-list">
  151. <ui class="ui comments">
  152. {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
  153. </ui>
  154. </div>
  155. {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
  156. </div>
  157. {{end}}
  158. </td>
  159. </tr>
  160. {{end}}
  161. {{end}}
  162. {{end}}
  163. {{else}}
  164. {{template "repo/diff/section_unified" dict "file" . "root" $}}
  165. {{end}}
  166. </tbody>
  167. </table>
  168. </div>
  169. {{end}}
  170. {{end}}
  171. </div>
  172. </div>
  173. {{end}}
  174. <br>
  175. {{end}}
  176. {{if .Diff.IsIncomplete}}
  177. <div class="diff-file-box diff-box file-content">
  178. <h4 class="ui top attached normal header">
  179. {{$.i18n.Tr "repo.diff.too_many_files"}}
  180. </h4>
  181. </div>
  182. {{end}}
  183. {{if not $.Repository.IsArchived}}
  184. <div id="pull_review_add_comment" class="hide">
  185. {{template "repo/diff/new_comment" dict "root" .}}
  186. </div>
  187. <div class="hide" id="edit-content-form">
  188. <div class="ui comment form">
  189. <div class="ui top attached tabular menu">
  190. <a class="active write item">{{$.i18n.Tr "write"}}</a>
  191. <a class="preview item" data-url="{{$.Repository.APIURL}}/markdown" data-context="{{$.RepoLink}}">{{$.i18n.Tr "preview"}}</a>
  192. </div>
  193. <div class="ui bottom attached active write tab segment">
  194. <textarea tabindex="1" name="content"></textarea>
  195. </div>
  196. <div class="ui bottom attached tab preview segment markdown">
  197. {{$.i18n.Tr "loading"}}
  198. </div>
  199. <div class="text right edit buttons">
  200. <div class="ui basic blue cancel button" tabindex="3">{{.i18n.Tr "repo.issues.cancel"}}</div>
  201. <div class="ui green save button" tabindex="2">{{.i18n.Tr "repo.issues.save"}}</div>
  202. </div>
  203. </div>
  204. </div>
  205. {{end}}
  206. {{if .IsSplitStyle}}
  207. <script>
  208. document.addEventListener('DOMContentLoaded', function() {
  209. $('tr.add-code').each(function() {
  210. var prev = $(this).prev();
  211. if(prev.is('.del-code') && prev.children().eq(5).text().trim() === '') {
  212. while(prev.prev().is('.del-code') && prev.prev().children().eq(5).text().trim() === '') {
  213. prev = prev.prev();
  214. }
  215. prev.children().eq(3).attr("data-line-num", $(this).children().eq(3).attr("data-line-num"));
  216. prev.children().eq(3).html($(this).children().eq(3).html());
  217. prev.children().eq(4).html($(this).children().eq(4).html());
  218. prev.children().eq(5).html($(this).children().eq(5).html());
  219. prev.children().eq(0).addClass('del-code');
  220. prev.children().eq(1).addClass('del-code');
  221. prev.children().eq(2).addClass('del-code');
  222. prev.children().eq(3).addClass('add-code');
  223. prev.children().eq(4).addClass('add-code');
  224. prev.children().eq(5).addClass('add-code');
  225. $(this).remove();
  226. }
  227. });
  228. });
  229. </script>
  230. {{end}}
  231. {{end}}