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_unified.tmpl 3.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. {{$file := .file}}
  2. <colgroup>
  3. <col width="50">
  4. <col width="50">
  5. <col width="10">
  6. <col width="10">
  7. <col>
  8. </colgroup>
  9. {{range $j, $section := $file.Sections}}
  10. {{range $k, $line := $section.Lines}}
  11. <tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{.GetHTMLDiffLineType}}">
  12. {{if eq .GetType 4}}
  13. {{if $.root.AfterCommitID}}
  14. <td colspan="2" class="lines-num">
  15. <div class="tw-flex">
  16. {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
  17. <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
  18. {{svg "octicon-fold-down"}}
  19. </button>
  20. {{end}}
  21. {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}}
  22. <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
  23. {{svg "octicon-fold-up"}}
  24. </button>
  25. {{end}}
  26. {{if eq $line.GetExpandDirection 2}}
  27. <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
  28. {{svg "octicon-fold"}}
  29. </button>
  30. {{end}}
  31. </div>
  32. </td>
  33. {{else}}
  34. {{/* for code file preview page or comment diffs on pull comment pages, do not show the expansion arrows */}}
  35. <td colspan="2" class="lines-num"></td>
  36. {{end}}
  37. {{else}}
  38. <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>
  39. <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>
  40. {{end}}
  41. {{$inlineDiff := $section.GetComputedInlineDiffFor $line ctx.Locale -}}
  42. <td class="lines-escape">
  43. {{- if $inlineDiff.EscapeStatus.Escaped -}}
  44. <button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>
  45. {{- end -}}
  46. </td>
  47. <td class="lines-type-marker"><span class="tw-font-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td>
  48. {{if eq .GetType 4}}
  49. <td class="chroma lines-code blob-hunk">{{/*
  50. */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{/*
  51. */}}</td>
  52. {{else}}
  53. <td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{/*
  54. */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
  55. */}}<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} tw-invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">{{/*
  56. */}}{{svg "octicon-plus"}}{{/*
  57. */}}</button>{{/*
  58. */}}{{end}}{{/*
  59. */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{/*
  60. */}}</td>
  61. {{end}}
  62. </tr>
  63. {{if $line.Comments}}
  64. <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
  65. <td class="add-comment-left add-comment-right" colspan="5">
  66. {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
  67. </td>
  68. </tr>
  69. {{end}}
  70. {{end}}
  71. {{end}}