gitea源码

section_unified.tmpl 4.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. {{$file := .file}}
  2. {{$repoLink := or ctx.RootData.CommitRepoLink ctx.RootData.RepoLink}}
  3. {{$afterCommitID := or $.root.AfterCommitID "no-after-commit-id"}}{{/* this tmpl is also used by the PR Conversation page, so the "AfterCommitID" may not exist */}}
  4. {{$blobExcerptLink := print $repoLink (Iif $.root.PageIsWiki "/wiki" "") "/blob_excerpt/" (PathEscape $afterCommitID) "?"}}
  5. <colgroup>
  6. <col width="50">
  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. <tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{.GetHTMLDiffLineType}}">
  15. {{if eq .GetType 4}}
  16. {{if $.root.AfterCommitID}}
  17. {{$expandDirection := $line.GetExpandDirection}}
  18. <td colspan="2" class="lines-num">
  19. <div class="code-expander-buttons" data-expand-direction="{{$expandDirection}}">
  20. {{if or (eq $expandDirection 3) (eq $expandDirection 5)}}
  21. <button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
  22. {{svg "octicon-fold-down"}}
  23. </button>
  24. {{end}}
  25. {{if or (eq $expandDirection 3) (eq $expandDirection 4)}}
  26. <button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
  27. {{svg "octicon-fold-up"}}
  28. </button>
  29. {{end}}
  30. {{if eq $expandDirection 2}}
  31. <button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptLink}}&{{$line.GetBlobExcerptQuery}}&style=unified&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
  32. {{svg "octicon-fold"}}
  33. </button>
  34. {{end}}
  35. </div>
  36. </td>
  37. {{else}}
  38. {{/* for code file preview page or comment diffs on pull comment pages, do not show the expansion arrows */}}
  39. <td colspan="2" class="lines-num"></td>
  40. {{end}}
  41. {{else}}
  42. <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>
  43. <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>
  44. {{end}}
  45. {{$inlineDiff := $section.GetComputedInlineDiffFor $line ctx.Locale -}}
  46. <td class="lines-escape">
  47. {{- if $inlineDiff.EscapeStatus.Escaped -}}
  48. <button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>
  49. {{- end -}}
  50. </td>
  51. <td class="lines-type-marker"><span class="tw-font-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td>
  52. {{if eq .GetType 4}}
  53. <td class="chroma lines-code blob-hunk">{{template "repo/diff/section_code" dict "diff" $inlineDiff}}</td>
  54. {{else}}
  55. <td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">
  56. {{- if and $.root.SignedUserID $.root.PageIsPullFiles -}}
  57. <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}}">
  58. {{- svg "octicon-plus" -}}
  59. </button>
  60. {{- end -}}
  61. {{- template "repo/diff/section_code" dict "diff" $inlineDiff -}}
  62. </td>
  63. {{end}}
  64. </tr>
  65. {{if $line.Comments}}
  66. <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}">
  67. <td class="add-comment-left add-comment-right" colspan="5">
  68. {{template "repo/diff/conversation" dict "." $.root "comments" $line.Comments}}
  69. </td>
  70. </tr>
  71. {{end}}
  72. {{end}}
  73. {{end}}