本站源代码
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

240 lines
11KB

  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. {{template "repo/diff/options_dropdown" .}}
  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>
  20. <div class="diff-detail-box diff-box ui sticky">
  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. {{template "repo/diff/options_dropdown" .}}
  30. {{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}}
  31. {{template "repo/diff/new_review" .}}
  32. {{end}}
  33. </div>
  34. </div>
  35. <ol class="diff-detail-box diff-stats 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. {{range $i, $file := .Diff.Files}}
  57. {{if $file.IsIncomplete}}
  58. <div class="diff-file-box diff-box file-content">
  59. <h4 class="ui top attached normal header rounded">
  60. <div class="diff-counter count ui left">
  61. {{if not $file.IsRenamed}}
  62. <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
  63. <span class="bar">
  64. <div class="pull-left add"></div>
  65. <div class="pull-left del"></div>
  66. </span>
  67. <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
  68. {{end}}
  69. </div>
  70. <span class="file">{{$file.Name}}</span>
  71. <div>{{$.i18n.Tr "repo.diff.file_suppressed"}}</div>
  72. {{if not $file.IsSubmodule}}
  73. {{if $file.IsDeleted}}
  74. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  75. {{else}}
  76. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  77. {{end}}
  78. {{end}}
  79. </h4>
  80. </div>
  81. {{else}}
  82. <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}" id="diff-{{.Index}}">
  83. <h4 class="ui top attached normal header">
  84. <div class="diff-counter count">
  85. {{if $file.IsBin}}
  86. {{$.i18n.Tr "repo.diff.bin"}}
  87. {{else if not $file.IsRenamed}}
  88. <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
  89. <span class="bar">
  90. <div class="pull-left add"></div>
  91. <div class="pull-left del"></div>
  92. </span>
  93. <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
  94. {{end}}
  95. </div>
  96. <span class="file">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}</span>
  97. {{if not $file.IsSubmodule}}
  98. {{if $file.IsDeleted}}
  99. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  100. {{else}}
  101. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  102. {{end}}
  103. {{end}}
  104. </h4>
  105. <div class="ui attached unstackable table segment">
  106. {{if ne $file.Type 4}}
  107. {{$isImage := false}}
  108. {{if $file.IsDeleted}}
  109. {{$isImage = (call $.IsImageFileInBase $file.Name)}}
  110. {{else}}
  111. {{$isImage = (call $.IsImageFileInHead $file.Name)}}
  112. {{end}}
  113. <div class="file-body file-code code-view code-diff {{if $.IsSplitStyle}}code-diff-split{{else}}code-diff-unified{{end}}">
  114. <table>
  115. <tbody>
  116. {{if $isImage}}
  117. {{template "repo/diff/image_diff" dict "file" . "root" $}}
  118. {{else}}
  119. {{if $.IsSplitStyle}}
  120. {{$highlightClass := $file.GetHighlightClass}}
  121. {{range $j, $section := $file.Sections}}
  122. {{range $k, $line := $section.Lines}}
  123. <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
  124. <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>
  125. <td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
  126. <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>
  127. <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>
  128. <td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
  129. <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>
  130. </tr>
  131. {{if gt (len $line.Comments) 0}}
  132. <tr class="add-code-comment">
  133. <td class="lines-num"></td>
  134. <td class="lines-type-marker"></td>
  135. <td class="add-comment-left">
  136. {{if eq $line.GetCommentSide "previous"}}
  137. <div class="field comment-code-cloud">
  138. <div class="comment-list">
  139. <ui class="ui comments">
  140. {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
  141. </ui>
  142. </div>
  143. {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
  144. </div>
  145. {{end}}
  146. </td>
  147. <td class="lines-num"></td>
  148. <td class="lines-type-marker"></td>
  149. <td class="add-comment-right">
  150. {{if eq $line.GetCommentSide "proposed"}}
  151. <div class="field comment-code-cloud">
  152. <div class="comment-list">
  153. <ui class="ui comments">
  154. {{ template "repo/diff/comments" dict "root" $ "comments" $line.Comments}}
  155. </ui>
  156. </div>
  157. {{template "repo/diff/comment_form_datahandler" dict "reply" (index $line.Comments 0).ReviewID "hidden" true "root" $ "comment" (index $line.Comments 0)}}
  158. </div>
  159. {{end}}
  160. </td>
  161. </tr>
  162. {{end}}
  163. {{end}}
  164. {{end}}
  165. {{else}}
  166. {{template "repo/diff/section_unified" dict "file" . "root" $}}
  167. {{end}}
  168. {{end}}
  169. </tbody>
  170. </table>
  171. </div>
  172. {{end}}
  173. </div>
  174. </div>
  175. {{end}}
  176. <br>
  177. {{end}}
  178. {{if .Diff.IsIncomplete}}
  179. <div class="diff-file-box diff-box file-content">
  180. <h4 class="ui top attached normal header">
  181. {{$.i18n.Tr "repo.diff.too_many_files"}}
  182. </h4>
  183. </div>
  184. {{end}}
  185. {{if not $.Repository.IsArchived}}
  186. <div id="pull_review_add_comment" class="hide">
  187. {{template "repo/diff/new_comment" dict "root" .}}
  188. </div>
  189. <div class="hide" id="edit-content-form">
  190. <div class="ui comment form">
  191. <div class="ui top attached tabular menu">
  192. <a class="active write item">{{$.i18n.Tr "write"}}</a>
  193. <a class="preview item" data-url="{{$.Repository.APIURL}}/markdown" data-context="{{$.RepoLink}}">{{$.i18n.Tr "preview"}}</a>
  194. </div>
  195. <div class="ui bottom attached active write tab segment">
  196. <textarea tabindex="1" name="content"></textarea>
  197. </div>
  198. <div class="ui bottom attached tab preview segment markdown">
  199. {{$.i18n.Tr "loading"}}
  200. </div>
  201. <div class="text right edit buttons">
  202. <div class="ui basic blue cancel button" tabindex="3">{{.i18n.Tr "repo.issues.cancel"}}</div>
  203. <div class="ui green save button" tabindex="2">{{.i18n.Tr "repo.issues.save"}}</div>
  204. </div>
  205. </div>
  206. </div>
  207. {{end}}
  208. {{if .IsSplitStyle}}
  209. <script>
  210. document.addEventListener('DOMContentLoaded', function() {
  211. $('tr.add-code').each(function() {
  212. var prev = $(this).prev();
  213. if(prev.is('.del-code') && prev.children().eq(5).text().trim() === '') {
  214. while(prev.prev().is('.del-code') && prev.prev().children().eq(5).text().trim() === '') {
  215. prev = prev.prev();
  216. }
  217. prev.children().eq(3).attr("data-line-num", $(this).children().eq(3).attr("data-line-num"));
  218. prev.children().eq(3).html($(this).children().eq(3).html());
  219. prev.children().eq(4).html($(this).children().eq(4).html());
  220. prev.children().eq(5).html($(this).children().eq(5).html());
  221. prev.children().eq(0).addClass('del-code');
  222. prev.children().eq(1).addClass('del-code');
  223. prev.children().eq(2).addClass('del-code');
  224. prev.children().eq(3).addClass('add-code');
  225. prev.children().eq(4).addClass('add-code');
  226. prev.children().eq(5).addClass('add-code');
  227. $(this).remove();
  228. }
  229. });
  230. });
  231. </script>
  232. {{end}}
  233. </div>
  234. {{end}}
上海开阖软件有限公司 沪ICP备12045867号-1