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.

section_split.tmpl 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. {{$file := .file}}
  2. <colgroup>
  3. <col width="50">
  4. <col width="10">
  5. <col width="10">
  6. <col>
  7. <col width="50">
  8. <col width="10">
  9. <col width="10">
  10. <col>
  11. </colgroup>
  12. {{range $j, $section := $file.Sections}}
  13. {{range $k, $line := $section.Lines}}
  14. {{$hasmatch := ne $line.Match -1}}
  15. {{if or (ne .GetType 2) (not $hasmatch)}}
  16. <tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{.GetHTMLDiffLineType}}">
  17. {{if eq .GetType 4}}
  18. <td class="lines-num lines-num-old">
  19. <div class="tw-flex">
  20. {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
  21. <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
  22. {{svg "octicon-fold-down"}}
  23. </button>
  24. {{end}}
  25. {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}}
  26. <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
  27. {{svg "octicon-fold-up"}}
  28. </button>
  29. {{end}}
  30. {{if eq $line.GetExpandDirection 2}}
  31. <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
  32. {{svg "octicon-fold"}}
  33. </button>
  34. {{end}}
  35. </div>
  36. </td>{{$inlineDiff := $section.GetComputedInlineDiffFor $line ctx.Locale}}
  37. <td class="lines-escape lines-escape-old">{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}</td>
  38. <td colspan="6" class="lines-code lines-code-old ">{{/*
  39. */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{/*
  40. */}}</td>
  41. {{else if and (eq .GetType 3) $hasmatch}}{{/* DEL */}}
  42. {{$match := index $section.Lines $line.Match}}
  43. {{- $leftDiff := ""}}{{if $line.LeftIdx}}{{$leftDiff = $section.GetComputedInlineDiffFor $line ctx.Locale}}{{end}}
  44. {{- $rightDiff := ""}}{{if $match.RightIdx}}{{$rightDiff = $section.GetComputedInlineDiffFor $match ctx.Locale}}{{end}}
  45. <td class="lines-num lines-num-old del-code" data-line-num="{{$line.LeftIdx}}"><span rel="diff-{{$file.NameHash}}L{{$line.LeftIdx}}"></span></td>
  46. <td class="lines-escape del-code lines-escape-old">{{if $line.LeftIdx}}{{if $leftDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $leftDiff}}"></button>{{end}}{{end}}</td>
  47. <td class="lines-type-marker lines-type-marker-old del-code"><span class="tw-font-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td>
  48. <td class="lines-code lines-code-old del-code">{{/*
  49. */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
  50. */}}<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} tw-invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/*
  51. */}}{{svg "octicon-plus"}}{{/*
  52. */}}</button>{{/*
  53. */}}{{end}}{{/*
  54. */}}{{if $line.LeftIdx}}{{/*
  55. */}}{{template "repo/diff/section_code" dict "diff" $leftDiff}}{{/*
  56. */}}{{else}}{{/*
  57. */}}<code class="code-inner"></code>{{/*
  58. */}}{{end}}{{/*
  59. */}}</td>
  60. <td class="lines-num lines-num-new add-code" data-line-num="{{if $match.RightIdx}}{{$match.RightIdx}}{{end}}"><span rel="{{if $match.RightIdx}}diff-{{$file.NameHash}}R{{$match.RightIdx}}{{end}}"></span></td>
  61. <td class="lines-escape add-code lines-escape-new">{{if $match.RightIdx}}{{if $rightDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $rightDiff}}"></button>{{end}}{{end}}</td>
  62. <td class="lines-type-marker lines-type-marker-new add-code">{{if $match.RightIdx}}<span class="tw-font-mono" data-type-marker="{{$match.GetLineTypeMarker}}"></span>{{end}}</td>
  63. <td class="lines-code lines-code-new add-code">{{/*
  64. */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
  65. */}}<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-right{{if (not $match.CanComment)}} tw-invisible{{end}}" data-side="right" data-idx="{{$match.RightIdx}}">{{/*
  66. */}}{{svg "octicon-plus"}}{{/*
  67. */}}</button>{{/*
  68. */}}{{end}}{{/*
  69. */}}{{if $match.RightIdx}}{{/*
  70. */}}{{template "repo/diff/section_code" dict "diff" $rightDiff}}{{/*
  71. */}}{{else}}{{/*
  72. */}}<code class="code-inner"></code>{{/*
  73. */}}{{end}}{{/*
  74. */}}</td>
  75. {{else}}
  76. {{$inlineDiff := $section.GetComputedInlineDiffFor $line ctx.Locale}}
  77. <td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$file.NameHash}}L{{$line.LeftIdx}}{{end}}"></span></td>
  78. <td class="lines-escape lines-escape-old">{{if $line.LeftIdx}}{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}{{end}}</td>
  79. <td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="tw-font-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
  80. <td class="lines-code lines-code-old">{{/*
  81. */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 2))}}{{/*
  82. */}}<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} tw-invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/*
  83. */}}{{svg "octicon-plus"}}{{/*
  84. */}}</button>{{/*
  85. */}}{{end}}{{/*
  86. */}}{{if $line.LeftIdx}}{{/*
  87. */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{/*
  88. */}}{{else}}{{/*
  89. */}}<code class="code-inner"></code>{{/*
  90. */}}{{end}}{{/*
  91. */}}</td>
  92. <td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$file.NameHash}}R{{$line.RightIdx}}{{end}}"></span></td>
  93. <td class="lines-escape lines-escape-new">{{if $line.RightIdx}}{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}{{end}}</td>
  94. <td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="tw-font-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
  95. <td class="lines-code lines-code-new">{{/*
  96. */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 3))}}{{/*
  97. */}}<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-right{{if (not $line.CanComment)}} tw-invisible{{end}}" data-side="right" data-idx="{{$line.RightIdx}}">{{/*
  98. */}}{{svg "octicon-plus"}}{{/*
  99. */}}</button>{{/*
  100. */}}{{end}}{{/*
  101. */}}{{if $line.RightIdx}}{{/*
  102. */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{/*
  103. */}}{{else}}{{/*
  104. */}}<code class="code-inner"></code>{{/*
  105. */}}{{end}}{{/*
  106. */}}</td>
  107. {{end}}
  108. </tr>
  109. {{if and (eq .GetType 3) $hasmatch}}
  110. {{$match := index $section.Lines $line.Match}}
  111. {{if or $line.Comments $match.Comments}}
  112. <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
  113. <td class="add-comment-left" colspan="4">
  114. {{if $line.Comments}}
  115. {{if eq $line.GetCommentSide "previous"}}
  116. {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
  117. {{end}}
  118. {{end}}
  119. {{if $match.Comments}}
  120. {{if eq $match.GetCommentSide "previous"}}
  121. {{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}}
  122. {{end}}
  123. {{end}}
  124. </td>
  125. <td class="add-comment-right" colspan="4">
  126. {{if $line.Comments}}
  127. {{if eq $line.GetCommentSide "proposed"}}
  128. {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
  129. {{end}}
  130. {{end}}
  131. {{if $match.Comments}}
  132. {{if eq $match.GetCommentSide "proposed"}}
  133. {{template "repo/diff/conversation" dict "." $.root "comments" $match.Comments}}
  134. {{end}}
  135. {{end}}
  136. </td>
  137. </tr>
  138. {{end}}
  139. {{else if $line.Comments}}
  140. <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
  141. <td class="add-comment-left" colspan="4">
  142. {{if eq $line.GetCommentSide "previous"}}
  143. {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
  144. {{end}}
  145. </td>
  146. <td class="add-comment-right" colspan="4">
  147. {{if eq $line.GetCommentSide "proposed"}}
  148. {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
  149. {{end}}
  150. </td>
  151. </tr>
  152. {{end}}
  153. {{end}}
  154. {{end}}
  155. {{end}}