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 9.5KB

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