mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-24 18:56:11 +01:00
21ed4fd8da
Fix #17514 Given the comments I've adjusted this somewhat. The numbers of characters detected are increased and include things like the use of U+300 to make à instead of à and non-breaking spaces. There is a button which can be used to escape the content to show it. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Gwyneth Morgan <gwymor@tilde.club> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
59 lines
3.7 KiB
Handlebars
59 lines
3.7 KiB
Handlebars
{{$file := .file}}
|
|
{{range $j, $section := $file.Sections}}
|
|
{{range $k, $line := $section.Lines}}
|
|
{{if or $.root.AfterCommitID (ne .GetType 4)}}
|
|
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{DiffLineTypeToStr .GetType}}">
|
|
{{if eq .GetType 4}}
|
|
<td colspan="2" class="lines-num">
|
|
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5) }}
|
|
<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=down" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}">
|
|
{{svg "octicon-fold-down"}}
|
|
</a>
|
|
{{end}}
|
|
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4) }}
|
|
<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=up" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}">
|
|
{{svg "octicon-fold-up"}}
|
|
</a>
|
|
{{end}}
|
|
{{if eq $line.GetExpandDirection 2}}
|
|
<a role="button" class="blob-excerpt" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=" data-anchor="diff-{{Sha1 $file.Name}}K{{$line.SectionInfo.RightIdx}}">
|
|
{{svg "octicon-fold"}}
|
|
</a>
|
|
{{end}}
|
|
</td>
|
|
{{else}}
|
|
<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>
|
|
<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>
|
|
{{end}}
|
|
{{$inlineDiff := $section.GetComputedInlineDiffFor $line -}}
|
|
<td class="lines-escape">{{if $inlineDiff.EscapeStatus.Escaped}}<a href="" class="toggle-escape-button" title="{{$.i18n.Tr "repo.line_unicode"}}"></a>{{end}}</td>
|
|
<td class="lines-type-marker"><span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td>
|
|
{{if eq .GetType 4}}
|
|
<td class="chroma lines-code blob-hunk">{{/*
|
|
*/}}<code {{if $inlineDiff.EscapeStatus.Escaped}}class="code-inner has-escaped" title="{{$.root.i18n.Tr "repo.line_unicode"}}"{{else}}class="code-inner"{{end}}>{{$inlineDiff.Content}}</code>{{/*
|
|
*/}}
|
|
{{$line.Content}}
|
|
</td>
|
|
{{else}}
|
|
<td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{/*
|
|
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
|
|
*/}}<a class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">{{/*
|
|
*/}}{{svg "octicon-plus"}}{{/*
|
|
*/}}</a>{{/*
|
|
*/}}{{end}}{{/*
|
|
*/}}<code {{if $inlineDiff.EscapeStatus.Escaped}}class="code-inner has-escaped" title="{{$.root.i18n.Tr "repo.line_unicode"}}"{{else}}class="code-inner"{{end}}>{{$inlineDiff.Content}}</code>{{/*
|
|
*/}}</td>
|
|
{{end}}
|
|
</tr>
|
|
{{if gt (len $line.Comments) 0}}
|
|
<tr class="add-comment" data-line-type="{{DiffLineTypeToStr .GetType}}">
|
|
<td colspan="3" class="lines-num"></td>
|
|
<td class="add-comment-left add-comment-right" colspan="2">
|
|
{{template "repo/diff/conversation" mergeinto $.root "comments" $line.Comments}}
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|