code.gitea.io/gitea@v1.22.3/templates/repo/diff/section_split.tmpl (about)

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